Instructions to use Phonsiri/gemma-2-2b-SFT-Reasoning-full-Model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Phonsiri/gemma-2-2b-SFT-Reasoning-full-Model with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Phonsiri/gemma-2-2b-SFT-Reasoning-full-Model") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Phonsiri/gemma-2-2b-SFT-Reasoning-full-Model") model = AutoModelForCausalLM.from_pretrained("Phonsiri/gemma-2-2b-SFT-Reasoning-full-Model") 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Phonsiri/gemma-2-2b-SFT-Reasoning-full-Model with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Phonsiri/gemma-2-2b-SFT-Reasoning-full-Model" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Phonsiri/gemma-2-2b-SFT-Reasoning-full-Model", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Phonsiri/gemma-2-2b-SFT-Reasoning-full-Model
- SGLang
How to use Phonsiri/gemma-2-2b-SFT-Reasoning-full-Model with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Phonsiri/gemma-2-2b-SFT-Reasoning-full-Model" \ --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": "Phonsiri/gemma-2-2b-SFT-Reasoning-full-Model", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
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 "Phonsiri/gemma-2-2b-SFT-Reasoning-full-Model" \ --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": "Phonsiri/gemma-2-2b-SFT-Reasoning-full-Model", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Phonsiri/gemma-2-2b-SFT-Reasoning-full-Model with Docker Model Runner:
docker model run hf.co/Phonsiri/gemma-2-2b-SFT-Reasoning-full-Model
Gemma-2-2B SFT Reasoning Model
A supervised fine-tuned version of google/gemma-2-2b, trained to produce structured chain-of-thought reasoning on mathematical and logical problems.
Model Lineage: This SFT model serves as the foundation for downstream training: Phonsiri/gemma-2-2b-GRPO-Reasoning-full
Model Highlights
This model was trained to explicitly separate its reasoning process from its final answer, using a structured output format. It learns the syntax and structure of chain-of-thought reasoning before any reinforcement signal is applied.
Output Format:
| Section | Tag | Description |
|---|---|---|
| Chain-of-Thought | <reasoning> ... </reasoning> |
Step-by-step internal reasoning |
| Final Answer | <answer> ... </answer> |
Concise final answer |
Training Details
Base Model
Fine-tuned from google/gemma-2-2b-it using full parameter fine-tuning (no LoRA/PEFT).
Datasets
Training data was combined from the following sources:
| Dataset | Type |
|---|---|
nohurry/Opus-4.6-Reasoning-3000x-filtered |
HuggingFace — Reasoning |
math_combined_2566_2567.json |
Local — Thai math problems |
problems_1_5.json |
Local — Math problems |
problems_6_10.json |
Local — Math problems |
problems_101_125.json |
Local — Math problems |
combined.json |
Local — Combined problems |
all_solutions.json |
Local — Solutions |
Hyperparameters
| Parameter | Value |
|---|---|
| Epochs | 3 |
| Learning Rate | 2e-5 |
| LR Scheduler | Cosine |
| Max Seq Length | 8192 |
| Batch Size (per device) | 4 |
| Gradient Accumulation | 4 |
| Effective Batch Size | 16 |
| Warmup Ratio | 0.1 |
| Weight Decay | 0.01 |
| Precision | bfloat16 |
| Gradient Checkpointing | Yes |
| Attention | SDPA |
| Optimizer | AdamW |
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
import torch
model_id = "Phonsiri/gemma-2-2b-SFT-Reasoning-full-Model"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map="auto",
torch_dtype=torch.bfloat16
)
system_prompt = (
"You are a helpful assistant. Please reason step by step, "
"and put your thoughts within <reasoning> and </reasoning> tags, "
"and your final answer within <answer> and </answer> tags."
)
prompt = "Solve for x: 3x + 5 = 20"
messages = [{"role": "user", "content": f"{system_prompt}\n\n{prompt}"}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=False)
with torch.no_grad():
model.generate(
**inputs,
streamer=streamer,
max_new_tokens=4096,
temperature=0.6,
top_p=0.9,
repetition_penalty=1.1,
)
Example Output
<reasoning>
We need to isolate x on one side of the equation.
Step 1: Subtract 5 from both sides.
3x + 5 - 5 = 20 - 5
3x = 15
Step 2: Divide both sides by 3.
x = 15 / 3
x = 5
</reasoning>
<answer>
x = 5
</answer>
Acknowledgements
Authors:
- Phonsiri Thabunsri — @Phonsiriwillbejommarn
- CYP777 — @CYP777
Project Advisor:
- Supaporn Bunrit, Ph.D. — Suranaree University of Technology
Institutions & Credits:
- Suranaree University of Technology (SUT) — Research support and computing resources
- Google DeepMind — Open-weights Gemma 2 model
- Downloads last month
- 3