python3isfun's picture
Upload README.md with huggingface_hub
ae0023a verified
---
license: apache-2.0
base_model: Qwen/Qwen3-1.7B
tags:
- tool-calling
- function-calling
- gguf
- llama.cpp
- on-device
- qwen3
library_name: llama.cpp
pipeline_tag: text-generation
---
# qwen3-1.7b-toolcall (Q5_K_M GGUF)
A QLoRA fine-tune of **Qwen3-1.7B** that reliably emits `<tool_call>` blocks for four
local search tools, intended for **on-device inference** (iOS / llama.cpp). Quantized to
**Q5_K_M** (~1.2 GB).
- **Base model:** [Qwen/Qwen3-1.7B](https://huggingface.co/Qwen/Qwen3-1.7B) (Apache-2.0)
- **Method:** QLoRA (Unsloth) — r=16, α=32, all 7 attn/MLP projections, 3 epochs, lr 2e-4, cosine, AdamW-8bit
- **Format:** bare ChatML, no `<think>` blocks
## What it does
Given a user message, it either calls one of four tools or answers directly (math, chitchat,
general knowledge, questions about the tools).
| Tool | Purpose |
|---|---|
| `search_recipes(query, sort_by)` | find recipes by dish / ingredient |
| `search_events(query, region, max_price)` | find concerts, sports, shows |
| `search_food_categories(query, min_tier)` | browse dish categories by popularity tier (1–5) |
| `search_regions(query)` | look up which cities a region covers |
A tool call is emitted as exactly:
```
<tool_call>
{"name": "search_recipes", "arguments": {"query": "cubano"}}
</tool_call>
```
## Prompt format
Plain ChatML, one block per message, then an empty assistant turn to generate:
```
<|im_start|>system
{system prompt}<|im_end|>
<|im_start|>user
{user message}<|im_end|>
<|im_start|>assistant
```
System prompt the model was trained on:
```
You have access to these tools. To use one, reply ONLY with a tool_call block:
<tool_call>
{"name": "TOOL_NAME", "arguments": {"key": "value"}}
</tool_call>
Tools:
- search_recipes(query, sort_by): Find recipes by dish name or ingredient.
- search_events(query, region, max_price): Find concerts, sports, shows.
- search_food_categories(query, min_tier): Browse 100 dish categories by tier (1-5).
- search_regions(query): Look up which cities a region covers.
If the question does NOT need a tool, answer directly without a tool_call block.
```
Two-turn flow: the model emits a `<tool_call>`; your app runs the tool and feeds the result
back as a system message (`Tool results:\n{...}\n\nNow answer the user's question using the
results above.`), then the model writes the final natural-language answer.
## Evaluation
12-test tool-use suite + a 250-example held-out set. Q5_K_M, temperature 0:
| Metric | Base Qwen3-1.7B | This model (Q5_K_M) |
|---|---|---|
| Overall score | 0.767 | **0.850** |
| Pass rate (≥0.8) | 8/12 | **10/12** |
| Tool-call rate | 70% | **100%** |
| Valid tool-call JSON | 70% | **100%** |
| Correct tool name | 70% | **100%** |
| Held-out tool-name acc (unseen) | 47% | **100%** |
Q5_K_M matches the full-precision model (0.85) and passes under both the trained (no-few-shot)
prompt and a few-shot variant. An **overfitting check** showed train acc = holdout acc = 100%
(zero gap) and 94% on deliberately off-template slang/typo queries — it learned the skill, not
the training set.
## Usage (llama.cpp)
```bash
hf download python3isfun/qwen3-1.7b-toolcall-gguf qwen3-1.7b-toolcall-Q5_K_M.gguf --local-dir .
./llama-cli -m qwen3-1.7b-toolcall-Q5_K_M.gguf --temp 0 -p "<your ChatML prompt>"
```
```python
from llama_cpp import Llama
llm = Llama(model_path="qwen3-1.7b-toolcall-Q5_K_M.gguf", n_ctx=2048)
prompt = ("<|im_start|>system\n" + SYSTEM_PROMPT + "<|im_end|>\n"
"<|im_start|>user\nFind me a recipe for tacos<|im_end|>\n"
"<|im_start|>assistant\n")
print(llm(prompt, temperature=0.0, stop=["<|im_end|>"])["choices"][0]["text"])
# -> <tool_call>\n{"name": "search_recipes", "arguments": {"query": "tacos"}}\n</tool_call>
```
## Notes & limitations
- Trained against a specific local dataset (recipes/events/food categories/regions); tool
*results* must come from that data for grounded final answers.
- Constrained task (4 tools) — strong scores mean "no overfitting on this skill," not "flawless
on every input."
- A `Q4_K_M` variant (~1.06 GB) also exists; it matches Q5 under the trained prompt but is
slightly less robust under a longer few-shot prompt.
## License
Apache-2.0, inherited from the Qwen3-1.7B base model.