The
phi-instruct-segment-ppo model introduces a segment-level reward model to improve reinforcement learning with human feedback (RLHF) in language models. This work builds upon the methods in our paper
Segmenting Text and Learning Their Rewards for Improved RLHF in Language Model.
Below is an illustration of the segment-based reward modeling method, showing how entropy thresholds are used for segmentation, integrating both the reward model and PPO training:
Model checkpoints are available on
HuggingFace.
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3# Load model and tokenizer
4model_name = "yyqoni/Phi-3-mini-4k-segment-ppo-60k"
5model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True)
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7
8# Input text
9input_text = "What are the benefits of using reinforcement learning in AI?"
10
11# Apply chat template formatting with generation prompt
12formatted_input = tokenizer.apply_chat_template(
13 [{"role": "user", "content": input_text}],
14 tokenize=False,
15 add_generation_prompt=True
16)
17
18# Tokenize the formatted input
19inputs = tokenizer(formatted_input, return_tensors="pt", add_special_tokens=False)
20
21# Generate response
22outputs = model.generate(**inputs, max_new_tokens=50)
23
24# Decode and print the response
25print(tokenizer.decode(outputs[0], skip_special_tokens=True))
1@misc{yin2025segmentingtextlearningrewards,
2 title={Segmenting Text and Learning Their Rewards for Improved RLHF in Language Model},
3 author={Yueqin Yin and Shentao Yang and Yujia Xie and Ziyi Yang and Yuting Sun and Hany Awadalla and Weizhu Chen and Mingyuan Zhou},
4 year={2025},
5 eprint={2501.02790},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2501.02790},
9}