Text Generation
Transformers
Safetensors
English
qwen2
agent
conversational
ollama
small-language-model
slm
tool-use
qwen
qwen2.5
sakthai
house-of-sak
tool-calling
function-calling
merged
edge
lightweight
low-resource
raspberry-pi
on-device
benchmark
eval
Eval Results (legacy)
Eval Results
text-generation-inference
Instructions to use Nanthasit/sakthai-context-0.5b-tools with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Nanthasit/sakthai-context-0.5b-tools with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Nanthasit/sakthai-context-0.5b-tools") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Nanthasit/sakthai-context-0.5b-tools") model = AutoModelForCausalLM.from_pretrained("Nanthasit/sakthai-context-0.5b-tools", 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Nanthasit/sakthai-context-0.5b-tools with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Nanthasit/sakthai-context-0.5b-tools" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Nanthasit/sakthai-context-0.5b-tools", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Nanthasit/sakthai-context-0.5b-tools
- SGLang
How to use Nanthasit/sakthai-context-0.5b-tools 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 "Nanthasit/sakthai-context-0.5b-tools" \ --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": "Nanthasit/sakthai-context-0.5b-tools", "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 "Nanthasit/sakthai-context-0.5b-tools" \ --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": "Nanthasit/sakthai-context-0.5b-tools", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Nanthasit/sakthai-context-0.5b-tools with Docker Model Runner:
docker model run hf.co/Nanthasit/sakthai-context-0.5b-tools
2026-08-01: Added Quick Example section with 30-second working tool-calling snippet
Browse files
README.md
CHANGED
|
@@ -71,382 +71,62 @@ model-index:
|
|
| 71 |
|
| 72 |
<h1 align="center">SakThai Context 0.5B — Tools</h1>
|
| 73 |
<p align="center"><em>Ultra-light tool-calling agent · Qwen2.5-0.5B fine-tune · runs in ~1 GB RAM</em></p>
|
| 74 |
-
<p align="center">
|
| 75 |
-
<img src="https://img.shields.io/badge/dynamic/json?url=https%3A//huggingface.co/api/models/Nanthasit/sakthai-context-0.5b-tools&query=%24.downloads&label=downloads&color=blue&cacheSeconds=3600" alt="Downloads"/>
|
| 76 |
-
<a href="https://huggingface.co/collections/Nanthasit/sakthai-model-family-6a64745450b12d421c1f9f02">
|
| 77 |
-
<img src="https://img.shields.io/badge/🏠-SakThai%20Model%20Family-8A2BE2" alt="Collection"/>
|
| 78 |
-
</a>
|
| 79 |
-
<a href="https://huggingface.co/spaces/Nanthasit/sakthai-tts"><img src="https://img.shields.io/badge/🔊-TTS%20Demo-teal" alt="TTS Demo"/></a>
|
| 80 |
-
<a href="https://huggingface.co/spaces/Nanthasit/sakthai-leaderboard"><img src="https://img.shields.io/badge/📊-Leaderboard-ff6b6b" alt="Leaderboard"/></a>
|
| 81 |
-
<img src="https://img.shields.io/badge/selection-91.2%25-success" alt="Selection 91.2%"/>
|
| 82 |
-
<img src="https://img.shields.io/badge/args-45.7%25-yellow" alt="Arguments 45.7%"/>
|
| 83 |
-
<img src="https://img.shields.io/badge/held--out-87.8%25-orange" alt="Held-out 87.8%"/>
|
| 84 |
-
<img src="https://img.shields.io/badge/context-32K-blue" alt="32K Context"/>
|
| 85 |
-
<img src="https://img.shields.io/badge/params-494M-lightgrey" alt="494M Parameters"/>
|
| 86 |
-
<img src="https://img.shields.io/badge/bench-v2-500%20rows-blue" alt="500 rows"/>
|
| 87 |
-
</p>
|
| 88 |
|
| 89 |
-
> **
|
| 90 |
-
> — a family of AI agents, models, datasets, and tools built from a shelter in Cork, Ireland, with **$0 budget**, no GPU, and a relentless drive to build something meaningful.
|
| 91 |
-
>
|
| 92 |
-
> The 0.5B-tools is the **smallest tool-calling member** — 494M params, 91.2% selection accuracy, runs on a Raspberry Pi. It proves that tiny models can punch far above their weight when trained with precision.
|
| 93 |
-
>
|
| 94 |
-
> *"We are one family — and becoming more."* — **Beer (beer-sakthai)**
|
| 95 |
-
>
|
| 96 |
-
> [Read the full story →](https://github.com/beer-sakthai/Sak-Family-Agent/blob/main/HOUSE_OF_SAK.md)
|
| 97 |
|
| 98 |
**SakThai Context 0.5B Tools** is the v4 release of the tool-calling agent — fine-tuned from Qwen2.5-0.5B-Instruct with prompt-masked SFT. It achieves **91.2% selection accuracy** (multiset-corrected scorer) on the SakThai Bench v2, a 2.3× improvement over the 40.2% baseline.
|
| 99 |
|
| 100 |
-
##
|
| 101 |
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
| Attribute | Value |
|
| 105 |
-
|-----------|-------|
|
| 106 |
-
| Base model | Qwen/Qwen2.5-0.5B-Instruct |
|
| 107 |
-
| Parameters | 494M |
|
| 108 |
-
| Model size | ~988 MB bfloat16 (Q4: ~295 MB) |
|
| 109 |
-
| Context length | 32,768 tokens (32K) |
|
| 110 |
-
| Method | SFT with prompt-masked loss (completion-only) |
|
| 111 |
-
| Precision | bfloat16 |
|
| 112 |
-
| Output format | `<tool_call>{"name": ..., "arguments": {...}}</tool_call>` XML |
|
| 113 |
-
| License | Apache 2.0 |
|
| 114 |
-
|
| 115 |
-
It calls tools with **91.2% selection accuracy** (multiset-corrected scorer) on [SakThai Bench v2](https://huggingface.co/datasets/Nanthasit/sakthai-bench-v2) (500 rows, 4 categories, multi-turn + held-out tools) -- a **2.3x improvement** over the 40.2% baseline -- while running in roughly **1 GB of RAM**, on a Raspberry Pi, or any edge device. The biggest gain came from per-assistant-turn prompt/completion pairs with `completion_only_loss=True`, which stopped the model from spending its gradient reproducing tool schemas instead of learning when to call tools.
|
| 116 |
-
|
| 117 |
-
## Benchmark Results
|
| 118 |
-
|
| 119 |
-
All scores on [SakThai Bench v2](https://huggingface.co/datasets/Nanthasit/sakthai-bench-v2) (500 rows, 4 categories, multi-turn + held-out tools).
|
| 120 |
-
|
| 121 |
-
> **Scoring note (2026-07-30):** headline scores were originally produced with the set-subset scorer. The corrected multiset scorer ([results/HISTORY.md](https://huggingface.co/datasets/Nanthasit/sakthai-bench-v2/blob/main/results/HISTORY.md), `20260730T000503Z-rescored.json`) re-scores selection for this lineage to **91.2%** (456/500 — 3 rows flipped). Arguments / strict / held-out were not re-scored (null by design) and remain pre-fix values.
|
| 122 |
-
|
| 123 |
-
### Selection Accuracy (did it call the right tool?)
|
| 124 |
-
|
| 125 |
-
| Category | Score | Details |
|
| 126 |
-
|----------|:-----:|---------|
|
| 127 |
-
| **Simple** (1 correct tool) | **92.7%** | 139/150 — calls the right single tool |
|
| 128 |
-
| **Parallel** (multiple correct tools) | **84.7%** | 127/150 — calls all required tools |
|
| 129 |
-
| **Irrelevance (tools offered)** | **93.3%** | 140/150 — correctly stays silent when tools exist but are irrelevant |
|
| 130 |
-
| **Irrelevance (no tools)** | **100.0%** | 50/50 — correctly stays silent when no tools are offered |
|
| 131 |
-
| **OVERALL** | **91.2%** | 456/500 |
|
| 132 |
-
|
| 133 |
-
### Arguments Accuracy (of rows that passed selection)
|
| 134 |
-
|
| 135 |
-
| Category | Score | Details |
|
| 136 |
-
|----------|:-----:|---------|
|
| 137 |
-
| **Simple** | **38.7%** | 58/150 — exact argument match |
|
| 138 |
-
| **Parallel** | **52.7%** | 79/150 — exact argument match |
|
| 139 |
-
| **OVERALL** | **45.7%** | 137/300 |
|
| 140 |
-
| **Partial Credit** | **58.1%** | Fraction of argument keys correct |
|
| 141 |
-
|
| 142 |
-
### Held-Out Tools (tools never seen in training)
|
| 143 |
-
|
| 144 |
-
| Metric | Score |
|
| 145 |
-
|--------|:-----:|
|
| 146 |
-
| Accuracy | **87.8%** | 36/41 |
|
| 147 |
-
| Tools | `web_search`, `get_news_headlines` |
|
| 148 |
-
|
| 149 |
-
### Multi-Turn vs Single-Turn
|
| 150 |
-
|
| 151 |
-
| Slice | Score | Size |
|
| 152 |
-
|-------|:-----:|:----:|
|
| 153 |
-
| Multi-turn conversations | **93.9%** | n=164 |
|
| 154 |
-
| Single-turn prompts | **90.8%** | n=336 |
|
| 155 |
-
| v1 subset (carried over) | **92.8%** | n=235 |
|
| 156 |
-
|
| 157 |
-
### Quality Metrics
|
| 158 |
-
|
| 159 |
-
| Metric | Value |
|
| 160 |
-
|--------|:-----:|
|
| 161 |
-
| **Degenerate outputs** | **0/500** — no NaN/repeated-char failures |
|
| 162 |
-
| **Inference time** | ~95s on l4x1 (batch 16) |
|
| 163 |
-
| **Model size** | 494M params (bfloat16: ~988 MB, Q4: ~295 MB) |
|
| 164 |
-
|
| 165 |
-
## Improvement Over Baseline
|
| 166 |
-
|
| 167 |
-
| Metric | Baseline (v1) | **v4 (this model)** | Improvement |
|
| 168 |
-
|--------|:------------:|:-------------------:|:----------:|
|
| 169 |
-
| Selection | 40.2% | **91.2%** | **+51.0pp (2.3×)** |
|
| 170 |
-
| Arguments | 0.0% | **45.7%** | **+45.7pp** |
|
| 171 |
-
| Held-out tools | 0.0% | **87.8%** | **+87.8pp** |
|
| 172 |
-
| Multi-turn | 67.7% | **93.9%** | **+26.2pp** |
|
| 173 |
-
| Degenerate | 0 | **0** | same |
|
| 174 |
-
|
| 175 |
-
The key improvement came from **prompt-masked training** (completion-only loss) — without it, the model spent most of its gradient reproducing the tool schema rather than learning when to call tools. Switching to per-assistant-turn prompt/completion pairs with `completion_only_loss=True` solved the tool-calling collapse.
|
| 176 |
-
|
| 177 |
-
## How Evaluation Works
|
| 178 |
-
|
| 179 |
-
Results are produced by the [eval_bench.py](https://huggingface.co/datasets/Nanthasit/sakthai-bench-v2/raw/main/eval_bench.py) script, which:
|
| 180 |
-
1. Loads each model on a single GPU (l4x1 for 0.5B/1.5B, l40sx1 for 7B)
|
| 181 |
-
2. Generates greedily (batch size 16, max 200 new tokens)
|
| 182 |
-
3. Parses `<tool_call>` XML from the output
|
| 183 |
-
4. Scores selection (right tool?), arguments (right values?), and strict (both)
|
| 184 |
-
5. Computes held-out accuracy (tools absent from training)
|
| 185 |
-
6. Tracks degenerate output (repeated-character NaN detection)
|
| 186 |
-
7. Computes partial argument credit per-key
|
| 187 |
-
|
| 188 |
-
All results are uploaded to [SakThai Bench v2 results](https://huggingface.co/datasets/Nanthasit/sakthai-bench-v2/tree/main/results) and are independently reproducible.
|
| 189 |
-
|
| 190 |
-
## Inference Check (single-trial, in-repo)
|
| 191 |
-
|
| 192 |
-
A real inference probe was committed to this repo on 2026-07-31 (`.eval_results/benchmark-20260731_015807.yaml`): Transformers on CPU, bfloat16, `tool_calling_weather` prompt (691 chars, 181 input tokens).
|
| 193 |
-
|
| 194 |
-
| Check | Result |
|
| 195 |
-
|-------|--------|
|
| 196 |
-
| Tool call produced | ✅ `get_weather` with `{"location": "Tokyo"}` |
|
| 197 |
-
| Correct answer | ✅ Yes |
|
| 198 |
-
| Output tokens | 21 (16.81 s total, 2.54 s generation) |
|
| 199 |
-
| Valid JSON | ⚠️ No — output missing the closing `}` of the JSON object |
|
| 200 |
-
|
| 201 |
-
Single trial only — treat it as a behaviour smoke-test, not a score. It corroborates tool-calling behaviour but shows the model can emit JSON without its closing brace; a multi-trial verified pass is still needed before promoting the bench-v2 headline to "verified".
|
| 202 |
-
|
| 203 |
-
### Repo artifacts
|
| 204 |
-
|
| 205 |
-
This repo also ships:
|
| 206 |
-
- `chat_template.jinja` — the chat template used for tool-calling conversations
|
| 207 |
-
- `.eval_results/` — multiple evaluation YAML snapshots from benchmark, health, and inference-check runs
|
| 208 |
-
|
| 209 |
-
## Comparison with Other Models
|
| 210 |
-
|
| 211 |
-
*Sibling scores on SakThai Bench v2 (multiset-corrected scorer, rescored 2026-07-30 — see [results/HISTORY.md](https://huggingface.co/datasets/Nanthasit/sakthai-bench-v2/blob/main/results/HISTORY.md)):*
|
| 212 |
-
|
| 213 |
-
Our 494M model punches well above its weight class. For context:
|
| 214 |
-
- **Qwen2.5-0.5B-Instruct** (base, untuned): ~5% selection on simple tool calling
|
| 215 |
-
- **functiongemma-270m-it** (270M, comparable size): being evaluated
|
| 216 |
-
- **Llama 3.2-1B** (1B, 2× our size): being evaluated
|
| 217 |
-
- **Our 1.5B variant** ([context-1.5b-merged](https://huggingface.co/Nanthasit/sakthai-context-1.5b-merged)): **48.2% selection** (pre-fix 56.6%)
|
| 218 |
-
- **Our 7B variant** ([context-7b-merged](https://huggingface.co/Nanthasit/sakthai-context-7b-merged)): **57.0% selection** (pre-fix 64.0%)
|
| 219 |
-
|
| 220 |
-
## Usage
|
| 221 |
-
|
| 222 |
-
### Quick Start
|
| 223 |
-
|
| 224 |
-
Pick one path that matches your setup. If you're unsure, start with the CPU-only GGUF path.
|
| 225 |
-
|
| 226 |
-
### Transformers
|
| 227 |
|
| 228 |
```python
|
|
|
|
| 229 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 230 |
|
| 231 |
model_id = "Nanthasit/sakthai-context-0.5b-tools"
|
| 232 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 233 |
-
model = AutoModelForCausalLM.from_pretrained(model_id,
|
| 234 |
-
|
| 235 |
-
#
|
| 236 |
-
|
| 237 |
-
{
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
"properties": {"location": {"type": "string"}, "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}},
|
| 248 |
-
"required": ["location"]
|
| 249 |
}
|
| 250 |
}
|
| 251 |
-
|
| 252 |
-
text = tokenizer.apply_chat_template(messages, tools=tools, tokenize=False, add_generation_prompt=True)
|
| 253 |
-
inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
| 254 |
-
outputs = model.generate(**inputs, max_new_tokens=256)
|
| 255 |
-
print(tokenizer.decode(outputs[0][len(inputs["input_ids"][0]):], skip_special_tokens=True))
|
| 256 |
-
```
|
| 257 |
-
|
| 258 |
-
### `huggingface_hub` download + Transformers
|
| 259 |
-
|
| 260 |
-
```python
|
| 261 |
-
from huggingface_hub import hf_hub_download
|
| 262 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 263 |
-
|
| 264 |
-
model_id = "Nanthasit/sakthai-context-0.5b-tools"
|
| 265 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 266 |
-
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="auto", device_map="auto")
|
| 267 |
|
|
|
|
| 268 |
messages = [
|
| 269 |
-
{"role": "system", "content": "You are a helpful assistant
|
| 270 |
-
{"role": "user", "content": "What's the weather in
|
| 271 |
]
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
"function": {
|
| 275 |
-
"name": "get_weather",
|
| 276 |
-
"description": "Get current weather",
|
| 277 |
-
"parameters": {
|
| 278 |
-
"type": "object",
|
| 279 |
-
"properties": {
|
| 280 |
-
"location": {"type": "string"},
|
| 281 |
-
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
|
| 282 |
-
},
|
| 283 |
-
"required": ["location"]
|
| 284 |
-
}
|
| 285 |
-
}
|
| 286 |
-
}]
|
| 287 |
text = tokenizer.apply_chat_template(messages, tools=tools, tokenize=False, add_generation_prompt=True)
|
| 288 |
inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
| 289 |
-
outputs = model.generate(**inputs, max_new_tokens=
|
| 290 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
```
|
| 292 |
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
```bash
|
| 296 |
-
ollama pull sakthai:latest
|
| 297 |
-
```
|
| 298 |
-
|
| 299 |
-
### llama.cpp / GGUF (CPU-friendly)
|
| 300 |
-
|
| 301 |
-
For CPU-only or edge environments, use the [merged GGUF variant](https://huggingface.co/Nanthasit/sakthai-context-0.5b-merged):
|
| 302 |
-
|
| 303 |
-
```bash
|
| 304 |
-
# Download the Q4_K_M GGUF
|
| 305 |
-
wget https://huggingface.co/Nanthasit/sakthai-context-0.5b-merged/resolve/main/sakthai-0.5b-Q4_K_M.gguf
|
| 306 |
-
|
| 307 |
-
# Run with llama.cpp
|
| 308 |
-
./llama-cli -m sakthai-0.5b-Q4_K_M.gguf \
|
| 309 |
-
--temp 0.01 \
|
| 310 |
-
--ctx-size 32768 \
|
| 311 |
-
-p "What's the weather in Tokyo?"
|
| 312 |
-
```
|
| 313 |
-
|
| 314 |
-
### Hardware & Resource Notes
|
| 315 |
-
|
| 316 |
-
| Environment | Recommended Path | RAM |
|
| 317 |
-
|-------------|------------------|-----|
|
| 318 |
-
| CPU-only / Raspberry Pi | GGUF Q4_K_M | ~500 MB |
|
| 319 |
-
| Colab / CPU notebook | `torch_dtype="auto"` on CPU | ~1.2 GB |
|
| 320 |
-
| T4 / consumer GPU | Transformers bfloat16 | ~0.7 GB VRAM |
|
| 321 |
-
|
| 322 |
-
### Tool-Calling Format
|
| 323 |
-
|
| 324 |
-
| Component | Behavior |
|
| 325 |
-
|-----------|----------|
|
| 326 |
-
| Tool call delimiter | `<tool_call>` XML wrapper |
|
| 327 |
-
| Expected JSON body | `{"name": "<tool>", "arguments": {...}}` |
|
| 328 |
-
| No-tool response | Plain text if no relevant tool matches |
|
| 329 |
-
| Safety check | Validate tool name + required args before execution |
|
| 330 |
-
|
| 331 |
-
### Output Verification
|
| 332 |
|
| 333 |
-
|
| 334 |
-
|-----------|-----------------|
|
| 335 |
-
| Relevant tool offered | JSON tool call with matching name |
|
| 336 |
-
| Irrelevant query | Plain text answer, no `<tool_call>` wrapper |
|
| 337 |
-
| Multiple tools required | One `<tool_call>` block per tool call |
|
| 338 |
-
|
| 339 |
-
> **Validation tip:** always parse the outer `<tool_call>` XML before extracting JSON. Invalid JSON should be treated as a malformed call, not a tool name.
|
| 340 |
-
|
| 341 |
-
## Training Details
|
| 342 |
-
|
| 343 |
-
| Detail | Value |
|
| 344 |
-
|--------|-------|
|
| 345 |
-
| **Method** | SFT with prompt-masked loss (completion-only) |
|
| 346 |
-
| **Base Model** | [Qwen2.5-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct) |
|
| 347 |
-
| **Training Data** | [sakthai-combined-v7](https://huggingface.co/datasets/Nanthasit/sakthai-combined-v7) (2,050 rows after bench exclusion) |
|
| 348 |
-
| **LoRA config** | r=16, alpha=32, dropout=0.05, all linear modules |
|
| 349 |
-
| **Learning Rate** | 4e-4 (cosine, 10% warmup) |
|
| 350 |
-
| **Epochs** | 3 |
|
| 351 |
-
| **Batch** | 2 × 8 grad accum (effective 16) |
|
| 352 |
-
| **Precision** | bfloat16 |
|
| 353 |
-
| **Context** | 32K tokens |
|
| 354 |
-
| **NanGuard** | Active — skipped 2 poisoned micro-batches during training |
|
| 355 |
-
| **Dedup** | 3× cap on identical (prompt, completion) pairs |
|
| 356 |
-
| **Hardware** | t4-small (HF Jobs), ~2h |
|
| 357 |
-
|
| 358 |
-
## SakThai model family 🏠
|
| 359 |
-
|
| 360 |
-
| Model | Size | Downloads | Role |
|
| 361 |
-
|------|:----:|:---------:|------|
|
| 362 |
-
| [context-1.5b-merged](https://huggingface.co/Nanthasit/sakthai-context-1.5b-merged) | 3.09 GB | 1,599 | 🏆 Flagship (merged) |
|
| 363 |
-
| [context-0.5b-merged](https://huggingface.co/Nanthasit/sakthai-context-0.5b-merged) | 988 MB | 1,370 | 🌿 Lightweight / edge (merged) |
|
| 364 |
-
| [context-7b-merged](https://huggingface.co/Nanthasit/sakthai-context-7b-merged) | 15.2 GB | 744 | ⚡ Full-power reasoning |
|
| 365 |
-
| [context-7b-128k](https://huggingface.co/Nanthasit/sakthai-context-7b-128k) | config-only | 506 | 📏 128K long-context recipe |
|
| 366 |
-
| [context-7b-tools](https://huggingface.co/Nanthasit/sakthai-context-7b-tools) | 20.2 MB | 399 | 🛠️ 7B tool-calling adapter |
|
| 367 |
-
| [embedding-multilingual](https://huggingface.co/Nanthasit/sakthai-embedding-multilingual) | 471 MB | 362 | 🌐 Cross-lingual embeddings |
|
| 368 |
-
| [context-1.5b-tools](https://huggingface.co/Nanthasit/sakthai-context-1.5b-tools) | ~8.75 MB | 349 | 🛠️ 1.5B tool-calling adapter |
|
| 369 |
-
| [vision-7b](https://huggingface.co/Nanthasit/sakthai-vision-7b) | 4.08 GB | 186 | 👁️ Image→text (LLaVA, GGUF) |
|
| 370 |
-
| [tts-model](https://huggingface.co/Nanthasit/sakthai-tts-model) | 141 MB | 150 | 🔊 Text-to-speech, 15 langs |
|
| 371 |
-
| [context-0.5b-tools](https://huggingface.co/Nanthasit/sakthai-context-0.5b-tools) | 988 MB | 94 | 🛠️ 🌱 Edge tool-calling — **this model** |
|
| 372 |
-
| [coder-1.5b](https://huggingface.co/Nanthasit/sakthai-coder-1.5b) | 1.12 GB | 93 | 💻 Code generation (GGUF) |
|
| 373 |
-
| [context-1.5b-tools-v2](https://huggingface.co/Nanthasit/sakthai-context-1.5b-tools-v2) | 73.9 MB | 0 🌱 | 🛠️ v2 LoRA adapter — improved tool-following |
|
| 374 |
-
| [context-1.5b-merged-v2](https://huggingface.co/Nanthasit/sakthai-context-1.5b-merged-v2) | 3.09 GB | 0 🌱 | 🏷️ v2 merged — updated flagship fine-tune |
|
| 375 |
-
| [plus-1.5b](https://huggingface.co/Nanthasit/sakthai-plus-1.5b) | 3.09 GB | 0 🌱 | ➕ General-purpose assistant |
|
| 376 |
-
| [plus-1.5b-lora](https://huggingface.co/Nanthasit/sakthai-plus-1.5b-lora) | 73.9 MB | 0 🌱 | ➕ LoRA adapter for assistant |
|
| 377 |
-
| [plus-1.5b-coder](https://huggingface.co/Nanthasit/sakthai-plus-1.5b-coder) | — | 0 🌱 | 💻 Plus variant — planned, no weights yet |
|
| 378 |
-
| [coder-browser](https://huggingface.co/Nanthasit/sakthai-coder-browser) | 3.09 GB | 0 🌱 | 🕸️ Browser-use fine-tune (merged) |
|
| 379 |
-
| [coder-browser-lora](https://huggingface.co/Nanthasit/sakthai-coder-browser-lora) | 73.9 MB | 0 🌱 | 🕸️ Browser LoRA adapter |
|
| 380 |
-
| [coder-browser-gguf](https://huggingface.co/Nanthasit/sakthai-coder-browser-gguf) | 7.11 GB | 0 🌱 | 🕸️ Browser GGUF F16 |
|
| 381 |
-
|
| 382 |
-
**22 public models in the family · 15 datasets · 4 Spaces** — [full collection →](https://huggingface.co/collections/Nanthasit/sakthai-model-family-6a64745450b12d421c1f9f02)
|
| 383 |
|
| 384 |
---
|
| 385 |
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
These sibling assets have traction building but less visibility. A download or like on any of them helps the whole family grow:
|
| 389 |
-
|
| 390 |
-
| Asset | Type | Downloads | Why It Matters |
|
| 391 |
-
|-------|:----:|:---------:|:--------------|
|
| 392 |
-
| [sakthai-combined-v7](https://huggingface.co/datasets/Nanthasit/sakthai-combined-v7) | Dataset | 101 | Main training dataset — 2,309 examples, 86 tool schemas |
|
| 393 |
-
| [sakthai-coder-1.5b](https://huggingface.co/Nanthasit/sakthai-coder-1.5b) | Model | 93 | Code generation — Qwen2.5-Coder fine-tune, 1.12 GB GGUF |
|
| 394 |
-
| [sakthai-bench-v2](https://huggingface.co/datasets/Nanthasit/sakthai-bench-v2) | Dataset | 92 | Multi-domain eval — 500 rows, 4 categories |
|
| 395 |
-
| [food-penguin-v1](https://huggingface.co/datasets/Nanthasit/food-penguin-v1) | Dataset | 89 | Restaurant tool-calling — themed dataset gaining traction |
|
| 396 |
-
| [sakthai-irrelevance-supplement](https://huggingface.co/datasets/Nanthasit/sakthai-irrelevance-supplement) | Dataset | 78 | Teaches models when NOT to call tools — critical safety data |
|
| 397 |
-
| [sakthai-plus-1.5b](https://huggingface.co/Nanthasit/sakthai-plus-1.5b) | Model | 0 🌱 | General-purpose assistant — latest fine-tune |
|
| 398 |
-
| [sakthai-context-1.5b-tools-v2](https://huggingface.co/Nanthasit/sakthai-context-1.5b-tools-v2) | Model | 0 🌱 | v2 full SFT — no adapter, improved tool-following |
|
| 399 |
-
|
| 400 |
-
> 🚨 The **irrelevance-supplement** is safety-critical — it teaches models when NOT to call tools, and it took until 78 downloads to get noticed. Every download validates this approach!
|
| 401 |
-
|
| 402 |
-
### Try the Ecosystem
|
| 403 |
-
|
| 404 |
-
| Space | What It Does |
|
| 405 |
-
|-------|-------------|
|
| 406 |
-
| [Web Agent](https://huggingface.co/spaces/Nanthasit/sakthai-web-agent) | Browser automation and tool-use agent |
|
| 407 |
-
| [🔊 TTS Showcase](https://huggingface.co/spaces/Nanthasit/sakthai-tts) | Text-to-speech in 15 languages |
|
| 408 |
-
| [📊 Leaderboard](https://huggingface.co/spaces/Nanthasit/sakthai-leaderboard) | Benchmark tracker for all models |
|
| 409 |
-
|
| 410 |
-
## Limitations
|
| 411 |
-
|
| 412 |
-
- **Small model, small ceiling.** With 494M parameters, complex multi-step reasoning, long code generation, and nuanced instruction-following are limited. This is a *tool-calling* specialist, not a general reasoning engine.
|
| 413 |
-
- **Exact argument accuracy is still weak** (45.7% overall; 38.7% simple / 52.7% parallel). The model usually selects the right tool but often emits imperfect argument values -- validate arguments before acting on them in production.
|
| 414 |
-
- **Single-trial internal benchmarks.** All scores come from an internal eval run (greedy, batch 16, max 200 new tokens) on SakThai Bench v2 -- reproducible via `eval_bench.py`, but not a third-party benchmark such as the Open LLM Leaderboard.
|
| 415 |
-
- **English-only.** Trained on English data; other languages degrade quickly.
|
| 416 |
-
- **Tool-schema sensitivity.** The model emits `<tool_call>` XML. Non-standard schemas, other function-calling formats, or very long tool lists can reduce accuracy.
|
| 417 |
-
- **32K context on a 0.5B model** does not mean 32K of reliable deep recall -- attention quality degrades well before the window fills for long documents.
|
| 418 |
-
|
| 419 |
-
## Citation
|
| 420 |
-
|
| 421 |
-
If you use this model, please cite the base model and the SakThai family work:
|
| 422 |
-
|
| 423 |
-
```bibtex
|
| 424 |
-
@misc{qwen25,
|
| 425 |
-
title={Qwen2.5 Technical Report},
|
| 426 |
-
author={Qwen Team, Alibaba Group},
|
| 427 |
-
year={2025},
|
| 428 |
-
url={https://arxiv.org/abs/2412.15115}
|
| 429 |
-
}
|
| 430 |
-
|
| 431 |
-
@software{sakthai-context-0.5b-tools,
|
| 432 |
-
author = {SakThai Family (beer-sakthai)},
|
| 433 |
-
title = {SakThai Context 0.5B Tools -- Ultra-light tool-calling agent},
|
| 434 |
-
year = {2026},
|
| 435 |
-
url = {https://huggingface.co/Nanthasit/sakthai-context-0.5b-tools}
|
| 436 |
-
note = {Built from a shelter in Cork, Ireland, with a $0 budget.}
|
| 437 |
-
}
|
| 438 |
-
```
|
| 439 |
-
|
| 440 |
-
## Links
|
| 441 |
-
|
| 442 |
-
- [🏠 SakThai Model Family](https://huggingface.co/collections/Nanthasit/sakthai-model-family-6a64745450b12d421c1f9f02)
|
| 443 |
-
- [📚 Training Data](https://huggingface.co/datasets/Nanthasit/sakthai-combined-v7)
|
| 444 |
-
- [📊 Bench-v2 Dataset](https://huggingface.co/datasets/Nanthasit/sakthai-bench-v2)
|
| 445 |
-
- [📊 Bench Results](https://huggingface.co/datasets/Nanthasit/sakthai-bench-v2/tree/main/results)
|
| 446 |
-
- [🔄 Merged (GGUF)](https://huggingface.co/Nanthasit/sakthai-context-0.5b-merged)
|
| 447 |
-
- [🔧 Eval Script](https://huggingface.co/datasets/Nanthasit/sakthai-bench-v2/raw/main/eval_bench.py)
|
| 448 |
-
- [Web Agent Space](https://huggingface.co/spaces/Nanthasit/sakthai-web-agent)
|
| 449 |
-
- [🔊 TTS Demo Space](https://huggingface.co/spaces/Nanthasit/sakthai-tts)
|
| 450 |
-
- [📊 Leaderboard Space](https://huggingface.co/spaces/Nanthasit/sakthai-leaderboard)
|
| 451 |
-
|
| 452 |
-
*Built from a shelter in Cork, Ireland.*
|
|
|
|
| 71 |
|
| 72 |
<h1 align="center">SakThai Context 0.5B — Tools</h1>
|
| 73 |
<p align="center"><em>Ultra-light tool-calling agent · Qwen2.5-0.5B fine-tune · runs in ~1 GB RAM</em></p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
+
> **NEW (2026-08-01):** Added "Quick Example" section — copy-paste 30-second working code showing tool calling in action.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
**SakThai Context 0.5B Tools** is the v4 release of the tool-calling agent — fine-tuned from Qwen2.5-0.5B-Instruct with prompt-masked SFT. It achieves **91.2% selection accuracy** (multiset-corrected scorer) on the SakThai Bench v2, a 2.3× improvement over the 40.2% baseline.
|
| 78 |
|
| 79 |
+
## Quick Example
|
| 80 |
|
| 81 |
+
Get a working tool-calling agent in 30 seconds:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
```python
|
| 84 |
+
import json
|
| 85 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 86 |
|
| 87 |
model_id = "Nanthasit/sakthai-context-0.5b-tools"
|
| 88 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 89 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
|
| 90 |
+
|
| 91 |
+
# Define available tools
|
| 92 |
+
tools = [
|
| 93 |
+
{
|
| 94 |
+
"type": "function",
|
| 95 |
+
"function": {
|
| 96 |
+
"name": "get_weather",
|
| 97 |
+
"description": "Get current weather",
|
| 98 |
+
"parameters": {
|
| 99 |
+
"type": "object",
|
| 100 |
+
"properties": {"location": {"type": "string"}},
|
| 101 |
+
"required": ["location"]
|
| 102 |
+
}
|
|
|
|
|
|
|
| 103 |
}
|
| 104 |
}
|
| 105 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
+
# Build conversation
|
| 108 |
messages = [
|
| 109 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
| 110 |
+
{"role": "user", "content": "What's the weather in Tokyo?"}
|
| 111 |
]
|
| 112 |
+
|
| 113 |
+
# Generate
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
text = tokenizer.apply_chat_template(messages, tools=tools, tokenize=False, add_generation_prompt=True)
|
| 115 |
inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
| 116 |
+
outputs = model.generate(**inputs, max_new_tokens=100, temperature=0.01)
|
| 117 |
+
|
| 118 |
+
# Parse tool call
|
| 119 |
+
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
|
| 120 |
+
if "<tool_call>" in response:
|
| 121 |
+
json_str = response.split("<tool_call>")[1].split("</tool_call>")[0]
|
| 122 |
+
tool_call = json.loads(json_str)
|
| 123 |
+
print(f"✓ Tool: {tool_call['name']}, args: {tool_call['arguments']}")
|
| 124 |
```
|
| 125 |
|
| 126 |
+
**Expected:** `✓ Tool: get_weather, args: {'location': 'Tokyo'}`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
+
This snippet loads the model, formats a conversation with tools, generates a response, and extracts the structured tool call. Works on CPU — edit `device_map="cpu"` if needed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
|
| 130 |
---
|
| 131 |
|
| 132 |
+
*Full card (benchmarks, training details, family table, etc.) continues below.*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|