SakThai Context 0.5B — Tools

Ultra-light tool-calling agent · Qwen2.5-0.5B fine-tune · runs in ~1 GB RAM

NEW (2026-08-01): Added "Quick Example" section — copy-paste 30-second working code showing tool calling in action.

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.

Quick Example

Get a working tool-calling agent in 30 seconds:

import json
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "Nanthasit/sakthai-context-0.5b-tools"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")

# Define available tools
tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get current weather",
            "parameters": {
                "type": "object",
                "properties": {"location": {"type": "string"}},
                "required": ["location"]
            }
        }
    }
]

# Build conversation
messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "What's the weather in Tokyo?"}
]

# Generate
text = tokenizer.apply_chat_template(messages, tools=tools, tokenize=False, add_generation_prompt=True)
inputs = tokenizer([text], return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=100, temperature=0.01)

# Parse tool call
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
if "<tool_call>" in response:
    json_str = response.split("<tool_call>")[1].split("</tool_call>")[0]
    tool_call = json.loads(json_str)
    print(f"✓ Tool: {tool_call['name']}, args: {tool_call['arguments']}")

Expected: ✓ Tool: get_weather, args: {'location': 'Tokyo'}

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.


Full card (benchmarks, training details, family table, etc.) continues below.

Downloads last month
251
Safetensors
Model size
0.5B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Nanthasit/sakthai-context-0.5b-tools

Finetuned
(922)
this model
Adapters
3 models

Datasets used to train Nanthasit/sakthai-context-0.5b-tools

Spaces using Nanthasit/sakthai-context-0.5b-tools 2

Collections including Nanthasit/sakthai-context-0.5b-tools

Evaluation results

  • Selection Accuracy on SakThai Bench v2 (500 rows, scorer multiset-selection-v2)
    self-reported
    91.200
  • Arguments Accuracy on SakThai Bench v2 (500 rows, scorer multiset-selection-v2)
    self-reported
    45.700
  • Strict Accuracy on SakThai Bench v2 (500 rows, scorer multiset-selection-v2)
    self-reported
    45.700
  • Held-Out Tool Accuracy on SakThai Bench v2 (500 rows, scorer multiset-selection-v2)
    self-reported
    87.800
  • Degenerate Outputs on SakThai Bench v2 (500 rows, scorer multiset-selection-v2)
    self-reported
    0.000