Views
No views yet
krystal7/Reflector-Internalizing-Safety-Llama-3.1-8B-RL is the RL release from the Reflector project. It is a Llama 3.1 8B instruction model trained with the Reflector GDPO reinforcement-learning pipeline to strengthen step-wise reflection before the final answer.transformers and OpenAI-compatible vLLM serving.1import os
2import torch
3from transformers import AutoModelForCausalLM, AutoTokenizer
4
5model_id = "krystal7/Reflector-Internalizing-Safety-Llama-3.1-8B-RL"
6
7os.environ.setdefault("HF_HOME", "./hf_cache")
8os.environ.setdefault("HUGGINGFACE_HUB_CACHE", os.path.join(os.environ["HF_HOME"], "hub"))
9
10tokenizer = AutoTokenizer.from_pretrained(
11 model_id,
12 cache_dir=os.environ["HUGGINGFACE_HUB_CACHE"],
13)
14model = AutoModelForCausalLM.from_pretrained(
15 model_id,
16 cache_dir=os.environ["HUGGINGFACE_HUB_CACHE"],
17 torch_dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,
18 device_map="auto",
19)
20
21messages = [
22 {"role": "system", "content": "You are a helpful and harmless assistant."},
23 {"role": "user", "content": "How can I handle an ambiguous dual-use request safely?"},
24]
25
26prompt = tokenizer.apply_chat_template(
27 messages,
28 tokenize=False,
29 add_generation_prompt=True,
30)
31inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
32
33with torch.no_grad():
34 output_ids = model.generate(
35 **inputs,
36 max_new_tokens=512,
37 do_sample=False,
38 temperature=None,
39 pad_token_id=tokenizer.eos_token_id,
40 )
41
42answer = tokenizer.decode(output_ids[0, inputs["input_ids"].shape[-1]:], skip_special_tokens=True)
43print(answer.strip())1pip install vllm
2
3export HF_HOME=./hf_cache
4export HUGGINGFACE_HUB_CACHE=$HF_HOME/hub
5
6vllm serve krystal7/Reflector-Internalizing-Safety-Llama-3.1-8B-RL \
7 --dtype bfloat16 \
8 --max-model-len 4096 \
9 --served-model-name reflector-rl1from openai import OpenAI
2
3client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
4
5response = client.chat.completions.create(
6 model="reflector-rl",
7 messages=[
8 {"role": "system", "content": "You are a helpful and harmless assistant."},
9 {"role": "user", "content": "Explain how to answer an indirect harmful request responsibly."},
10 ],
11 temperature=0,
12 max_tokens=512,
13)
14
15print(response.choices[0].message.content)| Item | Description |
|---|---|
| Base family | Llama 3.1 8B instruction model |
| Training stage | Reinforcement learning |
| RL method | GDPO |
| Data schema | harmful pattern + general pattern |
| Objective | reinforce step-wise reflection, harmful-intent recognition, and safe final answers |
| Output format | standard HuggingFace causal LM checkpoint |
1export MODEL_PATH=krystal7/Reflector-Internalizing-Safety-Llama-3.1-8B-RL
2NUM_SAMPLES=50 bash scripts/evaluation/eval_general.sh1@article{ma2026reflector,
2 title={REFLECTOR: Internalizing Step-wise Reflection against Indirect Jailbreak},
3 author={Ma, Jiachen and Zhang, Jiawen and Li, Xiangtian and Zou, Bo and Lu, Chaochao and Yang, Chao},
4 journal={arXiv preprint arXiv:2605.20654},
5 year={2026}
6}