nick-cirillo commited on
Commit
5b58d01
·
verified ·
1 Parent(s): 7097e98

push model

Browse files
README.md ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ library_name: transformers
6
+ tags:
7
+ - finance
8
+ - aspect-classification
9
+ - absa
10
+ - finbert
11
+ - text-classification
12
+ datasets:
13
+ - pauri32/fiqa-2018
14
+ base_model: ProsusAI/finbert
15
+ metrics:
16
+ - accuracy
17
+ - f1
18
+ pipeline_tag: text-classification
19
+ ---
20
+
21
+ # ABSA-FinBERT: Aspect Classification for Financial Text
22
+
23
+ This model classifies financial headlines and tweets into four aspect categories: **Corporate**, **Economy**, **Market**, and **Stock**.
24
+
25
+ ## Model Description
26
+
27
+ ABSA-FinBERT is a fine-tuned version of [ProsusAI/finbert](https://huggingface.co/ProsusAI/finbert) for Level-1 aspect classification on the FiQA dataset. The model was trained with class-weighted cross-entropy loss to address extreme class imbalance in the training data.
28
+
29
+ This work is motivated by [Yang et al. (2018)](https://arxiv.org/abs/1808.07931), "Financial Aspect-Based Sentiment Analysis using Deep Representations," which demonstrated that financial text often contains multi-dimensional information requiring aspect-level analysis.
30
+
31
+ ## Intended Use
32
+
33
+ - Classifying financial news headlines by topic/aspect
34
+ - Preprocessing step for aspect-based sentiment analysis pipelines
35
+ - Financial text categorization
36
+
37
+ ## Training Data
38
+
39
+ Trained on the [FiQA dataset](https://huggingface.co/datasets/pauri32/fiqa-2018) (WWW'18 Open Challenge), with Level-1 aspect labels extracted from hierarchical annotations.
40
+
41
+ | Aspect | Training Examples | Percentage |
42
+ |--------|-------------------|------------|
43
+ | Stock | 562 | 58.5% |
44
+ | Corporate | 367 | 38.2% |
45
+ | Market | 26 | 2.7% |
46
+ | Economy | 4 | 0.4% |
47
+
48
+ ### Class Weights Applied
49
+ Due to extreme imbalance, inverse frequency weights were used: Corporate (0.65), Economy (59.94), Market (9.22), Stock (0.43).
50
+
51
+ ## Performance
52
+
53
+ | Metric | Score |
54
+ |--------|-------|
55
+ | Accuracy | 88.59% |
56
+ | Macro-F1 | 0.5429 |
57
+ | Weighted-F1 | 0.8688 |
58
+
59
+ ### Per-Class Results
60
+
61
+ | Aspect | Precision | Recall | F1-Score | Support |
62
+ |--------|-----------|--------|----------|---------|
63
+ | Corporate | 0.91 | 0.94 | 0.92 | 64 |
64
+ | Economy | 0.00 | 0.00 | 0.00 | 3 |
65
+ | Market | 0.50 | 0.25 | 0.33 | 8 |
66
+ | Stock | 0.89 | 0.95 | 0.92 | 74 |
67
+
68
+ **Note:** The model performs well on majority classes but fails on Economy due to having only 4 training examples. Class weighting cannot overcome severe data scarcity.
69
+
70
+ ## Usage
71
+
72
+ ```python
73
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
74
+ import torch
75
+
76
+ tokenizer = AutoTokenizer.from_pretrained("your-username/absa-finbert")
77
+ model = AutoModelForSequenceClassification.from_pretrained("your-username/absa-finbert")
78
+
79
+ # Label mapping
80
+ id2label = {0: "Corporate", 1: "Economy", 2: "Market", 3: "Stock"}
81
+
82
+ # Example inference
83
+ text = "How Kraft-Heinz Merger Came Together in Speedy 10 Weeks"
84
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
85
+ outputs = model(**inputs)
86
+ prediction = torch.argmax(outputs.logits, dim=-1).item()
87
+
88
+ print(f"Aspect: {id2label[prediction]}") # Output: Corporate
89
+ ```
90
+
91
+ ## Training Procedure
92
+
93
+ - **Base model:** ProsusAI/finbert
94
+ - **Learning rate:** 3e-5
95
+ - **Batch size:** 16 (effective 32 with gradient accumulation)
96
+ - **Epochs:** 10 (early stopping patience: 3)
97
+ - **Loss:** Weighted cross-entropy
98
+ - **Optimizer:** AdamW with warmup (10%)
99
+ - **Mixed precision:** FP16
100
+
101
+ ## Limitations
102
+
103
+ - Economy class is effectively unlearnable with only 4 training examples
104
+ - Market class has limited representation (26 examples)
105
+ - Model is optimized for short financial headlines/tweets, not long-form text
106
+
107
+ ## Citation
108
+
109
+ If you use this model, please cite:
110
+
111
+ ```bibtex
112
+ @misc{absa-finbert-2025,
113
+ title={ABSA-FinBERT: Aspect Classification for Financial Text},
114
+ author={Cirillo, Nick and Memon, Suha and Truong, Kalen and Zhang, Bruce},
115
+ year={2025},
116
+ howpublished={\url{https://huggingface.co/your-username/absa-finbert}}
117
+ }
118
+ ```
119
+
120
+ ## References
121
+
122
+ - Yang, S., Rosenfeld, J., & Makutonin, J. (2018). Financial Aspect-Based Sentiment Analysis using Deep Representations. arXiv:1808.07931.
123
+ - Araci, D. (2019). FinBERT: Financial Sentiment Analysis with Pre-trained Language Models. arXiv:1908.10063.
124
+ - Maia, M., et al. (2018). WWW'18 Open Challenge: Financial Opinion Mining and Question Answering.
config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertForSequenceClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.2,
6
+ "classifier_dropout": null,
7
+ "dtype": "float32",
8
+ "gradient_checkpointing": false,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.2,
11
+ "hidden_size": 768,
12
+ "id2label": {
13
+ "0": "positive",
14
+ "1": "negative",
15
+ "2": "neutral"
16
+ },
17
+ "initializer_range": 0.02,
18
+ "intermediate_size": 3072,
19
+ "label2id": {
20
+ "negative": 1,
21
+ "neutral": 2,
22
+ "positive": 0
23
+ },
24
+ "layer_norm_eps": 1e-12,
25
+ "max_position_embeddings": 512,
26
+ "model_type": "bert",
27
+ "num_attention_heads": 12,
28
+ "num_hidden_layers": 12,
29
+ "pad_token_id": 0,
30
+ "position_embedding_type": "absolute",
31
+ "transformers_version": "4.57.3",
32
+ "type_vocab_size": 2,
33
+ "use_cache": true,
34
+ "vocab_size": 30522
35
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e0bbf9021d3af08672e7b0a911621662602736ff6d408035dfeb5e5e62749a5c
3
+ size 437961724
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,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": true,
45
+ "cls_token": "[CLS]",
46
+ "do_basic_tokenize": true,
47
+ "do_lower_case": true,
48
+ "extra_special_tokens": {},
49
+ "mask_token": "[MASK]",
50
+ "model_max_length": 512,
51
+ "never_split": null,
52
+ "pad_token": "[PAD]",
53
+ "sep_token": "[SEP]",
54
+ "strip_accents": null,
55
+ "tokenize_chinese_chars": true,
56
+ "tokenizer_class": "BertTokenizer",
57
+ "unk_token": "[UNK]"
58
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff