Update README.md
Browse files
README.md
CHANGED
|
@@ -7,4 +7,71 @@ metrics:
|
|
| 7 |
base_model:
|
| 8 |
- google-bert/bert-base-uncased
|
| 9 |
pipeline_tag: text-classification
|
| 10 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
base_model:
|
| 8 |
- google-bert/bert-base-uncased
|
| 9 |
pipeline_tag: text-classification
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# Fine-Tuned BERT for Transaction Categorization
|
| 13 |
+
|
| 14 |
+
This is a fine-tuned [BERT model](https://huggingface.co/transformers/model_doc/bert.html) specifically trained to categorize financial transactions into predefined categories. The model was trained on a dataset of English transaction descriptions to classify them into categories like "Groceries," "Transport," "Entertainment," and more.
|
| 15 |
+
|
| 16 |
+
## Model Details
|
| 17 |
+
|
| 18 |
+
- **Base Model**: [bert-base-uncased](https://huggingface.co/bert-base-uncased).
|
| 19 |
+
- **Fine-Tuning Task**: Transaction Categorization (multi-class classification).
|
| 20 |
+
- **Languages**: English.
|
| 21 |
+
|
| 22 |
+
### Example Categories
|
| 23 |
+
The model classifies transactions into categories such as:
|
| 24 |
+
```python
|
| 25 |
+
CATEGORIES = {
|
| 26 |
+
|
| 27 |
+
0: "Utilities",
|
| 28 |
+
1: "Health",
|
| 29 |
+
2: "Dining",
|
| 30 |
+
3: "Travel",
|
| 31 |
+
4: "Education",
|
| 32 |
+
5: "Subscription",
|
| 33 |
+
6: "Family",
|
| 34 |
+
7: "Food",
|
| 35 |
+
8: "Festivals",
|
| 36 |
+
9: "Culture",
|
| 37 |
+
10: "Apparel",
|
| 38 |
+
11: "Transportation",
|
| 39 |
+
12: "Investment",
|
| 40 |
+
13: "Shopping",
|
| 41 |
+
14: "Groceries",
|
| 42 |
+
15: "Documents",
|
| 43 |
+
16: "Grooming",
|
| 44 |
+
17: "Entertainment",
|
| 45 |
+
18: "Social Life",
|
| 46 |
+
19: "Beauty",
|
| 47 |
+
20: "Rent",
|
| 48 |
+
21: "Money transfer",
|
| 49 |
+
22: "Salary",
|
| 50 |
+
23: "Tourism",
|
| 51 |
+
24: "Household",
|
| 52 |
+
}
|
| 53 |
+
```
|
| 54 |
+
---
|
| 55 |
+
|
| 56 |
+
## How to Use the Model
|
| 57 |
+
|
| 58 |
+
To use this model, you can load it directly with Hugging Face's `transformers` library:
|
| 59 |
+
|
| 60 |
+
```python
|
| 61 |
+
from transformers import BertTokenizer, BertForSequenceClassification
|
| 62 |
+
|
| 63 |
+
# Load the model
|
| 64 |
+
model_name = "kuro-08/bert-transaction-categorization"
|
| 65 |
+
tokenizer = BertTokenizer.from_pretrained(model_name)
|
| 66 |
+
model = BertForSequenceClassification.from_pretrained(model_name)
|
| 67 |
+
|
| 68 |
+
# Sample transaction description
|
| 69 |
+
transaction = "Transaction: Payment at Starbucks for coffee - Type: income/expense"
|
| 70 |
+
inputs = tokenizer(transaction, return_tensors="pt", truncation=True, padding=True)
|
| 71 |
+
|
| 72 |
+
# Predict the category
|
| 73 |
+
outputs = model(**inputs)
|
| 74 |
+
logits = outputs.logits
|
| 75 |
+
predicted_category = logits.argmax(-1).item()
|
| 76 |
+
|
| 77 |
+
print(f"Predicted category: {predicted_category}")
|