File size: 5,335 Bytes
3a775cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
126
127
128
129
130
131
132
133
134
---
license: gemma
base_model: google/functiongemma-270m-it
tags:
  - function-calling
  - finance
  - sms-parsing
  - transaction-extraction
  - gguf
  - llama-cpp
language:
  - en
pipeline_tag: text-generation
library_name: transformers
---

# FunctionGemma Bank SMS Parser

A fine-tuned [FunctionGemma-270M-IT](https://huggingface.co/google/functiongemma-270m-it) model for extracting structured transaction data from bank SMS messages.

## Model Description

This model is trained to perform two functions:

1. **`extract_transaction`** - Parse banking SMS and extract structured fields:
   - `source`: Bank or sender name
   - `currency`: Currency code (INR, USD, etc.)
   - `amount`: Transaction amount (number)
   - `date`: Transaction date
   - `destination`: Recipient or merchant
   - `type`: "debit" or "credit"

2. **`skip_message`** - Identify non-transaction messages:
   - OTPs and verification codes
   - Promotional messages
   - Payment requests (not completed transactions)
   - Account alerts without transactions

## Quantization Options

| File | Quantization | Size | Description |
|------|--------------|------|-------------|
| `functiongemma-270m-bank-sms-parser-Q4_K_M.gguf` | Q4_K_M | ~242MB | **Recommended** - Best size/quality tradeoff |
| `functiongemma-270m-bank-sms-parser-Q5_K_M.gguf` | Q5_K_M | ~248MB | Higher quality if Q4 shows issues |
| `functiongemma-270m-bank-sms-parser-Q8_0.gguf` | Q8_0 | ~280MB | Near-lossless, for validation |

## Usage

### With llama.cpp server

```bash
# Download model
huggingface-cli download kartikaybagla/functiongemma-bank-sms-parser \
    functiongemma-270m-bank-sms-parser-Q4_K_M.gguf \
    --local-dir ./models

# Run server
llama-server --model ./models/functiongemma-270m-bank-sms-parser-Q4_K_M.gguf \
    --host 0.0.0.0 --port 8080 --ctx-size 2048
```

### With Docker

```bash
docker run -p 8080:8080 -v ./models:/models \
    ghcr.io/ggml-org/llama.cpp:server \
    --model /models/functiongemma-270m-bank-sms-parser-Q4_K_M.gguf \
    --host 0.0.0.0 --port 8080
```

### API Request

```bash
curl http://localhost:8080/v1/completions \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "<bos><start_of_turn>developer\nYou are a financial transaction extractor. Analyze SMS messages and:\n1. If the message describes a completed financial transaction (money sent, received, debited, or credited), use extract_transaction to capture the details.\n2. If the message is not a transaction (OTP, promotional, application status, payment request, etc.), use skip_message.\n\nOnly extract actual completed transactions with concrete amounts, not payment requests or pending transactions.<start_function_declaration>declaration:extract_transaction{description:<escape>Extract transaction details from a banking SMS message<escape>,parameters:{properties:{source:{type:<escape>STRING<escape>},currency:{type:<escape>STRING<escape>},amount:{type:<escape>NUMBER<escape>},date:{type:<escape>STRING<escape>},destination:{type:<escape>STRING<escape>},type:{type:<escape>STRING<escape>}},required:[<escape>source<escape>,<escape>currency<escape>,<escape>amount<escape>,<escape>date<escape>,<escape>destination<escape>,<escape>type<escape>],type:<escape>OBJECT<escape>}}<end_function_declaration><start_function_declaration>declaration:skip_message{description:<escape>Skip messages that are not financial transactions<escape>,parameters:{properties:{reason:{type:<escape>STRING<escape>}},required:[<escape>reason<escape>],type:<escape>OBJECT<escape>}}<end_function_declaration><end_of_turn>\n<start_of_turn>user\nICICI Bank Acct XX123 debited Rs 450.00 on 15-Jan-25; UPI to SWIGGY. UPI Ref: 123456789012<end_of_turn>\n<start_of_turn>model\n",
    "max_tokens": 200,
    "stop": ["<end_function_call>"]
  }'
```

### Example Output

**Input SMS:**
```
ICICI Bank Acct XX123 debited Rs 450.00 on 15-Jan-25; UPI to SWIGGY. UPI Ref: 123456789012
```

**Model Output:**
```
<start_function_call>extract_transaction{"source": "ICICI Bank", "currency": "INR", "amount": 450.00, "date": "15-Jan-25", "destination": "SWIGGY", "type": "debit"}<end_function_call>
```

**Input SMS (non-transaction):**
```
Your OTP for login is 482910. Valid for 5 minutes. Do not share.
```

**Model Output:**
```
<start_function_call>skip_message{"reason": "OTP verification code"}<end_function_call>
```

## Training

- **Base Model**: [google/functiongemma-270m-it](https://huggingface.co/google/functiongemma-270m-it)
- **Training Framework**: Hugging Face TRL (SFTTrainer)
- **Training Data**: Classified bank SMS messages from Indian banks
- **Fine-tuning Method**: LoRA

## Intended Use

This model is designed for:
- Personal finance automation
- Importing transactions into budgeting apps (e.g., Actual Budget)
- SMS-based expense tracking

## Limitations

- Primarily trained on Indian bank SMS formats (ICICI, HDFC, SBI, etc.)
- May not generalize well to banks from other countries
- Requires the specific prompt format shown above
- Not suitable for security-critical applications without additional validation

## License

This model inherits the [Gemma license](https://ai.google.dev/gemma/terms) from the base model.

## Links

- [Project Repository](https://github.com/kartikaybagla/bank-sms-parsing)
- [Base Model](https://huggingface.co/google/functiongemma-270m-it)