DataPilot/Zero_SFT_Ja_v3_Reasoning
Viewer • Updated • 32.7k • 49 • 1
How to use OsakanaTeishoku/sarashina2.2-3b-cot-sft-20250920 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="OsakanaTeishoku/sarashina2.2-3b-cot-sft-20250920")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("OsakanaTeishoku/sarashina2.2-3b-cot-sft-20250920")
model = AutoModelForCausalLM.from_pretrained("OsakanaTeishoku/sarashina2.2-3b-cot-sft-20250920", 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 OsakanaTeishoku/sarashina2.2-3b-cot-sft-20250920 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "OsakanaTeishoku/sarashina2.2-3b-cot-sft-20250920"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "OsakanaTeishoku/sarashina2.2-3b-cot-sft-20250920",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/OsakanaTeishoku/sarashina2.2-3b-cot-sft-20250920
How to use OsakanaTeishoku/sarashina2.2-3b-cot-sft-20250920 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "OsakanaTeishoku/sarashina2.2-3b-cot-sft-20250920" \
--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": "OsakanaTeishoku/sarashina2.2-3b-cot-sft-20250920",
"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 "OsakanaTeishoku/sarashina2.2-3b-cot-sft-20250920" \
--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": "OsakanaTeishoku/sarashina2.2-3b-cot-sft-20250920",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use OsakanaTeishoku/sarashina2.2-3b-cot-sft-20250920 with Docker Model Runner:
docker model run hf.co/OsakanaTeishoku/sarashina2.2-3b-cot-sft-20250920
これはsbintuitions/sarashina2.2-3b-instruct-v0.1をDataPilot/Zero_SFT_Ja_v3_ReasoningでSFTしたモデルです.
モデルは答えの前に,思考過程を <think> </think> の間に出力するよう調整されています.
コンテクスト長はオリジナルの8192から16384に拡張されています.
unslothで以下のように推論してください.素のtransformersで推論させると出力の質が低下する問題が発生しています(2025/9/20時点で解決法がわかっていません)
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "OsakanaTeishoku/sarashina2.2-3b-cot-sft-v0.1",
max_seq_length = 16384,
load_in_4bit = False,
# token = HF_TOKEN,
)
from transformers import TextStreamer
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
# modified from https://huggingface.co/unsloth/SmolLM3-3B/blob/main/chat_template.jinja
# do not change the system prompt!!!
SYSTEM_PROMPT = "You are a helpful AI assistant. Your role as an assistant involves thoroughly exploring questions through a systematic thinking process before providing the final precise and accurate solutions. This requires engaging in a comprehensive cycle of analysis, summarizing, exploration, reassessment, reflection, backtracking, and iteration to develop well-considered thinking process. Please structure your response into two main sections: Thought and Solution using the specified format: <think> Thought section </think> Solution section. In the Thought section, detail your reasoning process in steps. Each step should include detailed considerations such as analysing questions, summarizing relevant findings, brainstorming new ideas, verifying the accuracy of the current steps, refining any errors, and revisiting previous steps. In the Solution section, based on various attempts, explorations, and reflections from the Thought section, systematically present the final solution that you deem correct. The Solution section should be logical, accurate, and concise and detail necessary steps needed to reach the conclusion."
messages = [{"role": "system", "content": SYSTEM_PROMPT},{"role": "user", "content": "what is 13 + 24 ?"},{"role": "assistant", "content": "<think>"}]
input_text = tokenizer.apply_chat_template(messages, tokenize=False, continue_final_message=True)
input = tokenizer(input_text, return_tensors="pt").to(model.device)
FastLanguageModel.for_inference(model)
output = model.generate(**input, max_new_tokens=10000, use_cache=True, do_sample=True, temperature=0.6, top_p=0.95, streamer=streamer)
This llama model was trained 2x faster with Unsloth and Huggingface's TRL library.
Base model
sbintuitions/sarashina2.2-3b