File size: 4,215 Bytes
d60d596
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
---
language:
- en
- ig
- ha
- yo
license: apache-2.0
base_model: McGill-NLP/AfriqueQwen-8B
tags:
- tool-calling
- function-calling
- igbo
- hausa
- yoruba
- nigeria
- voice-assistant
---

# MadamLLM-Tools

**Madam** is a Nigerian multilingual voice assistant fine-tuned for native tool calling across Igbo, Hausa, Yoruba, and English.

This model (`madamLLM-tools`) extends [`babs/madamLLM-dpo`](https://huggingface.co/babs/madamLLM-dpo) with tool calling capabilities using Qwen3's native Hermes-style `<tool_call>` format.

## Model Details

- **Base model:** [McGill-NLP/AfriqueQwen-8B](https://huggingface.co/McGill-NLP/AfriqueQwen-8B) (Qwen3-8B continued pretrained on 27.5B tokens across 20 African languages)
- **Training stages:** SFT β†’ SimPO DPO β†’ Tool Calling SFT (this model)
- **Method:** LoRA SFT (rank 64, alpha 128, RSLoRA, all linear layers + lm_head)
- **Framework:** LLaMA-Factory
- **Hardware:** 2Γ— NVIDIA A100 SXM 80GB

## Tool Calling Evaluation

| Metric | Score |
|--------|-------|
| Tool calling accuracy | 20/20 β€” **100%** |
| Irrelevance detection | 10/10 β€” **100%** |
| Args in English | 19/20 β€” 95% |
| Weighted overall | **99.0%** |

All four languages scored 100% on tool accuracy: English βœ… Igbo βœ… Hausa βœ… Yoruba βœ…

## Supported Tools

Madam knows 8 Nigeria-specific tools out of the box:

| Tool | Description |
|------|-------------|
| `get_weather` | Current weather for Nigerian cities |
| `get_exchange_rate` | NGN exchange rates |
| `get_news` | Nigerian news headlines |
| `get_market_prices` | Commodity prices (rice, garri, fuel, etc.) |
| `search_health_info` | Basic health and first-aid guidance |
| `get_prayer_times` | Islamic prayer times |
| `send_message` | Send SMS/WhatsApp messages |
| `set_reminder` | Set time-based reminders |

## Tool Calling Format

Uses Qwen3's native Hermes-style format. Pass tools via `apply_chat_template`:

```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model = AutoModelForCausalLM.from_pretrained("babs/madamLLM-tools", torch_dtype=torch.bfloat16, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained("babs/madamLLM-tools")

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get the current weather conditions for a city in Nigeria",
            "parameters": {
                "type": "object",
                "properties": {
                    "city": {"type": "string", "description": "City name, e.g. Lagos, Kano, Abuja"}
                },
                "required": ["city"]
            }
        }
    }
]

messages = [
    {"role": "system", "content": "You are Madam, a Nigerian voice assistant."},
    {"role": "user", "content": "Yaya yanayi a Kano yau?"}  # Hausa: What's the weather in Kano today?
]

text = tokenizer.apply_chat_template(messages, tools=tools, tokenize=False, add_generation_prompt=True, enable_thinking=False)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=200, temperature=0.3, do_sample=True, eos_token_id=[151645, 151643])
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False))
# β†’ <tool_call>{"name": "get_weather", "arguments": {"city": "Kano"}}</tool_call>
```

## vLLM Serving

```bash
vllm serve babs/madamLLM-tools \
    --tool-call-parser hermes \
    --enable-auto-tool-choice \
    --dtype bfloat16 \
    --max-model-len 4096
```

## Training Data

| Source | Examples | Purpose |
|--------|----------|---------|
| Synthetic (Groq gpt-oss-120b) | 11,924 | Nigeria-specific tool calls, 4 languages |
| APIGen-MT-5k | 1,009 | Multi-turn tool chains |
| xLAM-60k sample | 2,500 | Diverse tool schemas (1,240 unique tools) |
| Hermes FC v1 | 1,100 | Format alignment |
| SFT replay | 4,000 | Anti-forgetting (Igbo/Hausa/Yoruba/English) |
| **Total** | **20,533** | |

50% of tool-calling examples use function masking (Hammer technique) for generalization to unseen tools.

## Soul

Madam embodies the nine fruits of the Spirit (Galatians 5:22-23): love, joy, peace, patience, kindness, goodness, faithfulness, gentleness, and self-control.