ServiceNow-AI/R1-Distill-SFT
Viewer • Updated • 1.85M • 1.31k • 323
How to use suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit-v0 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit-v0")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit-v0")
model = AutoModelForCausalLM.from_pretrained("suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit-v0", 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=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit-v0 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit-v0"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit-v0",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit-v0
How to use suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit-v0 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit-v0" \
--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": "suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit-v0",
"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 "suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit-v0" \
--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": "suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit-v0",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit-v0 with Docker Model Runner:
docker model run hf.co/suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit-v0
This model is the distilled version of DeepSeek-R1 on Llama-3.2-3B with R1-Distill-SFT dataset. This model is 4bit quantized! You should import it f16 if you want to use full model.
Example usage:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit",
load_in_4bit = True,
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit")
SYSTEM_PROMPT = """Respond in the following format:
<reasoning>
You should reason between these tags.
</reasoning>
Answer goes here...
Always use <reasoning> </reasoning> tags even if they are not necessary.
"""
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": "Continue the fibonnaci sequence: 1, 1, 2, 3, 5, 8,"},
]
inputs = tokenizer.apply_chat_template(
messages,
tokenize = True,
add_generation_prompt = True,
return_tensors = "pt",
).to("cuda")
output = model.generate(input_ids=inputs, max_new_tokens=256, use_cache=True, temperature=0.7)
decoded_output = tokenizer.decode(output[0], skip_special_tokens=False)
print(decoded_output)
Output:
<reasoning>
To continue the Fibonacci sequence, we need to recall the pattern of adding the previous two numbers to get the next number.
</reasoning>
The next numbers in the sequence would be: 13, 21, 34, 55, 89, 144
Suggested system prompt:
Respond in the following format:
<reasoning>
You should reason between these tags.
</reasoning>
Answer goes here...
Always use <reasoning> </reasoning> tags even if they are not necessary.
Base model
meta-llama/Llama-3.2-3B-Instruct