RLFR
Collection
Extending Reinforcement Learning for LLMs with Flow Environment • 5 items • Updated • 3
How to use JingHaoZ/RLFR-Qwen2.5-Math-7B with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="JingHaoZ/RLFR-Qwen2.5-Math-7B")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("JingHaoZ/RLFR-Qwen2.5-Math-7B")
model = AutoModelForCausalLM.from_pretrained("JingHaoZ/RLFR-Qwen2.5-Math-7B")
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use JingHaoZ/RLFR-Qwen2.5-Math-7B with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "JingHaoZ/RLFR-Qwen2.5-Math-7B"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "JingHaoZ/RLFR-Qwen2.5-Math-7B",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/JingHaoZ/RLFR-Qwen2.5-Math-7B
How to use JingHaoZ/RLFR-Qwen2.5-Math-7B with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "JingHaoZ/RLFR-Qwen2.5-Math-7B" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "JingHaoZ/RLFR-Qwen2.5-Math-7B",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "JingHaoZ/RLFR-Qwen2.5-Math-7B" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "JingHaoZ/RLFR-Qwen2.5-Math-7B",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use JingHaoZ/RLFR-Qwen2.5-Math-7B with Docker Model Runner:
docker model run hf.co/JingHaoZ/RLFR-Qwen2.5-Math-7B
RLFR-Qwen2.5-Math-7B is trained from Qwen2.5-Math-7B with the RLFR framework, which introduces the flow reward derived from latent space, extending RLVR with latent reward utilization.
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "JingHaoZ/RLFR-Qwen2.5-Math-7B"
device = "cuda" # the device to load the model onto
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
prompt = "Find the value of $x$ that satisfies the equation $4x+5 = 6x+7$."
messages = [
{"role": "system", "content": "Please reason step by step, and put your final answer within \\boxed{}."},
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(device)
generated_ids = model.generate(
**model_inputs,
max_new_tokens=512
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
If you find our work helpful, feel free to give us a citation.
@article{zhang2025rlfr,
title={RLFR: Extending Reinforcement Learning for LLMs with Flow Environment},
author={Zhang, Jinghao and Zheng, Naishan and Li, Ruilin and Cheng, Dongzhou and Liang, Zheming and Zhao, Feng and Wang, Jiaqi},
journal={arXiv preprint arXiv:2510.10201},
year={2025}
}