Self-Training Elicits Concise Reasoning in Large Language Models
Paper • 2502.20122 • Published • 4
How to use tergel/deepseek-math-7b-instruct-math-fs-gpt4o-bon with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="tergel/deepseek-math-7b-instruct-math-fs-gpt4o-bon")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForMultimodalLM
tokenizer = AutoTokenizer.from_pretrained("tergel/deepseek-math-7b-instruct-math-fs-gpt4o-bon")
model = AutoModelForMultimodalLM.from_pretrained("tergel/deepseek-math-7b-instruct-math-fs-gpt4o-bon")
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 tergel/deepseek-math-7b-instruct-math-fs-gpt4o-bon with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "tergel/deepseek-math-7b-instruct-math-fs-gpt4o-bon"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "tergel/deepseek-math-7b-instruct-math-fs-gpt4o-bon",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/tergel/deepseek-math-7b-instruct-math-fs-gpt4o-bon
How to use tergel/deepseek-math-7b-instruct-math-fs-gpt4o-bon with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "tergel/deepseek-math-7b-instruct-math-fs-gpt4o-bon" \
--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": "tergel/deepseek-math-7b-instruct-math-fs-gpt4o-bon",
"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 "tergel/deepseek-math-7b-instruct-math-fs-gpt4o-bon" \
--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": "tergel/deepseek-math-7b-instruct-math-fs-gpt4o-bon",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use tergel/deepseek-math-7b-instruct-math-fs-gpt4o-bon with Docker Model Runner:
docker model run hf.co/tergel/deepseek-math-7b-instruct-math-fs-gpt4o-bon
This model is fine-tuned using self-training methods to generate concise reasoning paths for reasoning tasks while maintaining accuracy.
Use the code below to get started with the model.
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_name = "tergel/deepseek-math-7b-instruct-math-fs-gpt4o-bon"
device = "cuda" if torch.cuda.is_available() else "cpu"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, device_map=device, torch_dtype=torch.bfloat16)
question = "Convert the point $(0,3)$ in rectangular coordinates to polar coordinates. Enter your answer in the form $(r,\\theta),$ where $r > 0$ and $0 \\le \\theta < 2 \\pi.$"
inputs = tokenizer(question, return_tensors="pt").to(device)
input_length = len(inputs['input_ids'][0])
outputs = model.generate(**inputs, max_new_tokens=512)
response = tokenizer.decode(outputs[0][input_length:], skip_special_tokens=True)
print(response)
For more detailed information about training methods, evaluation results, limitations, and technical specifications, please refer to our paper.
@article{munkhbat2025self,
title={Self-Training Elicits Concise Reasoning in Large Language Models},
author={Munkhbat, Tergel and Ho, Namgyu and Kim, Seohyun and Yang, Yongjin and Kim, Yujin and Yun, Se-Young},
journal={arXiv preprint arXiv:2502.20122},
year={2025}
}
Base model
deepseek-ai/deepseek-math-7b-instruct