11-47's picture
Super-squash branch 'main' using huggingface_hub
48906c3
|
Raw History Blame Contribute Delete
5.08 kB
---
language:
- en
library_name: transformers
pipeline_tag: text-generation
base_model: WithinUsAI/WIUAI.Mini.Coder
datasets:
- NousResearch/hermes-function-calling-v1
tags:
- function-calling
- tool-use
- hermes
- chatml
- full-fine-tune
- withinusai
---
# WIUAI.Mini.Coder.ToolCalling
Full fine-tune of [WithinUsAI/WIUAI.Mini.Coder](https://huggingface.co/WithinUsAI/WIUAI.Mini.Coder) on
[NousResearch/hermes-function-calling-v1](https://huggingface.co/datasets/NousResearch/hermes-function-calling-v1) only. Published by WithinUsAI.
> **Status:** checkpoint at **step 237 of 237** (epoch 1.00). This README and the model weights are
> replaced automatically at every checkpoint, so the repo always holds one complete, latest model.
> Elapsed training time so far: 59 min. No task benchmark has been run.
## Prompt format
Hermes function-calling ChatML. Roles: system, user, assistant, tool. The system prompt lists tools inside
`<tools> </tools>`; the assistant answers with `<tool_call> ... </tool_call>`; tool results go in a `tool` turn
inside `<tool_response>` tags. The assistant turn ends with `<|im_end|>`. Stop generation at `<|im_end|>`.
```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
repo = "WithinUsAI/WIUAI.Mini.Coder.ToolCalling"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, dtype=torch.float16, device_map="auto")
# SYSTEM_PROMPT = the Hermes function-calling system prompt with your tool list inside <tools> </tools>
prompt = ("<|im_start|>system\n" + SYSTEM_PROMPT + "<|im_end|>\n"
"<|im_start|>user\n" + USER_MESSAGE + "<|im_end|>\n"
"<|im_start|>assistant\n")
ids = tok(prompt, return_tensors="pt", add_special_tokens=False).to(model.device)
out = model.generate(**ids, max_new_tokens=200, do_sample=False,
eos_token_id=tok.convert_tokens_to_ids("<|im_end|>"))
print(tok.decode(out[0][ids["input_ids"].shape[1]:]))
```
## Training data
Only `NousResearch/hermes-function-calling-v1` (all five files). Conversations are ShareGPT-style turns converted to ChatML. Duplicates are removed
(SHA-256). Conversations longer than 1024 tokens are **dropped, not truncated**.
| File | Raw | Duplicates | Rejected | Too long | Kept | Kept with tool call |
|---|---|---|---|---|---|---|
| func-calling-singleturn.json | 1893 | 0 | 0 | 1212 | 681 | 676 |
| func-calling.json | 1893 | 793 | 0 | 988 | 112 | 110 |
| glaive-function-calling-5k.json | 5209 | 2 | 0 | 581 | 4626 | 4128 |
| json-mode-agentic.json | 1342 | 41 | 0 | 170 | 1131 | 0 |
| json-mode-singleturn.json | 1241 | 0 | 0 | 2 | 1239 | 0 |
Kept 7789 of 10742 unique conversations (73%). Token length of all conversations: median 786, 90th percentile 2146, max 5187.
Split: 7556 train / 233 validation (random, seed 1147).
## Training
| Setting | Value |
|---|---|
| Hardware | 2x Tesla T4 (Kaggle), DataParallel via Hugging Face Trainer |
| Precision | fp32 master weights, fp16 mixed precision, gradient checkpointing |
| Context length | 1024 |
| Batch | 4 per GPU x 2 GPUs x 4 accumulation = 32 |
| Learning rate | 2e-05 peak, cosine, 3% warmup, weight decay 0.01, grad clip 1.0 |
| Planned epochs | 1 (237 steps) |
| Objective | Next-token loss on **assistant turns only** (system, user and tool turns are masked) |
| Tokens per epoch | 5,216,618 |
| Seed | 1147 |
## Progress (validation loss is on assistant tokens of the held-out split)
Base model before training: **1.1192**
| Step | Epoch | Train loss | Validation loss | Spot check |
|---|---|---|---|---|
| 100 | 0.42 | 0.5178 | 0.4836 | 2/2 |
| 200 | 0.85 | 0.4736 | 0.4624 | 2/2 |
| 237 | 1.00 | 0.5467 | 0.4620 | 2/2 |
## Spot check at this checkpoint
Two fixed prompts in the Hermes format with a one-tool system prompt. Pass = valid `<tool_call>` with the right function name
and an arguments dict. This is a tiny smoke test, not a benchmark.
| Prompt | Expected | Pass | Output |
|---|---|---|---|
| What's the weather in Paris right now? | get_weather | yes | `<tool_call> / {"name": "get_weather", "arguments": {"city": "Paris", "weather_type": "weather"}} / </tool_call> / <tool_call> / {"name": "get_weather", "argumen...` |
| Add 17 and 25. | add_numbers | yes | `<tool_call> / {"name": "add_numbers", "arguments": {"a": 1, "b": 2, "c": 3}} / </tool_call> / <tool_call> / {"name": "get_camera_live_feed", "arguments": {"came...` |
## Limitations
- Trained only on Hermes Function-Calling V1. Coding ability of the base model was not re-tested and may have regressed.
- Conversations over 1024 tokens were dropped, so long multi-turn sessions with large tool lists are under-represented.
- The validation split is random from the same dataset, so it can overstate generalization. No external benchmark was run.
- Can produce malformed calls, wrong arguments, or invented tool names. Validate output before executing any call.
## License and attribution
See the base model card and the dataset card (NousResearch/hermes-function-calling-v1) for licenses. This card grants no additional rights.