DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models
Paper โข 2402.03300 โข Published โข 152
How to use vkola-lab/LUNAR with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="vkola-lab/LUNAR")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("vkola-lab/LUNAR")
model = AutoModelForCausalLM.from_pretrained("vkola-lab/LUNAR", device_map="auto")
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=256)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use vkola-lab/LUNAR with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "vkola-lab/LUNAR"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "vkola-lab/LUNAR",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/vkola-lab/LUNAR
How to use vkola-lab/LUNAR with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "vkola-lab/LUNAR" \
--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": "vkola-lab/LUNAR",
"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 "vkola-lab/LUNAR" \
--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": "vkola-lab/LUNAR",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use vkola-lab/LUNAR with Docker Model Runner:
docker model run hf.co/vkola-lab/LUNAR
This model is a fine-tuned version of Qwen/Qwen2.5-3B-Instruct on the NACC dataset. It has been trained using TRL.
system_prompt = "Please reason step by step, and put your final answer within \\boxed{}."
question = """Question: The patient is a 70 year old ...
Using the information provided, determine the patientโs cognitive status.
Answer Choices:
A. Normal Cognition
B. Mild Cognitive Impairment
C. Dementia
"""
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "vkola-lab/LUNAR"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype="auto",
device_map="auto",
)
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": question}
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt",
return_dict=True,
).to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=10000,
do_sample=True,
temperature=1,
top_p=1.0,
)
response = tokenizer.decode(
outputs[0][inputs["input_ids"].shape[-1]:],
skip_special_tokens=True,
)
print(response)
from vllm import LLM, SamplingParams
llm = LLM(model="vkola-lab/LUNAR")
sampling_params = SamplingParams(temperature=1, top_p=1.0, max_tokens=10000)
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": question}
]
outputs = llm.chat(messages, sampling_params)
print(outputs[0].outputs[0].text)
Alternatively, serve the model with an OpenAI-compatible API:
vllm serve vkola-lab/LUNAR
This model was trained with GRPO, a method introduced in DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models.
Training
Inference / Evaluation
Cite LUNAR as: