初始化项目,由ModelHub XC社区提供模型

Model: kartikey31/txn-parser
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-08-09 01:23:21 +08:00
commit f70fa31854
39 changed files with 298378 additions and 0 deletions

152
smollm2-360m/README.md Normal file
View File

@@ -0,0 +1,152 @@
---
license: apache-2.0
base_model: HuggingFaceTB/SmolLM2-360M-Instruct
tags:
- text-generation
- lora
- qlora
- gguf
- transaction-parser
language:
- en
- hi
library_name: peft
---
# txn-parser / smollm2-360m
QLoRA fine-tune of [`HuggingFaceTB/SmolLM2-360M-Instruct`](https://huggingface.co/HuggingFaceTB/SmolLM2-360M-Instruct) 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 **`smollm2-360m/`** 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
- `smollm2-360m/adapters/` — PEFT LoRA adapter (rank 32). Load on top of the base model
with `peft.PeftModel.from_pretrained(base, "kartikey31/txn-parser", subfolder="smollm2-360m/adapters")`.
- `smollm2-360m/gguf/` — merged GGUF builds at multiple quantization levels
(file names follow `txn-parser-smollm2-360m-<QUANT>.gguf`):
- [`smollm2-360m/gguf/txn-parser-smollm2-360m-F16.gguf`](https://huggingface.co/kartikey31/txn-parser/resolve/main/smollm2-360m/gguf/txn-parser-smollm2-360m-F16.gguf) (725.6 MB)
- [`smollm2-360m/gguf/txn-parser-smollm2-360m-Q4_K_M.gguf`](https://huggingface.co/kartikey31/txn-parser/resolve/main/smollm2-360m/gguf/txn-parser-smollm2-360m-Q4_K_M.gguf) (270.6 MB)
- [`smollm2-360m/gguf/txn-parser-smollm2-360m-Q5_K_M.gguf`](https://huggingface.co/kartikey31/txn-parser/resolve/main/smollm2-360m/gguf/txn-parser-smollm2-360m-Q5_K_M.gguf) (289.9 MB)
- [`smollm2-360m/gguf/txn-parser-smollm2-360m-Q6_K.gguf`](https://huggingface.co/kartikey31/txn-parser/resolve/main/smollm2-360m/gguf/txn-parser-smollm2-360m-Q6_K.gguf) (367.4 MB)
- [`smollm2-360m/gguf/txn-parser-smollm2-360m-Q8_0.gguf`](https://huggingface.co/kartikey31/txn-parser/resolve/main/smollm2-360m/gguf/txn-parser-smollm2-360m-Q8_0.gguf) (386.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 | `HuggingFaceTB/SmolLM2-360M-Instruct` |
| Method | QLoRA (4-bit) via Unsloth |
| LoRA rank | 32 (alpha 64, dropout 0.0) |
| Epochs | 2 |
| Batch size (train) | 64 |
| Grad accumulation | 1 |
| Eval batch size | 16 |
| Max seq length | 1024 |
| Learning rate | 2e-4 (warmup 3%) |
| Started | 2026-05-22T21:26:43.776899+00:00 |
| Finished | 2026-05-22T21:30:14.660709+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 \
smollm2-360m/gguf/txn-parser-smollm2-360m-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-smollm2-360m-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-smollm2-360m-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 smollm2-360m
```
---
*Auto-published by `scripts/train_and_publish.py` on 2026-05-22T21:30:14.964463+00:00.*

View File

@@ -0,0 +1,210 @@
---
base_model: HuggingFaceTB/SmolLM2-360M-Instruct
library_name: peft
pipeline_tag: text-generation
tags:
- base_model:adapter:HuggingFaceTB/SmolLM2-360M-Instruct
- lora
- sft
- transformers
- trl
- unsloth
---
# Model Card for Model ID
<!-- Provide a quick summary of what the model is/does. -->
## Model Details
### Model Description
<!-- Provide a longer summary of what this model is. -->
- **Developed by:** [More Information Needed]
- **Funded by [optional]:** [More Information Needed]
- **Shared by [optional]:** [More Information Needed]
- **Model type:** [More Information Needed]
- **Language(s) (NLP):** [More Information Needed]
- **License:** [More Information Needed]
- **Finetuned from model [optional]:** [More Information Needed]
### Model Sources [optional]
<!-- Provide the basic links for the model. -->
- **Repository:** [More Information Needed]
- **Paper [optional]:** [More Information Needed]
- **Demo [optional]:** [More Information Needed]
## Uses
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
### Direct Use
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
[More Information Needed]
### Downstream Use [optional]
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
[More Information Needed]
### Out-of-Scope Use
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
[More Information Needed]
## Bias, Risks, and Limitations
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
[More Information Needed]
### Recommendations
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
## How to Get Started with the Model
Use the code below to get started with the model.
[More Information Needed]
## Training Details
### Training Data
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
[More Information Needed]
### Training Procedure
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
#### Preprocessing [optional]
[More Information Needed]
#### Training Hyperparameters
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
#### Speeds, Sizes, Times [optional]
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
[More Information Needed]
## Evaluation
<!-- This section describes the evaluation protocols and provides the results. -->
### Testing Data, Factors & Metrics
#### Testing Data
<!-- This should link to a Dataset Card if possible. -->
[More Information Needed]
#### Factors
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
[More Information Needed]
#### Metrics
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
[More Information Needed]
### Results
[More Information Needed]
#### Summary
## Model Examination [optional]
<!-- Relevant interpretability work for the model goes here -->
[More Information Needed]
## Environmental Impact
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
- **Hardware Type:** [More Information Needed]
- **Hours used:** [More Information Needed]
- **Cloud Provider:** [More Information Needed]
- **Compute Region:** [More Information Needed]
- **Carbon Emitted:** [More Information Needed]
## Technical Specifications [optional]
### Model Architecture and Objective
[More Information Needed]
### Compute Infrastructure
[More Information Needed]
#### Hardware
[More Information Needed]
#### Software
[More Information Needed]
## Citation [optional]
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
**BibTeX:**
[More Information Needed]
**APA:**
[More Information Needed]
## Glossary [optional]
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
[More Information Needed]
## More Information [optional]
[More Information Needed]
## Model Card Authors [optional]
[More Information Needed]
## Model Card Contact
[More Information Needed]
### Framework versions
- PEFT 0.19.1

View File

@@ -0,0 +1,52 @@
{
"alora_invocation_tokens": null,
"alpha_pattern": {},
"arrow_config": null,
"auto_mapping": {
"base_model_class": "LlamaForCausalLM",
"parent_library": "transformers.models.llama.modeling_llama",
"unsloth_fixed": true
},
"base_model_name_or_path": "HuggingFaceTB/SmolLM2-360M-Instruct",
"bias": "none",
"corda_config": null,
"ensure_weight_tying": false,
"eva_config": null,
"exclude_modules": null,
"fan_in_fan_out": false,
"inference_mode": true,
"init_lora_weights": true,
"layer_replication": null,
"layers_pattern": null,
"layers_to_transform": null,
"loftq_config": {},
"lora_alpha": 64,
"lora_bias": false,
"lora_dropout": 0.0,
"lora_ga_config": null,
"megatron_config": null,
"megatron_core": "megatron.core",
"modules_to_save": null,
"peft_type": "LORA",
"peft_version": "0.19.1",
"qalora_group_size": 16,
"r": 32,
"rank_pattern": {},
"revision": null,
"target_modules": [
"down_proj",
"v_proj",
"up_proj",
"k_proj",
"gate_proj",
"o_proj",
"q_proj"
],
"target_parameters": null,
"task_type": "CAUSAL_LM",
"trainable_token_indices": null,
"use_bdlora": null,
"use_dora": false,
"use_qalora": false,
"use_rslora": false
}

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9b4d482a8fd5bb463dd858f9d8b576759471cf800f45e12660cfc22090988dae
size 69527352

View File

@@ -0,0 +1,6 @@
{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system
You are a helpful AI assistant named SmolLM, trained by Hugging Face<|im_end|>
' }}{% endif %}{{'<|im_start|>' + message['role'] + '
' + message['content'] + '<|im_end|>' + '
'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant
' }}{% endif %}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,154 @@
{
"add_prefix_space": false,
"backend": "tokenizers",
"bos_token": "<|im_start|>",
"clean_up_tokenization_spaces": false,
"eos_token": "<|im_end|>",
"errors": "replace",
"extra_special_tokens": [],
"is_local": false,
"model_max_length": 8192,
"pad_token": "<|endoftext|>",
"padding_side": "left",
"tokenizer_class": "GPT2Tokenizer",
"unk_token": "<|endoftext|>",
"vocab_size": 49152,
"added_tokens_decoder": {
"0": {
"content": "<|endoftext|>",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": false,
"special": true
},
"1": {
"content": "<|im_start|>",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": false,
"special": true
},
"2": {
"content": "<|im_end|>",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": false,
"special": true
},
"3": {
"content": "<repo_name>",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": false,
"special": true
},
"4": {
"content": "<reponame>",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": false,
"special": true
},
"5": {
"content": "<file_sep>",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": false,
"special": true
},
"6": {
"content": "<filename>",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": false,
"special": true
},
"7": {
"content": "<gh_stars>",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": false,
"special": true
},
"8": {
"content": "<issue_start>",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": false,
"special": true
},
"9": {
"content": "<issue_comment>",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": false,
"special": true
},
"10": {
"content": "<issue_closed>",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": false,
"special": true
},
"11": {
"content": "<jupyter_start>",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": false,
"special": true
},
"12": {
"content": "<jupyter_text>",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": false,
"special": true
},
"13": {
"content": "<jupyter_code>",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": false,
"special": true
},
"14": {
"content": "<jupyter_output>",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": false,
"special": true
},
"15": {
"content": "<jupyter_script>",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": false,
"special": true
},
"16": {
"content": "<empty_output>",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": false,
"special": true
}
}
}

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:92b07b803de61d1fd4ec1297001bef5e60d0e6859d92e6faedbfa2d5acb4dbce
size 725553792

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6a4edeff22ebbb1eabc5ab89624f2ecd5202af034cea61fe0ccd422e4e586505
size 270590592

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:dc8df0629cc58887b569c77d9f12aea04f70dbfeaf57431b2eedd5c220ba9ba1
size 289944192

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:193c4b51e556101707420668b1df4770e32f13e7553fd1f6a12c877de3e99dec
size 367358592

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8a1714b9ae16ada16ea318342661ffbf9d73295d9f42b7c6e33bf10e3dd7af03
size 386404992