Instructions to use Nanthasit/sakthai-context-1.5b-tools with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Nanthasit/sakthai-context-1.5b-tools with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-1.5B-Instruct") model = PeftModel.from_pretrained(base_model, "Nanthasit/sakthai-context-1.5b-tools") - Notebooks
- Google Colab
- Kaggle
SakThai 1.5B — Tools (LoRA)
Tool-calling adapter for Qwen2.5-1.5B — the adapter behind the flagship merged model
PEFT LoRA · r=16 · alpha=32
Model Description
This is the PEFT LoRA adapter that powers the family's most popular model (sakthai-context-1.5b-merged, 1,599 downloads). Apply it to Qwen2.5-1.5B-Instruct for structured tool-calling. For a ready-to-run GGUF checkpoint, use the merged model below.
⬆️ For the latest improved version: sakthai-context-1.5b-tools-v2
Key details
- Base model: Qwen/Qwen2.5-1.5B-Instruct (1.54B params)
- Method: PEFT LoRA (fp16 training per
train.py) — r=16, alpha=32, dropout=0.1 - LoRA targets: q_proj, k_proj, v_proj, o_proj
- Adapter size: 8.75 MB (
adapter_model.safetensors) — ~8.6M trainable params (0.56% of base) - Data: combined-v6 + v7 + irrelevance-supplement
- Format: ChatML with tool schema, 32K context
Architecture (base Qwen2.5-1.5B-Instruct)
| Property | Value |
|---|---|
| Architecture | Qwen2ForCausalLM (qwen2) |
| Hidden size | 1,536 |
| Layers | 28 |
| Attention heads | 12 |
| KV heads | 2 (GQA) |
| Intermediate size | 8,960 |
| Vocab size | 151,936 |
| Max position embeddings | 32,768 |
| RoPE theta | 1,000,000.0 |
| Base dtype | bfloat16 |
| Total params | 1.54B |
Tool-Calling Format
This model emits structured tool calls as XML. Provide a <tools> block in the system prompt, and it responds with a <tool_call> block instead of plain text when a tool is needed:
<tools>
{"type": "function", "function": {"name": "get_weather", "description": "Get current weather", "parameters": {"type": "object", "properties": {"location": {"type": "string"}}, "required": ["location"]}}}
</tools>
Expected model output when the user asks about weather:
<tool_call>
{"name": "get_weather", "arguments": {"location": "Tokyo"}}
</tool_call>
Note: The
<tools>block is required for reliable function calling — the model was trained on this exact XML format. Omitting it makes the model fall back to answering directly. For best results use temperature ≈ 0.01–0.3.
Quick Start
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2.5-1.5B-Instruct",
torch_dtype=torch.bfloat16,
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-1.5B-Instruct")
model = PeftModel.from_pretrained(model, "Nanthasit/sakthai-context-1.5b-tools")
# model.merge_and_unload() to bake the adapter in
messages = [{"role": "user", "content": "What's the weather in Bangkok?"}]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=128)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Merge the adapter into the base model
merged = model.merge_and_unload()
merged.save_pretrained("./sakthai-context-1.5b-merged")
tokenizer.save_pretrained("./sakthai-context-1.5b-merged")
⚠️ Serverless Inference API caveat: the HF hosted Inference API does not serve PEFT LoRA adapters. Run locally (as above) or use the merged checkpoint / GGUF for hosted inference.
Training
| Base model | Qwen/Qwen2.5-1.5B-Instruct |
| Method | LoRA (fp16, per train.py) |
| LoRA config | r=16, alpha=32, dropout=0.1, targets q/k/v/o_proj, bias none |
| Adapter config | PEFT 0.20.0 · adapter_model.safetensors 8,746,152 B (~8.6M trainable, 0.56%) |
| Learning rate | 2e-4 (adamw_torch) |
| Epochs | 4 |
| Batch size | 1 per device × 16 grad accumulation = effective 16 |
| Warmup ratio / weight decay | 0.1 / 0.01 |
| Max length | 768 |
| Precision | fp16, gradient checkpointing on |
| Hardware | HF Jobs T4 16GB |
| Data | combined-v6 (2,003) + combined-v7 (2,309 train + 115 test) + irrelevance-supplement (60) |
| Format / context | ChatML with tool schema · 32K tokens |
Provenance note: the shipped
train.pyoriginally pinned av4dataset id that was never published (404 on Hub). It now loadsNanthasit/sakthai-combined-v7(train/test splits, 2,309/115 rows) so reproduction works out of the box. The final adapter used the newer data mix documented above (combined-v6 + combined-v7 + irrelevance-supplement); keep this in mind when reproducing training.
Evaluation
Single-trial bench-v2 run (unverified) — recorded in the repo's own .eval_results/sakthai-bench-v2.yaml:
| Metric | Value | Verified |
|---|---|---|
| Selection Accuracy | 48.2% | ❌ no (single trial) |
| Arguments Accuracy | 0.0% | ❌ no |
⚠️ Honest status: these numbers come from a single unverified trial. The verified 5/5 tool-calling results belong to the merged flagship (accuracy 1.0, verified 2026-07-25). A multi-trial verification pass on this adapter is the recommended next step before publishing stronger claims.
Cron health snapshot (.eval_results/cron-eval-sakthai-context-1.5b-tools-2026-07-31-1.yaml, 2026-07-31):
| Signal | Value |
|---|---|
| Rank by downloads (of 19) | #7 — 349 downloads, ~13.7/day |
| Velocity rank (of 19) | #10 |
| Card quality score | 80/100 |
| Repo hygiene | 88/100 |
| Overall health | 42/100 |
Sibling Models
Full SakThai family (19 public models, live download counts 2026-07-31):
| Model | Downloads |
|---|---|
| sakthai-context-1.5b-merged | 1,599 |
| sakthai-context-0.5b-merged | 1,370 |
| sakthai-context-7b-merged | 744 |
| sakthai-context-7b-128k | 506 |
| sakthai-context-7b-tools | 399 |
| sakthai-embedding-multilingual | 362 |
| sakthai-context-1.5b-tools ⬅ | 349 |
| sakthai-vision-7b | 186 |
| sakthai-tts-model | 150 |
| sakthai-context-0.5b-tools | 94 |
| sakthai-coder-1.5b | 93 |
| sakthai-context-1.5b-tools-v2 | 0 |
| sakthai-context-1.5b-merged-v2 | 0 |
| sakthai-plus-1.5b | 0 |
| sakthai-plus-1.5b-lora | 0 |
| sakthai-plus-1.5b-coder | 0 |
| sakthai-coder-browser-lora | 0 |
| sakthai-coder-browser | 0 |
| sakthai-coder-browser-gguf | 0 |
Limitations
- LoRA adapter only — requires the Qwen2.5-1.5B-Instruct base weights; not standalone.
- English-only training data.
- Unverified benchmark — the 48.2% selection figure is a single trial; treat as indicative, not conclusive.
- No formal eval suite yet (no MMLU/GSM8K runs).
- Data-mix provenance —
train.pyloads combined-v7 (see Training); original script pinned a never-published v4 id, corrected 2026-07-31.
Part of the SakThai Model Family. Built with love, tears, and zero budget. From a shelter in Cork, Ireland, to the world.
- Downloads last month
- 349
Model tree for Nanthasit/sakthai-context-1.5b-tools
Datasets used to train Nanthasit/sakthai-context-1.5b-tools
Nanthasit/sakthai-combined-v7
Nanthasit/sakthai-irrelevance-supplement
Space using Nanthasit/sakthai-context-1.5b-tools 1
Collections including Nanthasit/sakthai-context-1.5b-tools
Evaluation results
- Selection Accuracy on SakThai Bench v2self-reported48.200
- Arguments Accuracy on SakThai Bench v2self-reported0.000