primel commited on
Commit
95c3971
·
verified ·
1 Parent(s): a7c8ede

Upload Transactor AIBA - Multilingual Banking Transaction NER Model

Browse files
README.md ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - ru
5
+ - multilingual
6
+ license: apache-2.0
7
+ tags:
8
+ - token-classification
9
+ - ner
10
+ - named-entity-recognition
11
+ - banking
12
+ - transactions
13
+ - financial
14
+ - multilingual
15
+ - bert
16
+ datasets:
17
+ - custom
18
+ metrics:
19
+ - precision
20
+ - recall
21
+ - f1
22
+ - seqeval
23
+ widget:
24
+ - text: "Transfer 12.5mln USD to Apex Industries account 27109477752047116719 INN 123456789 bank code 01234 for consulting"
25
+ - text: "Send 150k RUB to ООО Ромашка счет 40817810099910004312 ИНН 987654321 за услуги"
26
+ - text: "Show completed transactions from 01.12.2024 to 15.12.2024"
27
+ pipeline_tag: token-classification
28
+ ---
29
+
30
+ # Transactor AIBA - Banking Transaction NER Model
31
+
32
+ ## Model Description
33
+
34
+ **Transactor AIBA** is a multilingual Named Entity Recognition (NER) model fine-tuned on `google-bert/bert-base-multilingual-cased` for extracting entities from banking and financial transaction texts. The model supports both English and Russian languages.
35
+
36
+ ## Intended Use
37
+
38
+ This model is designed to extract key entities from banking transaction requests, including:
39
+ - Transaction amounts and currencies
40
+ - Account numbers and bank codes
41
+ - Tax identification numbers (INN)
42
+ - Recipient/sender information
43
+ - Transaction purposes
44
+ - Dates and time periods
45
+
46
+ ## Entity Types
47
+
48
+ The model recognizes the following entity types:
49
+
50
+ - `amount`
51
+ - `bank_code`
52
+ - `currency`
53
+ - `date`
54
+ - `description`
55
+ - `end_date`
56
+ - `receiver_hr`
57
+ - `receiver_inn`
58
+ - `receiver_name`
59
+ - `start_date`
60
+ - `status`
61
+
62
+ ## Training Data
63
+
64
+ - **Base Model**: `google-bert/bert-base-multilingual-cased`
65
+ - **Training Samples**: 200,015
66
+ - **Validation Samples**: 35,297
67
+ - **Dataset**: Custom banking transaction dataset with multilingual support
68
+
69
+ ## Training Details
70
+
71
+ - **Epochs**: 5
72
+ - **Batch Size**: 16
73
+ - **Learning Rate**: 2e-5
74
+ - **Optimizer**: AdamW
75
+ - **LR Scheduler**: Linear with warmup
76
+ - **Framework**: Transformers + PyTorch
77
+
78
+ ## Performance
79
+
80
+ - **Validation F1 Score**: 0.9999
81
+
82
+ ## Usage
83
+
84
+ ```python
85
+ from transformers import AutoTokenizer, AutoModelForTokenClassification
86
+ import torch
87
+
88
+ # Load model and tokenizer
89
+ model_name = "primel/transactor-aiba"
90
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
91
+ model = AutoModelForTokenClassification.from_pretrained(model_name)
92
+
93
+ # Example prediction
94
+ def extract_entities(text):
95
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
96
+
97
+ with torch.no_grad():
98
+ outputs = model(**inputs)
99
+ predictions = torch.argmax(outputs.logits, dim=2)
100
+
101
+ tokens = tokenizer.convert_ids_to_tokens(inputs['input_ids'][0])
102
+ predicted_labels = [model.config.id2label[pred.item()] for pred in predictions[0]]
103
+
104
+ entities = {}
105
+ current_entity = None
106
+ current_tokens = []
107
+
108
+ for token, label in zip(tokens, predicted_labels):
109
+ if token in ['[CLS]', '[SEP]', '[PAD]']:
110
+ continue
111
+
112
+ if label.startswith('B-'):
113
+ if current_entity and current_tokens:
114
+ entity_text = tokenizer.convert_tokens_to_string(current_tokens)
115
+ entities[current_entity] = entity_text.strip()
116
+ current_entity = label[2:]
117
+ current_tokens = [token]
118
+ elif label.startswith('I-') and current_entity == label[2:]:
119
+ current_tokens.append(token)
120
+ else:
121
+ if current_entity and current_tokens:
122
+ entity_text = tokenizer.convert_tokens_to_string(current_tokens)
123
+ entities[current_entity] = entity_text.strip()
124
+ current_entity = None
125
+ current_tokens = []
126
+
127
+ if current_entity and current_tokens:
128
+ entity_text = tokenizer.convert_tokens_to_string(current_tokens)
129
+ entities[current_entity] = entity_text.strip()
130
+
131
+ return entities
132
+
133
+ # Example
134
+ text = "Transfer 12.5mln USD to Apex Industries account 27109477752047116719"
135
+ print(extract_entities(text))
136
+ ```
137
+
138
+ ## Example Outputs
139
+
140
+ **Input**: "Transfer 12.5mln USD to Apex Industries account 27109477752047116719 INN 123456789 bank code 01234 for consulting"
141
+
142
+ **Output**:
143
+ ```python
144
+ {
145
+ "amount": "12.5mln",
146
+ "currency": "USD",
147
+ "receiver_name": "Apex Industries",
148
+ "receiver_hr": "27109477752047116719",
149
+ "receiver_inn": "123456789",
150
+ "receiver_bank_code": "01234",
151
+ "purpose": "consulting"
152
+ }
153
+ ```
154
+
155
+ ## Limitations
156
+
157
+ - The model is trained on synthetic and curated banking transaction data
158
+ - Performance may vary on real-world data with different formatting
159
+ - Best results are achieved with transaction texts similar to training distribution
160
+ - May require fine-tuning for specific banking systems or regional variations
161
+
162
+ ## License
163
+
164
+ Apache 2.0
165
+
166
+ ## Citation
167
+
168
+ ```bibtex
169
+ @misc{transactor-aiba,
170
+ author = {Primel},
171
+ title = {Transactor AIBA: Multilingual Banking Transaction NER},
172
+ year = {2025},
173
+ publisher = {Hugging Face},
174
+ howpublished = {\url{https://huggingface.co/primel/transactor-aiba}}
175
+ }
176
+ ```
config.json ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertForTokenClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "classifier_dropout": null,
7
+ "directionality": "bidi",
8
+ "dtype": "float32",
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 768,
12
+ "id2label": {
13
+ "0": "B-amount",
14
+ "1": "B-bank_code",
15
+ "2": "B-currency",
16
+ "3": "B-date",
17
+ "4": "B-description",
18
+ "5": "B-end_date",
19
+ "6": "B-receiver_hr",
20
+ "7": "B-receiver_inn",
21
+ "8": "B-receiver_name",
22
+ "9": "B-start_date",
23
+ "10": "B-status",
24
+ "11": "I-amount",
25
+ "12": "I-bank_code",
26
+ "13": "I-currency",
27
+ "14": "I-date",
28
+ "15": "I-description",
29
+ "16": "I-end_date",
30
+ "17": "I-receiver_hr",
31
+ "18": "I-receiver_inn",
32
+ "19": "I-receiver_name",
33
+ "20": "I-start_date",
34
+ "21": "I-status",
35
+ "22": "O"
36
+ },
37
+ "initializer_range": 0.02,
38
+ "intermediate_size": 3072,
39
+ "label2id": {
40
+ "B-amount": 0,
41
+ "B-bank_code": 1,
42
+ "B-currency": 2,
43
+ "B-date": 3,
44
+ "B-description": 4,
45
+ "B-end_date": 5,
46
+ "B-receiver_hr": 6,
47
+ "B-receiver_inn": 7,
48
+ "B-receiver_name": 8,
49
+ "B-start_date": 9,
50
+ "B-status": 10,
51
+ "I-amount": 11,
52
+ "I-bank_code": 12,
53
+ "I-currency": 13,
54
+ "I-date": 14,
55
+ "I-description": 15,
56
+ "I-end_date": 16,
57
+ "I-receiver_hr": 17,
58
+ "I-receiver_inn": 18,
59
+ "I-receiver_name": 19,
60
+ "I-start_date": 20,
61
+ "I-status": 21,
62
+ "O": 22
63
+ },
64
+ "layer_norm_eps": 1e-12,
65
+ "max_position_embeddings": 512,
66
+ "model_type": "bert",
67
+ "num_attention_heads": 12,
68
+ "num_hidden_layers": 12,
69
+ "pad_token_id": 0,
70
+ "pooler_fc_size": 768,
71
+ "pooler_num_attention_heads": 12,
72
+ "pooler_num_fc_layers": 3,
73
+ "pooler_size_per_head": 128,
74
+ "pooler_type": "first_token_transform",
75
+ "position_embedding_type": "absolute",
76
+ "transformers_version": "4.57.1",
77
+ "type_vocab_size": 2,
78
+ "use_cache": true,
79
+ "vocab_size": 119547
80
+ }
label_mapping.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "tag2id": {
3
+ "B-amount": 0,
4
+ "B-bank_code": 1,
5
+ "B-currency": 2,
6
+ "B-date": 3,
7
+ "B-description": 4,
8
+ "B-end_date": 5,
9
+ "B-receiver_hr": 6,
10
+ "B-receiver_inn": 7,
11
+ "B-receiver_name": 8,
12
+ "B-start_date": 9,
13
+ "B-status": 10,
14
+ "I-amount": 11,
15
+ "I-bank_code": 12,
16
+ "I-currency": 13,
17
+ "I-date": 14,
18
+ "I-description": 15,
19
+ "I-end_date": 16,
20
+ "I-receiver_hr": 17,
21
+ "I-receiver_inn": 18,
22
+ "I-receiver_name": 19,
23
+ "I-start_date": 20,
24
+ "I-status": 21,
25
+ "O": 22
26
+ },
27
+ "id2tag": {
28
+ "0": "B-amount",
29
+ "1": "B-bank_code",
30
+ "2": "B-currency",
31
+ "3": "B-date",
32
+ "4": "B-description",
33
+ "5": "B-end_date",
34
+ "6": "B-receiver_hr",
35
+ "7": "B-receiver_inn",
36
+ "8": "B-receiver_name",
37
+ "9": "B-start_date",
38
+ "10": "B-status",
39
+ "11": "I-amount",
40
+ "12": "I-bank_code",
41
+ "13": "I-currency",
42
+ "14": "I-date",
43
+ "15": "I-description",
44
+ "16": "I-end_date",
45
+ "17": "I-receiver_hr",
46
+ "18": "I-receiver_inn",
47
+ "19": "I-receiver_name",
48
+ "20": "I-start_date",
49
+ "21": "I-status",
50
+ "22": "O"
51
+ }
52
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4b1f78ffa7bcf7a93fcdb56fda925503257074b7ba3ef383e047d934c940d4f9
3
+ size 709145500
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": false,
45
+ "cls_token": "[CLS]",
46
+ "do_lower_case": false,
47
+ "extra_special_tokens": {},
48
+ "mask_token": "[MASK]",
49
+ "model_max_length": 512,
50
+ "pad_token": "[PAD]",
51
+ "sep_token": "[SEP]",
52
+ "strip_accents": null,
53
+ "tokenize_chinese_chars": true,
54
+ "tokenizer_class": "BertTokenizer",
55
+ "unk_token": "[UNK]"
56
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d41dd6c606f9b015995295fdb80c0ab243a2ace6beec1bde55e410d7efa85a40
3
+ size 5777
training_config.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_name": "google-bert/bert-base-multilingual-cased",
3
+ "num_train_samples": 200015,
4
+ "num_val_samples": 35297,
5
+ "num_epochs": 5,
6
+ "batch_size": 16,
7
+ "validation_f1": 0.9998642818660011
8
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff