Munshi: Qwen3 1.7B for Roman-Urdu shop ledger entries
Munshi turns a shopkeeper's Roman-Urdu message into one JSON ledger entry. It is the extraction step of Munshi, an offline bookkeeping assistant for small shops in Pakistan, built for the Qwen Local Hackathon 2026.
Input: Ahmed ko 5 kilo chawal udhaar diye
Output: {"type": "udhaar", "party": "Ahmed", "item": "chawal", "qty": 5, "unit": "kg", "amount": null}
Intended use
- Extracting a structured entry from a short Roman-Urdu message about credit (
udhaar), a customer payment (payment), a cashsale, a stockpurchaseor a shopexpense. - Running locally on modest hardware through Ollama or llama.cpp.
- The model only extracts. In the Munshi app, plain code stores the entries and calculates balances, and the user confirms every entry before it is saved.
Not intended for: doing arithmetic or keeping balances, guessing prices that are not in the message, financial or legal advice, or saving entries without a person checking them.
Files
| File | What it is |
|---|---|
finetuned-q4_k_m.gguf | The fine-tuned model, merged and quantized to Q4_K_M (1.1 GB), for Ollama or llama.cpp |
adapter/ | The LoRA adapter (rank 16, 70 MB) on unsloth/Qwen3-1.7B-unsloth-bnb-4bit, with tokenizer and chat template |
Modelfile | Ollama import file with the system prompt built in |
How to use
Use the exact system prompt from training (system_prompt.txt in the repo):
You turn a shopkeeper's Roman Urdu message into one ledger entry. Reply with JSON only, with exactly these keys: "type" (one of "udhaar", "payment", "sale", "purchase", "expense"), "party" (person or supplier name, or null), "item" (standard item name, or null), "qty" (number or null), "unit" (kg, litre, packet, dozen, bori, piece, or null), "amount" (rupees as a number, or null).
With Ollama, download the GGUF and the repo's Modelfile (which builds in the system prompt):
git clone https://github.com/wadeedkhan1/munshi && cd munshi
hf download wadeedkhan1/munshi-qwen3-1.7b-gguf finetuned-q4_k_m.gguf --local-dir .
ollama create munshi -f Modelfile
python ledger.py
Then send the system prompt and the message to /api/chat with "format": "json" and "think": false. See evaluate.py and ledger.py in the repo.
Training
| Base model | Qwen/Qwen3-1.7B (finetune-anywhere starter alias) |
| Method | LoRA on a 4-bit base (QLoRA) with Unsloth + TRL SFTTrainer, via finetune-anywhere paths/nvidia-gpu/train_unsloth.py |
| Settings | rank 16, alpha 32, learning rate 2e-4 (linear decay, Unsloth warm-up), 3 epochs (1125 steps), max sequence length 1024, batch size 1, gradient accumulation 4, seed 42 |
| Hardware | NVIDIA RTX 5060 (8 GB), local, WSL2 |
| Training time | 21 minutes (1265 s, from run.json) |
| Loss | final train loss 0.068; validation loss 0.110 after epoch 1, 0.097 after epoch 3 |
| Export | GGUF, Q4_K_M |
Data
The data is synthetic Roman-Urdu messages from generate_dataset.py (seed 42): 1500 train / 150 valid / 150 eval, in chat format. Messages vary spelling (chawal/chawl), units (kilo, darjan, bori), amount wording (dedh hazar, 5k, 10,000), casing and filler words.
The eval split uses held-out names, items and phrasings. Exact eval messages never appear in training. Some eval rows still reuse a training phrasing and the shared expense vocabulary, so the synthetic eval is not entirely out-of-distribution. A separate hand-written real eval set has 50 messages (udhaar 15, payment 11, sale 9, expense 8, purchase 7); none of them appear in train or valid.
Dataset link: https://github.com/wadeedkhan1/munshi/tree/master/data
Evaluation
All results come from evaluate.py (temperature 0, Ollama). An exact match means all six fields are right.
| Model | Eval set | Exact match | Valid JSON | Per-field (type / party / item / qty / unit / amount) | Avg latency |
|---|---|---|---|---|---|
| qwen3:1.7b (base) | synthetic eval (150) | 9/150 (6%) | 150/150 | 49 / 53 / 30 / 54 / 53 / 75 % | 2.25 s |
| Munshi | synthetic eval (150) | 94/150 (63%) | 150/150 | 81 / 91 / 79 / 91 / 91 / 96 % | 2.24 s |
| qwen3:1.7b (base) | real eval (50) | 16/50 (32%) | 50/50 | 64 / 64 / 64 / 60 / 72 / 82 % | 2.25 s |
| Munshi | real eval (50) | 34/50 (68%) | 50/50 | 86 / 98 / 90 / 92 / 94 / 94 % | 2.35 s |
| qwen2.5:7b (larger, not fine-tuned) | synthetic eval (150) | 46/150 (31%) | 150/150 | 89 / 91 / 48 / 94 / 86 / 86 % | 2.72 s |
| qwen2.5:7b (larger, not fine-tuned) | real eval (50) | 31/50 (62%) | 50/50 | 76 / 96 / 86 / 94 / 90 / 90 % | 2.62 s |
| llama3.2:3b (not fine-tuned) | synthetic eval (150) | 5/150 (3%) | 150/150 | 61 / 57 / 34 / 66 / 49 / 71 % | 2.39 s |
| llama3.2:3b (not fine-tuned) | real eval (50) | 3/50 (6%) | 50/50 | 52 / 64 / 64 / 66 / 52 / 76 % | 2.33 s |
Hardware used for evaluation: NVIDIA RTX 5060 (8 GB), Ollama 0.40.18, Q4_K_M GGUF.
The most common error is a customer payment predicted as udhaar (12/150 synthetic, 4/50 real), usually for wording not in the training data.
Limitations
- It is trained on synthetic data with a small vocabulary: 25 training names, 12 items, 6 units and 8 expense kinds. Real messages with other items, multiple items per message, or Urdu script are out of scope.
- Every sale in the training data uses the masculine verb "becha" and has a price, so a sale written with "bechi"/"beche" or without a price (for example "5 kilo cheeni bechi") can be labelled
purchase. - The model expects the system prompt above. Without it (for example in a chat app that sends no system message), it does not produce ledger entries. The repo's
Modelfilebuilds the prompt in. - If a message has no price,
amountisnull. The model is trained not to guess, so an udhaar entry may carry no rupee value. - Some training messages contain small grammar slips, such as a masculine verb after a female name.
- Always show the extracted entry to the user before saving it.