Text Generation
PEFT
Safetensors
GGUF
English
Hindi
lora
qlora
transaction-parser
on-device
conversational
Instructions to use kartikey31/txn-parser with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use kartikey31/txn-parser with PEFT:
Task type is invalid.
- llama-cpp-python
How to use kartikey31/txn-parser with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="kartikey31/txn-parser", filename="gemma-3-270m/gguf/txn-parser-gemma-3-270m-F16.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use kartikey31/txn-parser with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf kartikey31/txn-parser:Q4_K_M # Run inference directly in the terminal: llama-cli -hf kartikey31/txn-parser:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf kartikey31/txn-parser:Q4_K_M # Run inference directly in the terminal: llama-cli -hf kartikey31/txn-parser:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf kartikey31/txn-parser:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf kartikey31/txn-parser:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf kartikey31/txn-parser:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf kartikey31/txn-parser:Q4_K_M
Use Docker
docker model run hf.co/kartikey31/txn-parser:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use kartikey31/txn-parser with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "kartikey31/txn-parser" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kartikey31/txn-parser", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/kartikey31/txn-parser:Q4_K_M
- Ollama
How to use kartikey31/txn-parser with Ollama:
ollama run hf.co/kartikey31/txn-parser:Q4_K_M
- Unsloth Studio new
How to use kartikey31/txn-parser with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for kartikey31/txn-parser to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for kartikey31/txn-parser to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for kartikey31/txn-parser to start chatting
- Docker Model Runner
How to use kartikey31/txn-parser with Docker Model Runner:
docker model run hf.co/kartikey31/txn-parser:Q4_K_M
- Lemonade
How to use kartikey31/txn-parser with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull kartikey31/txn-parser:Q4_K_M
Run and chat with the model
lemonade run user.txn-parser-Q4_K_M
List all available models
lemonade list
Add model card for v1.0
Browse files
README.md
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
+
library_name: gguf
|
| 10 |
+
pipeline_tag: text-generation
|
| 11 |
+
tags:
|
| 12 |
+
- text-generation
|
| 13 |
+
- gemma
|
| 14 |
+
- gemma-3
|
| 15 |
+
- gemma-4
|
| 16 |
+
- gguf
|
| 17 |
+
- finetune
|
| 18 |
+
- distillation
|
| 19 |
+
- on-device
|
| 20 |
+
- android
|
| 21 |
+
- llama-cpp
|
| 22 |
+
- transaction-parsing
|
| 23 |
+
- json-output
|
| 24 |
+
- structured-output
|
| 25 |
+
- voice-input
|
| 26 |
+
- expense-tracking
|
| 27 |
+
- code-mixed
|
| 28 |
+
- hinglish
|
| 29 |
+
model-index:
|
| 30 |
+
- name: txn-parser-student
|
| 31 |
+
results:
|
| 32 |
+
- task:
|
| 33 |
+
type: text-generation
|
| 34 |
+
name: Transaction parsing (JSON output)
|
| 35 |
+
metrics:
|
| 36 |
+
- type: json_valid_pct
|
| 37 |
+
name: JSON valid (50-example eval)
|
| 38 |
+
value: 94.0
|
| 39 |
+
- type: schema_valid_pct
|
| 40 |
+
name: Schema valid
|
| 41 |
+
value: 72.0
|
| 42 |
+
- type: exact_match_pct
|
| 43 |
+
name: Exact match (numeric-aware)
|
| 44 |
+
value: 20.0
|
| 45 |
+
---
|
| 46 |
+
|
| 47 |
+
# Transaction Parser — Voice → JSON (on-device)
|
| 48 |
+
|
| 49 |
+
Distilled student model that turns voice-transcribed transaction strings into
|
| 50 |
+
structured JSON for an Android expense-tracking app. Examples:
|
| 51 |
+
|
| 52 |
+
| Input | Output |
|
| 53 |
+
|---|---|
|
| 54 |
+
| `"500 rs on beer 50 rs on candy"` | `[{amount: 500, item: "beer", category: "Drinks", ...}, {amount: 50, item: "candy", ...}]` |
|
| 55 |
+
| `"do sau rupay ka chai"` | `[{amount: 200, currency: "INR", item: "chai", category: "Drinks", ...}]` |
|
| 56 |
+
| `"1.5k for shoes from myntra"` | `[{amount: 1500, item: "shoes", category: "Shopping", ...}]` |
|
| 57 |
+
| `"got my salary 50000"` | `[{amount: 50000, type: "income", category: "Income", ...}]` |
|
| 58 |
+
|
| 59 |
+
## What's in this repo
|
| 60 |
+
|
| 61 |
+
| Path | Description |
|
| 62 |
+
|---|---|
|
| 63 |
+
| `student/gguf/gemma3_text-fixed.BF16.gguf` | Lossless ref (543 MB) |
|
| 64 |
+
| `student/gguf/gemma3_text-fixed.Q8_0.gguf` | High quality (~290 MB) |
|
| 65 |
+
| **`student/gguf/gemma3_text-fixed.Q5_K_M.gguf`** | **Default for ship (260 MB)** |
|
| 66 |
+
| `student/gguf/gemma3_text-fixed.Q4_K_M.gguf` | Smallest but lossy on 270M (253 MB) |
|
| 67 |
+
| `student/adapters/` | Trained LoRA adapter (r=32, α=64) for further finetuning |
|
| 68 |
+
| `teacher/gguf/gemma-4-e2b-it.Q3_K_M.gguf` | Teacher (Gemma 4 E2B) used for distillation labeling |
|
| 69 |
+
| `teacher/adapters/` | Teacher LoRA adapter (r=16, α=32) |
|
| 70 |
+
|
| 71 |
+
## Recommended file
|
| 72 |
+
|
| 73 |
+
**`student/gguf/gemma3_text-fixed.Q5_K_M.gguf`** — 260 MB, 94% JSON valid,
|
| 74 |
+
runs on-device on Android via `llama.cpp` at ~150 ms per request on a modern
|
| 75 |
+
mid-range device.
|
| 76 |
+
|
| 77 |
+
### Evaluation (50-example smoke test)
|
| 78 |
+
|
| 79 |
+
| Build | Size | JSON valid | Schema valid | Exact match (numeric-aware) | Mean latency (A100) |
|
| 80 |
+
|---|---|---|---|---|---|
|
| 81 |
+
| fp16 adapter (ceiling) | n/a | 98% | 94% | ~48% | 1219 ms |
|
| 82 |
+
| BF16 GGUF (fixed) | 543 MB | 98% | 74% | 48% | 108 ms |
|
| 83 |
+
| Q8_0 GGUF (fixed) | ~290 MB | ~98% | ~74% | ~46% | ~120 ms |
|
| 84 |
+
| **Q5_K_M GGUF (fixed)** | **260 MB** | **94%** | **72%** | **20%** | **210 ms** |
|
| 85 |
+
| Q4_K_M GGUF (fixed) | 253 MB | 68% | 56% | 18% | 177 ms |
|
| 86 |
+
|
| 87 |
+
The "exact-match" column uses numeric-aware comparison (`100 == 100.0`).
|
| 88 |
+
Most "schema invalid" failures are missing-field or enum-value drift; the
|
| 89 |
+
category prediction is mostly diagonal in the confusion matrix.
|
| 90 |
+
|
| 91 |
+
> **Tip for Android:** always run a `JSON.parse → schema validate → fallback UI`
|
| 92 |
+
> pipeline. ~6% of inputs at Q5_K_M will fail to parse — handle that as
|
| 93 |
+
> "couldn't understand, please try again" rather than crashing.
|
| 94 |
+
|
| 95 |
+
## Usage
|
| 96 |
+
|
| 97 |
+
### `llama.cpp` / `llama-cpp-python` (Python)
|
| 98 |
+
|
| 99 |
+
```python
|
| 100 |
+
from llama_cpp import Llama
|
| 101 |
+
|
| 102 |
+
llm = Llama(
|
| 103 |
+
model_path="gemma3_text-fixed.Q5_K_M.gguf",
|
| 104 |
+
n_gpu_layers=-1,
|
| 105 |
+
n_ctx=2048,
|
| 106 |
+
verbose=False,
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
SYSTEM_PROMPT = (
|
| 110 |
+
"You convert short, possibly code-mixed (English/Hindi/Hinglish) "
|
| 111 |
+
"transcribed transaction strings into a JSON object with a single "
|
| 112 |
+
'"transactions" array. Each transaction has: amount (number), '
|
| 113 |
+
"currency (string, default 'INR'), item (string), category (one of "
|
| 114 |
+
"Food, Drinks, Groceries, Transport, Shopping, Entertainment, Bills, "
|
| 115 |
+
"Health, Education, Personal, Gifts, Income, Other), type "
|
| 116 |
+
"('expense' or 'income'). Output ONLY the JSON object — no prose."
|
| 117 |
+
)
|
| 118 |
+
|
| 119 |
+
resp = llm.create_chat_completion(
|
| 120 |
+
messages=[
|
| 121 |
+
{"role": "system", "content": SYSTEM_PROMPT},
|
| 122 |
+
{"role": "user", "content": "500 rs on beer 50 rs on candy"},
|
| 123 |
+
],
|
| 124 |
+
temperature=0.0, top_p=1.0, max_tokens=512,
|
| 125 |
+
)
|
| 126 |
+
print(resp["choices"][0]["message"]["content"])
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
### Android (`llama.cpp` JNI)
|
| 130 |
+
|
| 131 |
+
1. Bundle `gemma3_text-fixed.Q5_K_M.gguf` in your app (or download on first run).
|
| 132 |
+
2. Use the `llama.cpp` Android example or a JNI wrapper.
|
| 133 |
+
3. Set the same system prompt above; user message = the voice transcript.
|
| 134 |
+
4. Validate output with a JSON-schema library on the parse path.
|
| 135 |
+
|
| 136 |
+
Keep the `llama_context` alive across requests — don't reload per call.
|
| 137 |
+
|
| 138 |
+
### Quick test on Linux/macOS
|
| 139 |
+
|
| 140 |
+
```bash
|
| 141 |
+
huggingface-cli download kartikey31/txn-parser \
|
| 142 |
+
--repo-type=model --local-dir models
|
| 143 |
+
|
| 144 |
+
python -c "
|
| 145 |
+
from llama_cpp import Llama
|
| 146 |
+
llm = Llama(model_path='models/student/gguf/gemma3_text-fixed.Q5_K_M.gguf', n_gpu_layers=-1, verbose=False)
|
| 147 |
+
print(llm.create_chat_completion(messages=[
|
| 148 |
+
{'role':'system','content':'Output only JSON with a transactions array...'},
|
| 149 |
+
{'role':'user','content':'500 rs on beer 50 rs on candy'},
|
| 150 |
+
], temperature=0)['choices'][0]['message']['content'])
|
| 151 |
+
"
|
| 152 |
+
```
|
| 153 |
+
|
| 154 |
+
## Training details
|
| 155 |
+
|
| 156 |
+
- **Base model**: `unsloth/gemma-3-270m-it`
|
| 157 |
+
- **Method**: QLoRA via Unsloth (`r=32`, `α=64`, dropout 0.0, all linear targets)
|
| 158 |
+
- **Train data**: 29,890 teacher-labeled examples (`data/distill/train.jsonl`)
|
| 159 |
+
generated by a fine-tuned Gemma 4 E2B teacher
|
| 160 |
+
- **Epochs**: 2
|
| 161 |
+
- **Effective batch**: 128 (A100) / 16 (5060 Ti)
|
| 162 |
+
- **Optimizer**: AdamW 8-bit, cosine LR, peak 2e-4, warmup 3%
|
| 163 |
+
- **Final eval loss**: 0.099 (eval set: 300 hand-curated examples)
|
| 164 |
+
- **GGUF conversion**: raw `llama.cpp/convert_hf_to_gguf.py` (NOT Unsloth's wrapper),
|
| 165 |
+
preserves BOS token in chat template
|
| 166 |
+
- **Hardware**: A100-SXM4-80GB, ~25 min total training time at batch 128
|
| 167 |
+
|
| 168 |
+
Code, dataset generation, evaluation, and conversion scripts:
|
| 169 |
+
https://github.com/kartikeychoudhary/txn-parser
|
| 170 |
+
|
| 171 |
+
## Categories enum
|
| 172 |
+
|
| 173 |
+
`Food, Drinks, Groceries, Transport, Shopping, Entertainment, Bills, Health, Education, Personal, Gifts, Income, Other`
|
| 174 |
+
|
| 175 |
+
## License
|
| 176 |
+
|
| 177 |
+
Apache-2.0 (matches base model). The training data is synthetic and
|
| 178 |
+
released under the same license.
|
| 179 |
+
|
| 180 |
+
## Citation
|
| 181 |
+
|
| 182 |
+
```
|
| 183 |
+
@software{txn-parser-2026,
|
| 184 |
+
author = {Kartikey Choudhary},
|
| 185 |
+
title = {Transaction Parser: Voice-to-JSON distilled model},
|
| 186 |
+
year = {2026},
|
| 187 |
+
url = {https://huggingface.co/kartikey31/txn-parser},
|
| 188 |
+
note = {Gemma 3 270M, distilled from Gemma 4 E2B teacher},
|
| 189 |
+
}
|
| 190 |
+
```
|