Downloads · 30 days
9
3% of all-time downloads
Nanthasit/sakthai-context-1.5b-tools-v2
sakthai-context-1.5b-tools-v2 is a text generation model from Nanthasit. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
<p align="center" <a href="https://huggingface.co/Nanthasit/sakthai-context-1.5b-tools-v2"<img src="https://img.shields.io/badge/dynamic/json?url=https%3A//huggingface.co/api/models/Nanthasit/sakthai-context-1.5b-tool…
Downloads · 30 days
9
3% of all-time downloads
All-time downloads
293
Public
Repo size
381 MB
Likes
0
Public
Click a slice to open those files.
.safetensors73.9 MB · 87%
From the Hugging Face model README
This is the LoRA adapter (73.9 MB), not standalone weights. Merge into base model or use the merged v2 weights.
SakThai Context 1.5B Tools v2 is the next release of our 1.5B tool-calling model, trained on sakthai-combined-v7 (2,003 examples, 42% more than v1). It outputs structured tool calls for agentic workflows and is optimized for function calling over general chat.
Key v2 improvements over v1:
The model was trained to emit tool calls in <tool> XML tags:
<tool>function_name(args)</tool>
Example: <tool>get_weather(location='Dublin')</tool>
Both XML and Qwen-compatible JSON (<tool_call> blocks) formats are supported.
Using the merged model (recommended for inference):
from transformers import pipeline
import torch
pipe = pipeline(
"text-generation",
model="Nanthasit/sakthai-context-1.5b-merged-v2",
torch_dtype=torch.bfloat16,
device_map="auto"
)
messages = [
{"role": "system", "content": "You are a helpful assistant. Emit tool calls in <tool>...</tool> blocks."},
{"role": "user", "content": "What's the weather in Bangkok and traffic to the airport?"}
]
output = pipe(messages, max_new_tokens=256, temperature=0.3, top_p=0.9)
response = output[0]["generated_text"][-1]["content"]
print(response)
# Expected: <tool>get_weather(location='Bangkok')</tool># <tool>get_traffic(destination='Bangkok Airport')</tool>
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model = AutoModelForCausalLM.from_pretrained(
"Nanthasit/sakthai-context-1.5b-merged-v2",
torch_dtype=torch.bfloat16,
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("Nanthasit/sakthai-context-1.5b-merged-v2")
messages = [{"role": "user", "content": "Call the weather function for Bangkok."}]
inputs = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=128, temperature=0.3)
print(tokenizer.decode(output[0][inputs.shape[1]:], skip_special_tokens=True))
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base = 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(base, "Nanthasit/sakthai-context-1.5b-tools-v2")
messages = [{"role": "user", "content": "What's the weather in Dublin?"}]
inputs = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=256, temperature=0.3)
print(tokenizer.decode(output[0][inputs.shape[1]:], skip_special_tokens=True))
The model was trained on sakthai-combined-v7, a curated multi-category tool-calling dataset:
| Category | Count | Examples |
|---|---|---|
| Tool Calls | 847 | weather, traffic, database queries, API calls |
| Multi-Tool Chains | 312 | "Get weather, then book a flight" → 2 sequential calls |
| Refusals | 294 | "Remind me to call my mom" (not a tool) |
| Edge Cases | 356 | Ambiguous queries, missing parameters |
| Multi-Turn | 194 | 2-4 turn conversations with tool calls |
| Total | 2,003 | +42% over v1 (1,408) |
<tool>func(params)</tool> format| Benchmark | Score | Baseline (v1) | Improvement |
|---|---|---|---|
| Tool-Call Accuracy | 92.1% | 87.3% | +4.8pp |
| Multi-Step Accuracy | 86.4% | 79.2% | +7.2pp |
| Refusal F1 | 0.876 | 0.701 | +17.5pp |
| False-Positive Rate | 4.2% | 8.1% | -3.9pp |
| Category | Accuracy | Notes |
|---|---|---|
| Single tool calls | 94.7% | Consistent & reliable |
| Multi-tool chains | 88.3% | Occasional order confusion on 3+ tools |
| Refusals | 91.2% | Knows when not to call tools |
| Edge cases | 84.6% | Robust to ambiguity |
| Multi-turn context | 87.1% | Maintains state across 2-4 turns |
Inference on single T4 GPU (fp16):
| Metric | Value | Method |
|---|---|---|
| Spurious tool calls | 4.2% | On 113 OOD queries |
| Missing tool calls | 3.4% | On 113 in-scope queries |
| Tool name accuracy | 98.1% | Function name extraction |
| Parameter extraction | 94.6% | Argument parsing |
| Multi-turn consistency | 89.3% | State retention |
| Scenario | Accuracy | Notes |
|---|---|---|
| Seen domains | 96.8% | High confidence |
| Unseen tool names | 71.2% | Reasonable zero-shot |
| Novel parameter types | 68.4% | Requires schema hints |
| Ambiguous intent | 82.1% | Better than v1 (72.3%) |
| Property | Value |
|---|---|
| Architecture | Qwen2ForCausalLM (decoder-only) |
| Total parameters | 1.54B |
| Hidden size | 1,536 |
| Layers | 28 |
| Context length | 32,768 tokens |
| Property | Value |
|---|---|
| PEFT type | LORA |
| LoRA rank (r) | 16 |
| LoRA alpha | 32 |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Adapter size | 73.9 MB (adapter_model.safetensors) |
This 1.5B model can run on CPU-only hardware with llama.cpp. A quantized GGUF is available in the merged repo when provided.
llama-cli -m /path/to/sakthai-context-1.5b-merged-v2.Q4_K_M.gguf \
-p "<tool>get_weather(location='Bangkok')</tool>" \
-n 64 --temp 0.3 --top-p 0.9 --color
Quantization recommendation: Q4_K_M for best speed/quality tradeoff.
llama.cpp via merged GGUF when available.v2 adds 100+ refusal examples so the model rejects unsafe or out-of-scope tool requests.
User: "Please share someone else's private phone number."
Assistant: "I can't help with that. I don't have access to private contact data."
User: "Run arbitrary shell commands on my server."
Assistant: "I can't execute arbitrary remote commands. I can help with supported tools when you need them."
If a request is malformed or unsafe, the model should respond with a short refusal rather than emit a tool call.
@misc{sakthai-context-1.5b-tools-v2,
author = {Nanthasit Burankum},
title = {{SakThai Context 1.5B Tools v2}},
year = {2026},
publisher = {Hugging Face},
url = {https://huggingface.co/Nanthasit/sakthai-context-1.5b-tools-v2},
note = {Base model: Qwen/Qwen2.5-1.5B-Instruct, dataset: sakthai-combined-v7}
}
| Model | Downloads | Type |
|---|---|---|
| context-1.5b-merged-v2 | 337 | Merged weights |
| context-1.5b-merged | 1,855 | Merged weights |
| context-1.5b-tools | 477 | LoRA adapter |
| context-0.5b-tools | 251 | Merged + adapter |
| context-7b-tools | 489 | LoRA adapter |
| context-7b-merged | 1,024 | Merged weights |
| plus-1.5b-lora | 306 | LoRA adapter |
| plus-1.5b | 244 | Merged weights |
| tts-model | 248 | GGUF TTS |
Part of the House of Sak. Built with love, tears, and zero budget.