open-r1/Mixture-of-Thoughts
Viewer • Updated • 699k • 5.4k • 312
How to use alphadl/R1-Distill-0.6B-Qwen with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="alphadl/R1-Distill-0.6B-Qwen")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("alphadl/R1-Distill-0.6B-Qwen")
model = AutoModelForCausalLM.from_pretrained("alphadl/R1-Distill-0.6B-Qwen")
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 alphadl/R1-Distill-0.6B-Qwen with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "alphadl/R1-Distill-0.6B-Qwen"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "alphadl/R1-Distill-0.6B-Qwen",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/alphadl/R1-Distill-0.6B-Qwen
How to use alphadl/R1-Distill-0.6B-Qwen with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "alphadl/R1-Distill-0.6B-Qwen" \
--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": "alphadl/R1-Distill-0.6B-Qwen",
"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 "alphadl/R1-Distill-0.6B-Qwen" \
--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": "alphadl/R1-Distill-0.6B-Qwen",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use alphadl/R1-Distill-0.6B-Qwen with Docker Model Runner:
docker model run hf.co/alphadl/R1-Distill-0.6B-Qwen
This model is a fine-tuned version of Qwen/Qwen3-0.6B-Base on the open-r1/Mixture-of-Thoughts dataset. It has been trained using TRL.
from transformers import pipeline
question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
generator = pipeline("text-generation", model="alphadl/R1-Distill-0.6B", device="cuda")
output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
print(output["generated_text"])
This model was trained with SFT.
| Model | Qwen3-0.6B-Base | R1-Distill-0.6B (Ours) |
|---|---|---|
| Math-500 | 38.2 | 41.0(+2.8) |
| GPQA Diamond | 24.2 | 28.3(+4.1) |
export VLLM_WORKER_MULTIPROC_METHOD=spawn # Required for vLLM
export NUMEXPR_MAX_THREADS=128 # Utilize all 128 cores for numerical computations
MODEL=data/R1-Distill-0.6B
# Evaluate the base model
# MODEL=Qwen/Qwen3-0.6B-Base
MODEL_ARGS="model_name=$MODEL,dtype=bfloat16,max_model_length=32768,gpu_memory_utilization=0.8,generation_parameters={max_new_tokens:8192,temperature:0.6,top_p:0.95}"
OUTPUT_DIR=data/evals/$MODEL
# Math 500
TASK=math_500
lighteval vllm $MODEL_ARGS "lighteval|$TASK|0|0" \
--use-chat-template \
--output-dir $OUTPUT_DIR
# GPQA Diamond
TASK=gpqa:diamond
lighteval vllm $MODEL_ARGS "lighteval|$TASK|0|0" \
--use-chat-template \
--output-dir $OUTPUT_DIR