Files
txn-parser/qwen3-0.6b/README.md
ModelHub XC f70fa31854 初始化项目,由ModelHub XC社区提供模型
Model: kartikey31/txn-parser
Source: Original Platform
2026-08-09 01:23:21 +08:00

153 lines
6.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
license: apache-2.0
base_model: Qwen/Qwen3-0.6B
tags:
- text-generation
- lora
- qlora
- gguf
- transaction-parser
language:
- en
- hi
library_name: peft
---
# txn-parser / qwen3-0.6b
QLoRA fine-tune of [`Qwen/Qwen3-0.6B`](https://huggingface.co/Qwen/Qwen3-0.6B) for
extracting structured transaction data (amount, currency, item, category,
type) from free-form Indian-English / code-switched speech and text.
This model lives in subfolder **`qwen3-0.6b/`** of the
[`kartikey31/txn-parser`](https://huggingface.co/kartikey31/txn-parser) repo, alongside
sibling fine-tunes of other base models trained on the same data.
## What's in here
- `qwen3-0.6b/adapters/` — PEFT LoRA adapter (rank 32). Load on top of the base model
with `peft.PeftModel.from_pretrained(base, "kartikey31/txn-parser", subfolder="qwen3-0.6b/adapters")`.
- `qwen3-0.6b/gguf/` — merged GGUF builds at multiple quantization levels
(file names follow `txn-parser-qwen3-0.6b-<QUANT>.gguf`):
- [`qwen3-0.6b/gguf/txn-parser-qwen3-0.6b-F16.gguf`](https://huggingface.co/kartikey31/txn-parser/resolve/main/qwen3-0.6b/gguf/txn-parser-qwen3-0.6b-F16.gguf) (1198.2 MB)
- [`qwen3-0.6b/gguf/txn-parser-qwen3-0.6b-Q4_K_M.gguf`](https://huggingface.co/kartikey31/txn-parser/resolve/main/qwen3-0.6b/gguf/txn-parser-qwen3-0.6b-Q4_K_M.gguf) (396.7 MB)
- [`qwen3-0.6b/gguf/txn-parser-qwen3-0.6b-Q5_K_M.gguf`](https://huggingface.co/kartikey31/txn-parser/resolve/main/qwen3-0.6b/gguf/txn-parser-qwen3-0.6b-Q5_K_M.gguf) (444.4 MB)
- [`qwen3-0.6b/gguf/txn-parser-qwen3-0.6b-Q6_K.gguf`](https://huggingface.co/kartikey31/txn-parser/resolve/main/qwen3-0.6b/gguf/txn-parser-qwen3-0.6b-Q6_K.gguf) (495.1 MB)
- [`qwen3-0.6b/gguf/txn-parser-qwen3-0.6b-Q8_0.gguf`](https://huggingface.co/kartikey31/txn-parser/resolve/main/qwen3-0.6b/gguf/txn-parser-qwen3-0.6b-Q8_0.gguf) (639.4 MB)
## Training data
- 93,348 teacher-labeled examples (`data/distill/train.jsonl`)
- 300 held-out eval examples (`data/distill/eval.jsonl`)
- Validator-gated: every row's `output` passes the project's grammar +
amount-parser semantic validator.
## Training config
| Knob | Value |
|---|---|
| Base model | `Qwen/Qwen3-0.6B` |
| Method | QLoRA (4-bit) via Unsloth |
| LoRA rank | 32 (alpha 64, dropout 0.0) |
| Epochs | 2 |
| Batch size (train) | 64 |
| Grad accumulation | 2 |
| Eval batch size | 16 |
| Max seq length | 1024 |
| Learning rate | 2e-4 (warmup 3%) |
| Started | 2026-05-22T21:54:03.967900+00:00 |
| Finished | 2026-05-22T22:42:56.089528+00:00 |
## System prompt (use this EXACTLY)
The model was trained with one specific system prompt and Gemma/Smol/Qwen
chat template. If you paraphrase the prompt or skip the chat template,
quality degrades quickly. Copy-paste this verbatim into your inference
client (no leading/trailing whitespace, no edits):
```text
You convert voice-transcribed transaction descriptions into structured JSON.
Output ONLY a JSON object with this schema, no other text:
{"transactions":[{"amount":<number>,"currency":"INR"|"USD","item":"<lowercase singular noun phrase>","category":"<enum>","type":"expense"|"income"}]}
Categories: Food, Drinks, Groceries, Transport, Shopping, Entertainment, Bills, Health, Education, Personal, Gifts, Income, Other.
Rules:
- Currency defaults to INR. Use USD only when the input explicitly says "dollars" or contains "$".
- Amounts: "k" = ×1000, "hazaar" = ×1000, "sau" = ×100, "lakh" = ×100000. Convert number-words ("five hundred") to digits.
- type is "expense" by default; "income" only for explicit salary, cashback, refund, gift received, payment received.
- For disfluencies and corrections ("500 wait no 600"), output the CORRECTED amount only.
- For ambiguous items ("that thing", "stuff"), use item "unspecified" and category "Other".
- Item field: lowercase singular noun phrase ("uber ride", "beer", "chai" — not "Beers" or "Uber").
- Multi-transaction inputs become multiple array entries in spoken order.
- Category heuristics: uber/ola/auto/petrol/bus/metro → Transport; beer/wine/chai/coffee/juice → Drinks; rent/electricity/wifi/recharge/gas → Bills; movie/netflix/concert → Entertainment; doctor/medicine/hospital → Health.
```
Source of truth: [`scripts/_lib.py`](https://github.com/kartikeychoudhary/txn-parser/blob/main/scripts/_lib.py)
constant `SYSTEM_PROMPT`. Don't retype it — pull from `_lib.py` or this README.
## Download a single GGUF
```bash
huggingface-cli download kartikey31/txn-parser \
qwen3-0.6b/gguf/txn-parser-qwen3-0.6b-Q4_K_M.gguf \
--local-dir .
```
## Inference (Python, llama-cpp-python)
```python
from llama_cpp import Llama
SYSTEM_PROMPT = '''You convert voice-transcribed transaction descriptions into structured JSON.
Output ONLY a JSON object with this schema, no other text:
{"transactions":[{"amount":<number>,"currency":"INR"|"USD","item":"<lowercase singular noun phrase>","category":"<enum>","type":"expense"|"income"}]}
Categories: Food, Drinks, Groceries, Transport, Shopping, Entertainment, Bills, Health, Education, Personal, Gifts, Income, Other.
Rules:
- Currency defaults to INR. Use USD only when the input explicitly says "dollars" or contains "$".
- Amounts: "k" = ×1000, "hazaar" = ×1000, "sau" = ×100, "lakh" = ×100000. Convert number-words ("five hundred") to digits.
- type is "expense" by default; "income" only for explicit salary, cashback, refund, gift received, payment received.
- For disfluencies and corrections ("500 wait no 600"), output the CORRECTED amount only.
- For ambiguous items ("that thing", "stuff"), use item "unspecified" and category "Other".
- Item field: lowercase singular noun phrase ("uber ride", "beer", "chai" — not "Beers" or "Uber").
- Multi-transaction inputs become multiple array entries in spoken order.
- Category heuristics: uber/ola/auto/petrol/bus/metro → Transport; beer/wine/chai/coffee/juice → Drinks; rent/electricity/wifi/recharge/gas → Bills; movie/netflix/concert → Entertainment; doctor/medicine/hospital → Health.'''
llm = Llama(
model_path="txn-parser-qwen3-0.6b-Q4_K_M.gguf",
n_gpu_layers=-1, n_ctx=2048,
)
out = llm.create_chat_completion(
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": "200 ka samosa"},
],
temperature=0.0,
)
print(out["choices"][0]["message"]["content"])
```
## Inference (CLI, llama.cpp)
```bash
./llama-cli -m txn-parser-qwen3-0.6b-Q4_K_M.gguf \
--grammar-file scripts/grammar.gbnf \
--system-prompt "$(cat system_prompt.txt)" \
-p "200 ka samosa" -n 256
```
## Reproduce
```bash
git clone https://github.com/kartikeychoudhary/txn-parser.git
cd txn-parser && bash setup.sh
python scripts/train_and_publish.py --only qwen3-0.6b
```
---
*Auto-published by `scripts/train_and_publish.py` on 2026-05-22T22:42:56.387243+00:00.*