intvy joshuasundance commited on
Commit
56ab0a5
0 Parent(s):

Duplicate from joshuasundance/setfit-absa-all-MiniLM-L6-v2-laptops-aspect

Browse files

Co-authored-by: Joshua Sundance Bailey <joshuasundance@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
1_Pooling/config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
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
+ }
README.md ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: setfit
3
+ tags:
4
+ - setfit
5
+ - absa
6
+ - sentence-transformers
7
+ - text-classification
8
+ - generated_from_setfit_trainer
9
+ metrics:
10
+ - accuracy
11
+ widget:
12
+ - text: camera:It has no camera but, I can always buy and install one easy.
13
+ - text: Acer:Acer was no help and Garmin could not determine the problem(after spending
14
+ about 2 hours with me), so I returned it and purchased a Toshiba R700 that seems
15
+ even nicer and I was able to load all of my software with no problem.
16
+ - text: memory:I've been impressed with the battery life and the performance for such
17
+ a small amount of memory.
18
+ - text: speed:Yes, a Mac is much more money than the average laptop out there, but
19
+ there is no comparison in style, speed and just cool factor.
20
+ - text: fiance:I got it back and my built-in webcam and built-in mic were shorting
21
+ out anytime I touched the lid, (mind you this was my means of communication with
22
+ my fiance who was deployed) but I suffered thru it and would constandly have to
23
+ reset the computer to be able to use my cam and mic anytime they went out.
24
+ pipeline_tag: text-classification
25
+ inference: false
26
+ base_model: sentence-transformers/all-MiniLM-L6-v2
27
+ model-index:
28
+ - name: SetFit Aspect Model with sentence-transformers/all-MiniLM-L6-v2
29
+ results:
30
+ - task:
31
+ type: text-classification
32
+ name: Text Classification
33
+ dataset:
34
+ name: tomaarsen/setfit-absa-semeval-laptops
35
+ type: unknown
36
+ split: test
37
+ metrics:
38
+ - type: accuracy
39
+ value: 0.8239700374531835
40
+ name: Accuracy
41
+ ---
42
+
43
+ # SetFit Aspect Model with sentence-transformers/all-MiniLM-L6-v2
44
+
45
+ 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.
46
+
47
+ The model has been trained using an efficient few-shot learning technique that involves:
48
+
49
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
50
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
51
+
52
+ This model was trained within the context of a larger system for ABSA, which looks like so:
53
+
54
+ 1. Use a spaCy model to select possible aspect span candidates.
55
+ 2. **Use this SetFit model to filter these possible aspect span candidates.**
56
+ 3. Use a SetFit model to classify the filtered aspect span candidates.
57
+
58
+ ## Model Details
59
+
60
+ ### Model Description
61
+ - **Model Type:** SetFit
62
+ - **Sentence Transformer body:** [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)
63
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
64
+ - **spaCy Model:** en_core_web_sm
65
+ - **SetFitABSA Aspect Model:** [joshuasundance/setfit-absa-all-MiniLM-L6-v2-laptops-aspect](https://huggingface.co/joshuasundance/setfit-absa-all-MiniLM-L6-v2-laptops-aspect)
66
+ - **SetFitABSA Polarity Model:** [joshuasundance/setfit-absa-all-mpnet-base-v2-laptops-polarity](https://huggingface.co/joshuasundance/setfit-absa-all-mpnet-base-v2-laptops-polarity)
67
+ - **Maximum Sequence Length:** 256 tokens
68
+ - **Number of Classes:** 2 classes
69
+ <!-- - **Training Dataset:** [tomaarsen/setfit-absa-semeval-laptops](https://huggingface.co/datasets/tomaarsen/setfit-absa-semeval-laptops) -->
70
+ <!-- - **Language:** Unknown -->
71
+ <!-- - **License:** Unknown -->
72
+
73
+ ### Model Sources
74
+
75
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
76
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
77
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
78
+
79
+ ### Model Labels
80
+ | Label | Examples |
81
+ |:----------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
82
+ | aspect | <ul><li>'cord:I charge it at night and skip taking the cord with me because of the good battery life.'</li><li>'battery life:I charge it at night and skip taking the cord with me because of the good battery life.'</li><li>'service center:The tech guy then said the service center does not do 1-to-1 exchange and I have to direct my concern to the "sales" team, which is the retail shop which I bought my netbook from.'</li></ul> |
83
+ | no aspect | <ul><li>'night:I charge it at night and skip taking the cord with me because of the good battery life.'</li><li>'skip:I charge it at night and skip taking the cord with me because of the good battery life.'</li><li>'exchange:The tech guy then said the service center does not do 1-to-1 exchange and I have to direct my concern to the "sales" team, which is the retail shop which I bought my netbook from.'</li></ul> |
84
+
85
+ ## Evaluation
86
+
87
+ ### Metrics
88
+ | Label | Accuracy |
89
+ |:--------|:---------|
90
+ | **all** | 0.8240 |
91
+
92
+ ## Uses
93
+
94
+ ### Direct Use for Inference
95
+
96
+ First install the SetFit library:
97
+
98
+ ```bash
99
+ pip install setfit
100
+ ```
101
+
102
+ Then you can load this model and run inference.
103
+
104
+ ```python
105
+ from setfit import AbsaModel
106
+
107
+ # Download from the 🤗 Hub
108
+ model = AbsaModel.from_pretrained(
109
+ "joshuasundance/setfit-absa-all-MiniLM-L6-v2-laptops-aspect",
110
+ "joshuasundance/setfit-absa-all-mpnet-base-v2-laptops-polarity",
111
+ spacy_model="en_core_web_sm",
112
+ )
113
+ # Run inference
114
+ preds = model("This laptop meets every expectation and Windows 7 is great!")
115
+ ```
116
+
117
+ <!--
118
+ ### Downstream Use
119
+
120
+ *List how someone could finetune this model on their own dataset.*
121
+ -->
122
+
123
+ <!--
124
+ ### Out-of-Scope Use
125
+
126
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
127
+ -->
128
+
129
+ <!--
130
+ ## Bias, Risks and Limitations
131
+
132
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
133
+ -->
134
+
135
+ <!--
136
+ ### Recommendations
137
+
138
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
139
+ -->
140
+
141
+ ## Training Details
142
+
143
+ ### Training Set Metrics
144
+ | Training set | Min | Median | Max |
145
+ |:-------------|:----|:--------|:----|
146
+ | Word count | 2 | 21.1510 | 42 |
147
+
148
+ | Label | Training Sample Count |
149
+ |:----------|:----------------------|
150
+ | no aspect | 119 |
151
+ | aspect | 126 |
152
+
153
+ ### Training Hyperparameters
154
+ - batch_size: (128, 128)
155
+ - num_epochs: (5, 5)
156
+ - max_steps: -1
157
+ - sampling_strategy: oversampling
158
+ - body_learning_rate: (2e-05, 1e-05)
159
+ - head_learning_rate: 0.01
160
+ - loss: CosineSimilarityLoss
161
+ - distance_metric: cosine_distance
162
+ - margin: 0.25
163
+ - end_to_end: False
164
+ - use_amp: True
165
+ - warmup_proportion: 0.1
166
+ - seed: 42
167
+ - eval_max_steps: -1
168
+ - load_best_model_at_end: True
169
+
170
+ ### Training Results
171
+ | Epoch | Step | Training Loss | Validation Loss |
172
+ |:----------:|:-------:|:-------------:|:---------------:|
173
+ | 0.0042 | 1 | 0.3776 | - |
174
+ | 0.2110 | 50 | 0.2644 | 0.2622 |
175
+ | 0.4219 | 100 | 0.2248 | 0.2437 |
176
+ | **0.6329** | **150** | **0.0059** | **0.2238** |
177
+ | 0.8439 | 200 | 0.0017 | 0.2326 |
178
+ | 1.0549 | 250 | 0.0012 | 0.2382 |
179
+ | 1.2658 | 300 | 0.0008 | 0.2455 |
180
+ | 1.4768 | 350 | 0.0006 | 0.2328 |
181
+ | 1.6878 | 400 | 0.0005 | 0.243 |
182
+
183
+ * The bold row denotes the saved checkpoint.
184
+ ### Framework Versions
185
+ - Python: 3.11.7
186
+ - SetFit: 1.0.3
187
+ - Sentence Transformers: 2.3.0
188
+ - spaCy: 3.7.2
189
+ - Transformers: 4.37.2
190
+ - PyTorch: 2.1.2+cu118
191
+ - Datasets: 2.16.1
192
+ - Tokenizers: 0.15.1
193
+
194
+ ## Citation
195
+
196
+ ### BibTeX
197
+ ```bibtex
198
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
199
+ doi = {10.48550/ARXIV.2209.11055},
200
+ url = {https://arxiv.org/abs/2209.11055},
201
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
202
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
203
+ title = {Efficient Few-Shot Learning Without Prompts},
204
+ publisher = {arXiv},
205
+ year = {2022},
206
+ copyright = {Creative Commons Attribution 4.0 International}
207
+ }
208
+ ```
209
+
210
+ <!--
211
+ ## Glossary
212
+
213
+ *Clearly define terms in order to be accessible across audiences.*
214
+ -->
215
+
216
+ <!--
217
+ ## Model Card Authors
218
+
219
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
220
+ -->
221
+
222
+ <!--
223
+ ## Model Card Contact
224
+
225
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
226
+ -->
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "models\\step_150",
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.37.2",
23
+ "type_vocab_size": 2,
24
+ "use_cache": true,
25
+ "vocab_size": 30522
26
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.0.0",
4
+ "transformers": "4.6.1",
5
+ "pytorch": "1.8.1"
6
+ }
7
+ }
config_setfit.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "spacy_model": "en_core_web_sm",
3
+ "labels": [
4
+ "no aspect",
5
+ "aspect"
6
+ ],
7
+ "normalize_embeddings": false,
8
+ "span_context": 0
9
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3d7688103fa9c9411967142dca7be810ed4c93a70ded0f19c8b12b2ee2e90b26
3
+ size 90864192
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:95a94b6d35296d4ec451dca25a4970baca68060fc8a05eea35fa5d556f05ac85
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": 512,
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