Askinkaty commited on
Commit
12543cc
·
verified ·
1 Parent(s): e814a0e

Upload 13 files

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 384,
3
+ "pooling_mode_cls_token": false,
4
+ "pooling_mode_mean_tokens": true,
5
+ "pooling_mode_max_tokens": false,
6
+ "pooling_mode_mean_sqrt_len_tokens": false,
7
+ "pooling_mode_weightedmean_tokens": false,
8
+ "pooling_mode_lasttoken": false,
9
+ "include_prompt": true
10
+ }
README.md CHANGED
@@ -1,3 +1,268 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - setfit
4
+ - absa
5
+ - sentence-transformers
6
+ - text-classification
7
+ - generated_from_setfit_trainer
8
+ widget:
9
+ - text: Edelweiss:Downgrade Wipro to 'Hold', says Edelweiss
10
+ - text: Overweight:Morgan Stanley upgrades Axis Bank to Overweight; ups target price
11
+ - text: 'downside:Expect more downside in the IT, pharma stocks: Sandeep Wagle'
12
+ - text: 'Barclays:Infusion of additional $1 trillion to India''s GDP to create new
13
+ midcap leaders: Barclays'
14
+ - text: focus:Jaypee, Reliance Group stocks in focus ahead of UP results
15
+ metrics:
16
+ - accuracy
17
+ pipeline_tag: text-classification
18
+ library_name: setfit
19
+ inference: false
20
+ base_model: sentence-transformers/all-MiniLM-L6-v2
21
+ ---
22
+
23
+ # SetFit Aspect Model with sentence-transformers/all-MiniLM-L6-v2
24
+
25
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Aspect Based Sentiment Analysis (ABSA). This SetFit model uses [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) as the Sentence Transformer embedding model. A [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance is used for classification. In particular, this model is in charge of filtering aspect span candidates.
26
+
27
+ The model has been trained using an efficient few-shot learning technique that involves:
28
+
29
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
30
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
31
+
32
+ This model was trained within the context of a larger system for ABSA, which looks like so:
33
+
34
+ 1. Use a spaCy model to select possible aspect span candidates.
35
+ 2. **Use this SetFit model to filter these possible aspect span candidates.**
36
+ 3. Use a SetFit model to classify the filtered aspect span candidates.
37
+
38
+ ## Model Details
39
+
40
+ ### Model Description
41
+ - **Model Type:** SetFit
42
+ - **Sentence Transformer body:** [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)
43
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
44
+ - **spaCy Model:** en_core_web_sm
45
+ - **SetFitABSA Aspect Model:** [/scratch/project_2006600/fin_experiment/models/setfit-finance-aspect](https://huggingface.co//scratch/project_2006600/fin_experiment/models/setfit-finance-aspect)
46
+ - **SetFitABSA Polarity Model:** [/scratch/project_2006600/fin_experiment/models/setfit-finance-polarity](https://huggingface.co//scratch/project_2006600/fin_experiment/models/setfit-finance-polarity)
47
+ - **Maximum Sequence Length:** 256 tokens
48
+ - **Number of Classes:** 2 classes
49
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
50
+ <!-- - **Language:** Unknown -->
51
+ <!-- - **License:** Unknown -->
52
+
53
+ ### Model Sources
54
+
55
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
56
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
57
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
58
+
59
+ ### Model Labels
60
+ | Label | Examples |
61
+ |:----------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
62
+ | aspect | <ul><li>'Sebi:Ponzi schemes: Sebi seeks quarterly meetings of state panels'</li><li>'Vodafone:European shares steady, pegged back by Vodafone'</li><li>'European shares:European shares steady, pegged back by Vodafone'</li></ul> |
63
+ | no aspect | <ul><li>'Ponzi schemes:Ponzi schemes: Sebi seeks quarterly meetings of state panels'</li><li>'meetings:Ponzi schemes: Sebi seeks quarterly meetings of state panels'</li><li>'state panels:Ponzi schemes: Sebi seeks quarterly meetings of state panels'</li></ul> |
64
+
65
+ ## Uses
66
+
67
+ ### Direct Use for Inference
68
+
69
+ First install the SetFit library:
70
+
71
+ ```bash
72
+ pip install setfit
73
+ ```
74
+
75
+ Then you can load this model and run inference.
76
+
77
+ ```python
78
+ from setfit import AbsaModel
79
+
80
+ # Download from the 🤗 Hub
81
+ model = AbsaModel.from_pretrained(
82
+ "/scratch/project_2006600/fin_experiment/models/setfit-finance-aspect",
83
+ "/scratch/project_2006600/fin_experiment/models/setfit-finance-polarity",
84
+ )
85
+ # Run inference
86
+ preds = model("The food was great, but the venue is just way too busy.")
87
+ ```
88
+
89
+ <!--
90
+ ### Downstream Use
91
+
92
+ *List how someone could finetune this model on their own dataset.*
93
+ -->
94
+
95
+ <!--
96
+ ### Out-of-Scope Use
97
+
98
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
99
+ -->
100
+
101
+ <!--
102
+ ## Bias, Risks and Limitations
103
+
104
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
105
+ -->
106
+
107
+ <!--
108
+ ### Recommendations
109
+
110
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
111
+ -->
112
+
113
+ ## Training Details
114
+
115
+ ### Training Set Metrics
116
+ | Training set | Min | Median | Max |
117
+ |:-------------|:----|:--------|:----|
118
+ | Word count | 4 | 10.9446 | 24 |
119
+
120
+ | Label | Training Sample Count |
121
+ |:----------|:----------------------|
122
+ | no aspect | 3387 |
123
+ | aspect | 1988 |
124
+
125
+ ### Training Hyperparameters
126
+ - batch_size: (64, 64)
127
+ - num_epochs: (2, 2)
128
+ - max_steps: -1
129
+ - sampling_strategy: oversampling
130
+ - body_learning_rate: (2e-05, 1e-05)
131
+ - head_learning_rate: 0.01
132
+ - loss: CosineSimilarityLoss
133
+ - distance_metric: cosine_distance
134
+ - margin: 0.25
135
+ - end_to_end: False
136
+ - use_amp: True
137
+ - warmup_proportion: 0.1
138
+ - l2_weight: 0.01
139
+ - seed: 42
140
+ - eval_max_steps: -1
141
+ - load_best_model_at_end: True
142
+
143
+ ### Training Results
144
+ | Epoch | Step | Training Loss | Validation Loss |
145
+ |:------:|:----:|:-------------:|:---------------:|
146
+ | 0.0000 | 1 | 0.3294 | - |
147
+ | 0.0004 | 50 | 0.3505 | - |
148
+ | 0.0008 | 100 | 0.3428 | 0.3418 |
149
+ | 0.0012 | 150 | 0.3407 | - |
150
+ | 0.0017 | 200 | 0.3284 | 0.3288 |
151
+ | 0.0021 | 250 | 0.3232 | - |
152
+ | 0.0025 | 300 | 0.3092 | 0.3087 |
153
+ | 0.0029 | 350 | 0.3047 | - |
154
+ | 0.0033 | 400 | 0.2906 | 0.2849 |
155
+ | 0.0037 | 450 | 0.2782 | - |
156
+ | 0.0041 | 500 | 0.2695 | 0.2667 |
157
+ | 0.0046 | 550 | 0.2625 | - |
158
+ | 0.0050 | 600 | 0.2601 | 0.2574 |
159
+ | 0.0054 | 650 | 0.2541 | - |
160
+ | 0.0058 | 700 | 0.2554 | 0.2539 |
161
+ | 0.0062 | 750 | 0.2552 | - |
162
+ | 0.0066 | 800 | 0.2537 | 0.2529 |
163
+ | 0.0071 | 850 | 0.2555 | - |
164
+ | 0.0075 | 900 | 0.2544 | 0.2518 |
165
+ | 0.0079 | 950 | 0.2528 | - |
166
+ | 0.0083 | 1000 | 0.2536 | 0.2506 |
167
+ | 0.0087 | 1050 | 0.251 | - |
168
+ | 0.0091 | 1100 | 0.2508 | 0.2493 |
169
+ | 0.0095 | 1150 | 0.2504 | - |
170
+ | 0.0100 | 1200 | 0.2497 | 0.2480 |
171
+ | 0.0104 | 1250 | 0.2484 | - |
172
+ | 0.0108 | 1300 | 0.2476 | 0.2463 |
173
+ | 0.0112 | 1350 | 0.2468 | - |
174
+ | 0.0116 | 1400 | 0.2454 | 0.2440 |
175
+ | 0.0120 | 1450 | 0.245 | - |
176
+ | 0.0124 | 1500 | 0.2427 | 0.2409 |
177
+ | 0.0129 | 1550 | 0.2401 | - |
178
+ | 0.0133 | 1600 | 0.2412 | 0.2361 |
179
+ | 0.0137 | 1650 | 0.2373 | - |
180
+ | 0.0141 | 1700 | 0.2325 | 0.2279 |
181
+ | 0.0145 | 1750 | 0.2305 | - |
182
+ | 0.0149 | 1800 | 0.2245 | 0.2144 |
183
+ | 0.0153 | 1850 | 0.2186 | - |
184
+ | 0.0158 | 1900 | 0.2089 | 0.1916 |
185
+ | 0.0162 | 1950 | 0.1935 | - |
186
+ | 0.0166 | 2000 | 0.1761 | 0.1500 |
187
+ | 0.0170 | 2050 | 0.1477 | - |
188
+ | 0.0174 | 2100 | 0.1395 | 0.1287 |
189
+ | 0.0178 | 2150 | 0.1315 | - |
190
+ | 0.0183 | 2200 | 0.1231 | 0.1178 |
191
+ | 0.0187 | 2250 | 0.1172 | - |
192
+ | 0.0191 | 2300 | 0.1082 | 0.1085 |
193
+ | 0.0195 | 2350 | 0.1005 | - |
194
+ | 0.0199 | 2400 | 0.0999 | 0.1058 |
195
+ | 0.0203 | 2450 | 0.0881 | - |
196
+ | 0.0207 | 2500 | 0.0899 | 0.1009 |
197
+ | 0.0212 | 2550 | 0.0851 | - |
198
+ | 0.0216 | 2600 | 0.0829 | 0.0986 |
199
+ | 0.0220 | 2650 | 0.0779 | - |
200
+ | 0.0224 | 2700 | 0.0773 | 0.0968 |
201
+ | 0.0228 | 2750 | 0.0731 | - |
202
+ | 0.0232 | 2800 | 0.0687 | 0.0944 |
203
+ | 0.0236 | 2850 | 0.0673 | - |
204
+ | 0.0241 | 2900 | 0.0667 | 0.0934 |
205
+ | 0.0245 | 2950 | 0.0617 | - |
206
+ | 0.0249 | 3000 | 0.0619 | 0.0928 |
207
+ | 0.0253 | 3050 | 0.0577 | - |
208
+ | 0.0257 | 3100 | 0.0559 | 0.0927 |
209
+ | 0.0261 | 3150 | 0.0588 | - |
210
+ | 0.0265 | 3200 | 0.0557 | 0.0939 |
211
+ | 0.0270 | 3250 | 0.0526 | - |
212
+ | 0.0274 | 3300 | 0.0519 | 0.0913 |
213
+ | 0.0278 | 3350 | 0.0498 | - |
214
+ | 0.0282 | 3400 | 0.0454 | 0.0902 |
215
+ | 0.0286 | 3450 | 0.0442 | - |
216
+ | 0.0290 | 3500 | 0.0425 | 0.0892 |
217
+ | 0.0295 | 3550 | 0.0391 | - |
218
+ | 0.0299 | 3600 | 0.0369 | 0.0879 |
219
+ | 0.0303 | 3650 | 0.0384 | - |
220
+ | 0.0307 | 3700 | 0.033 | 0.0890 |
221
+ | 0.0311 | 3750 | 0.0341 | - |
222
+ | 0.0315 | 3800 | 0.0364 | 0.0896 |
223
+ | 0.0319 | 3850 | 0.0347 | - |
224
+ | 0.0324 | 3900 | 0.0321 | 0.0891 |
225
+
226
+ ### Framework Versions
227
+ - Python: 3.11.11
228
+ - SetFit: 1.1.0
229
+ - Sentence Transformers: 3.3.1
230
+ - spaCy: 3.7.5
231
+ - Transformers: 4.42.1
232
+ - PyTorch: 2.5.1+cu124
233
+ - Datasets: 3.2.0
234
+ - Tokenizers: 0.19.1
235
+
236
+ ## Citation
237
+
238
+ ### BibTeX
239
+ ```bibtex
240
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
241
+ doi = {10.48550/ARXIV.2209.11055},
242
+ url = {https://arxiv.org/abs/2209.11055},
243
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
244
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
245
+ title = {Efficient Few-Shot Learning Without Prompts},
246
+ publisher = {arXiv},
247
+ year = {2022},
248
+ copyright = {Creative Commons Attribution 4.0 International}
249
+ }
250
+ ```
251
+
252
+ <!--
253
+ ## Glossary
254
+
255
+ *Clearly define terms in order to be accessible across audiences.*
256
+ -->
257
+
258
+ <!--
259
+ ## Model Card Authors
260
+
261
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
262
+ -->
263
+
264
+ <!--
265
+ ## Model Card Contact
266
+
267
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
268
+ -->
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "sentence-transformers/all-MiniLM-L6-v2",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "gradient_checkpointing": false,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 384,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 1536,
14
+ "layer_norm_eps": 1e-12,
15
+ "max_position_embeddings": 512,
16
+ "model_type": "bert",
17
+ "num_attention_heads": 12,
18
+ "num_hidden_layers": 6,
19
+ "pad_token_id": 0,
20
+ "position_embedding_type": "absolute",
21
+ "torch_dtype": "float32",
22
+ "transformers_version": "4.42.1",
23
+ "type_vocab_size": 2,
24
+ "use_cache": true,
25
+ "vocab_size": 30522
26
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "3.3.1",
4
+ "transformers": "4.42.1",
5
+ "pytorch": "2.5.1+cu124"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null,
9
+ "similarity_fn_name": "cosine"
10
+ }
config_setfit.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "span_context": 0,
3
+ "spacy_model": "en_core_web_sm",
4
+ "normalize_embeddings": false,
5
+ "labels": [
6
+ "no aspect",
7
+ "aspect"
8
+ ]
9
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9f7241887e38f04c953c97a748c8d2dbf515b78010cafdfc024ca4d155a4df7b
3
+ size 90864192
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:043d1eef77de7f112a8b7de534e78a3b95e759005ab0444a1200a61c3c0bfa44
3
+ size 3919
modules.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.models.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.models.Pooling"
13
+ },
14
+ {
15
+ "idx": 2,
16
+ "name": "2",
17
+ "path": "2_Normalize",
18
+ "type": "sentence_transformers.models.Normalize"
19
+ }
20
+ ]
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 256,
3
+ "do_lower_case": false
4
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": {
3
+ "content": "[CLS]",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "mask_token": {
10
+ "content": "[MASK]",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "[PAD]",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "sep_token": {
24
+ "content": "[SEP]",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "unk_token": {
31
+ "content": "[UNK]",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ }
37
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "mask_token": "[MASK]",
49
+ "max_length": 128,
50
+ "model_max_length": 256,
51
+ "never_split": null,
52
+ "pad_to_multiple_of": null,
53
+ "pad_token": "[PAD]",
54
+ "pad_token_type_id": 0,
55
+ "padding_side": "right",
56
+ "sep_token": "[SEP]",
57
+ "stride": 0,
58
+ "strip_accents": null,
59
+ "tokenize_chinese_chars": true,
60
+ "tokenizer_class": "BertTokenizer",
61
+ "truncation_side": "right",
62
+ "truncation_strategy": "longest_first",
63
+ "unk_token": "[UNK]"
64
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff