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

Profile Collection Downloads LoRA License Base model


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.py originally pinned a v4 dataset id that was never published (404 on Hub). It now loads Nanthasit/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):


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 provenancetrain.py loads 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
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

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

Adapter
(1284)
this model

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

Space using Nanthasit/sakthai-context-1.5b-tools 1

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

Evaluation results