Push model using huggingface_hub.
Browse files- 1_Pooling/config.json +7 -0
- README.md +233 -0
- config.json +24 -0
- config_sentence_transformers.json +7 -0
- config_setfit.json +7 -0
- model_head.pkl +3 -0
- modules.json +14 -0
- pytorch_model.bin +3 -0
- sentence_bert_config.json +4 -0
- special_tokens_map.json +15 -0
- tokenizer.json +0 -0
- tokenizer_config.json +66 -0
- vocab.txt +0 -0
1_Pooling/config.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"word_embedding_dimension": 768,
|
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 |
+
}
|
README.md
ADDED
@@ -0,0 +1,233 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
license: apache-2.0
|
5 |
+
library_name: setfit
|
6 |
+
tags:
|
7 |
+
- setfit
|
8 |
+
- sentence-transformers
|
9 |
+
- text-classification
|
10 |
+
- generated_from_setfit_trainer
|
11 |
+
datasets:
|
12 |
+
- sst2
|
13 |
+
metrics:
|
14 |
+
- precision
|
15 |
+
- recall
|
16 |
+
- f1
|
17 |
+
widget:
|
18 |
+
- text: 'this is a story of two misfits who do n''t stand a chance alone , but together
|
19 |
+
they are magnificent . '
|
20 |
+
- text: 'it does n''t believe in itself , it has no sense of humor ... it ''s just
|
21 |
+
plain bored . '
|
22 |
+
- text: 'the band ''s courage in the face of official repression is inspiring , especially
|
23 |
+
for aging hippies ( this one included ) . '
|
24 |
+
- text: 'a fast , funny , highly enjoyable movie . '
|
25 |
+
- text: 'the movie achieves as great an impact by keeping these thoughts hidden as
|
26 |
+
... ( quills ) did by showing them . '
|
27 |
+
pipeline_tag: text-classification
|
28 |
+
co2_eq_emissions:
|
29 |
+
emissions: 2.6114980282637004
|
30 |
+
source: codecarbon
|
31 |
+
training_type: fine-tuning
|
32 |
+
on_cloud: false
|
33 |
+
cpu_model: 13th Gen Intel(R) Core(TM) i7-13700K
|
34 |
+
ram_total_size: 31.777088165283203
|
35 |
+
hours_used: 0.03
|
36 |
+
hardware_used: 1 x NVIDIA GeForce RTX 3090
|
37 |
+
base_model: sentence-transformers/paraphrase-mpnet-base-v2
|
38 |
+
model-index:
|
39 |
+
- name: SetFit with sentence-transformers/paraphrase-mpnet-base-v2 on sst2
|
40 |
+
results:
|
41 |
+
- task:
|
42 |
+
type: text-classification
|
43 |
+
name: Text Classification
|
44 |
+
dataset:
|
45 |
+
name: Unknown
|
46 |
+
type: sst2
|
47 |
+
split: test
|
48 |
+
metrics:
|
49 |
+
- type: accuracy
|
50 |
+
value: 0.8588082901554405
|
51 |
+
name: Accuracy
|
52 |
+
---
|
53 |
+
|
54 |
+
# SetFit with sentence-transformers/paraphrase-mpnet-base-v2 on sst2
|
55 |
+
|
56 |
+
This is a [SetFit](https://github.com/huggingface/setfit) model trained on the [sst2](https://huggingface.co/datasets/sst2) dataset that can be used for Text Classification. This SetFit model uses [sentence-transformers/paraphrase-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-mpnet-base-v2) as the Sentence Transformer embedding model. For classification, it uses a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance.
|
57 |
+
|
58 |
+
The model has been trained using an efficient few-shot learning technique that involves:
|
59 |
+
|
60 |
+
1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
|
61 |
+
2. Training a classification head with features from the fine-tuned Sentence Transformer.
|
62 |
+
|
63 |
+
## Model Details
|
64 |
+
|
65 |
+
### Model Description
|
66 |
+
- **Model Type:** SetFit
|
67 |
+
- **Sentence Transformer body:** [sentence-transformers/paraphrase-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-mpnet-base-v2)
|
68 |
+
- **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance.
|
69 |
+
- **Maximum Sequence Length:** 512 tokens
|
70 |
+
- **Number of Classes:** 2 classes
|
71 |
+
- **Training Dataset:** [sst2](https://huggingface.co/datasets/sst2)
|
72 |
+
- **Language:** en
|
73 |
+
- **License:** apache-2.0
|
74 |
+
|
75 |
+
### Model Sources
|
76 |
+
|
77 |
+
- **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
|
78 |
+
- **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
|
79 |
+
- **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
|
80 |
+
|
81 |
+
### Model Labels
|
82 |
+
| Label | Examples |
|
83 |
+
|:------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
84 |
+
| 0 | <ul><li>'stale and uninspired . '</li><li>"the film 's considered approach to its subject matter is too calm and thoughtful for agitprop , and the thinness of its characterizations makes it a failure as straight drama . ' "</li><li>"that their charm does n't do a load of good "</li></ul> |
|
85 |
+
| 1 | <ul><li>"broomfield is energized by volletta wallace 's maternal fury , her fearlessness "</li><li>'flawless '</li><li>'insightfully written , delicately performed '</li></ul> |
|
86 |
+
|
87 |
+
## Evaluation
|
88 |
+
|
89 |
+
### Metrics
|
90 |
+
| Label | Accuracy |
|
91 |
+
|:--------|:---------|
|
92 |
+
| **all** | 0.8588 |
|
93 |
+
|
94 |
+
## Uses
|
95 |
+
|
96 |
+
### Direct Use for Inference
|
97 |
+
|
98 |
+
First install the SetFit library:
|
99 |
+
|
100 |
+
```bash
|
101 |
+
pip install setfit
|
102 |
+
```
|
103 |
+
|
104 |
+
Then you can load this model and run inference.
|
105 |
+
|
106 |
+
```python
|
107 |
+
from setfit import SetFitModel
|
108 |
+
|
109 |
+
# Download from 🤗 Hub
|
110 |
+
model = SetFitModel.from_pretrained("tomaarsen/setfit-paraphrase-mpnet-base-v2-sst2-8-shot")
|
111 |
+
# Run inference
|
112 |
+
preds = model("a fast , funny , highly enjoyable movie . ")
|
113 |
+
```
|
114 |
+
<!--
|
115 |
+
### Downstream Use
|
116 |
+
|
117 |
+
*List how someone could finetune this model on their own dataset.*
|
118 |
+
-->
|
119 |
+
|
120 |
+
<!--
|
121 |
+
### Out-of-Scope Use
|
122 |
+
|
123 |
+
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
|
124 |
+
-->
|
125 |
+
|
126 |
+
<!--
|
127 |
+
## Bias, Risks and Limitations
|
128 |
+
|
129 |
+
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
|
130 |
+
-->
|
131 |
+
|
132 |
+
<!--
|
133 |
+
### Recommendations
|
134 |
+
|
135 |
+
*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
|
136 |
+
-->
|
137 |
+
|
138 |
+
## Training Details
|
139 |
+
|
140 |
+
### Training Set Metrics
|
141 |
+
| Training set | Min | Median | Max |
|
142 |
+
|:-------------|:----|:--------|:----|
|
143 |
+
| Word count | 2 | 11.4375 | 33 |
|
144 |
+
|
145 |
+
| Label | Training Sample Count |
|
146 |
+
|:---------|:----------------------|
|
147 |
+
| negative | 8 |
|
148 |
+
| positive | 8 |
|
149 |
+
|
150 |
+
### Training Hyperparameters
|
151 |
+
- batch_size: (16, 16)
|
152 |
+
- num_epochs: (10, 10)
|
153 |
+
- max_steps: -1
|
154 |
+
- sampling_strategy: oversampling
|
155 |
+
- body_learning_rate: (2e-05, 1e-05)
|
156 |
+
- head_learning_rate: 0.01
|
157 |
+
- loss: CosineSimilarityLoss
|
158 |
+
- distance_metric: cosine_distance
|
159 |
+
- margin: 0.25
|
160 |
+
- end_to_end: False
|
161 |
+
- use_amp: False
|
162 |
+
- warmup_proportion: 0.1
|
163 |
+
- seed: 42
|
164 |
+
- load_best_model_at_end: True
|
165 |
+
|
166 |
+
### Training Results
|
167 |
+
| Epoch | Step | Training Loss | Validation Loss |
|
168 |
+
|:----------:|:------:|:-------------:|:---------------:|
|
169 |
+
| 0.1111 | 1 | 0.2126 | - |
|
170 |
+
| 1.1111 | 10 | 0.1604 | - |
|
171 |
+
| **2.2222** | **20** | **0.0224** | **0.1761** |
|
172 |
+
| 3.3333 | 30 | 0.0039 | - |
|
173 |
+
| 4.4444 | 40 | 0.0029 | 0.1935 |
|
174 |
+
| 5.5556 | 50 | 0.0026 | - |
|
175 |
+
| 6.6667 | 60 | 0.0008 | 0.1944 |
|
176 |
+
| 7.7778 | 70 | 0.0009 | - |
|
177 |
+
| 8.8889 | 80 | 0.0027 | 0.1941 |
|
178 |
+
| 10.0 | 90 | 0.0004 | - |
|
179 |
+
|
180 |
+
* The bold row denotes the saved checkpoint.
|
181 |
+
### Environmental Impact
|
182 |
+
Carbon emissions were measured using [CodeCarbon](https://github.com/mlco2/codecarbon).
|
183 |
+
- **Carbon Emitted**: 0.003 kg of CO2
|
184 |
+
- **Hours Used**: 0.03 hours
|
185 |
+
|
186 |
+
### Training Hardware
|
187 |
+
- **On Cloud**: No
|
188 |
+
- **GPU Model**: 1 x NVIDIA GeForce RTX 3090
|
189 |
+
- **CPU Model**: 13th Gen Intel(R) Core(TM) i7-13700K
|
190 |
+
- **RAM Size**: 31.78 GB
|
191 |
+
|
192 |
+
### Framework Versions
|
193 |
+
- Python: 3.9.16
|
194 |
+
- SetFit: 1.0.0.dev0
|
195 |
+
- Sentence Transformers: 2.2.2
|
196 |
+
- Transformers: 4.29.0
|
197 |
+
- PyTorch: 1.13.1+cu117
|
198 |
+
- Datasets: 2.15.0
|
199 |
+
- Tokenizers: 0.13.3
|
200 |
+
|
201 |
+
## Citation
|
202 |
+
|
203 |
+
### BibTeX
|
204 |
+
```bibtex
|
205 |
+
@article{https://doi.org/10.48550/arxiv.2209.11055,
|
206 |
+
doi = {10.48550/ARXIV.2209.11055},
|
207 |
+
url = {https://arxiv.org/abs/2209.11055},
|
208 |
+
author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
|
209 |
+
keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
|
210 |
+
title = {Efficient Few-Shot Learning Without Prompts},
|
211 |
+
publisher = {arXiv},
|
212 |
+
year = {2022},
|
213 |
+
copyright = {Creative Commons Attribution 4.0 International}
|
214 |
+
}
|
215 |
+
```
|
216 |
+
|
217 |
+
<!--
|
218 |
+
## Glossary
|
219 |
+
|
220 |
+
*Clearly define terms in order to be accessible across audiences.*
|
221 |
+
-->
|
222 |
+
|
223 |
+
<!--
|
224 |
+
## Model Card Authors
|
225 |
+
|
226 |
+
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
|
227 |
+
-->
|
228 |
+
|
229 |
+
<!--
|
230 |
+
## Model Card Contact
|
231 |
+
|
232 |
+
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
|
233 |
+
-->
|
config.json
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "checkpoints\\step_20\\",
|
3 |
+
"architectures": [
|
4 |
+
"MPNetModel"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0.1,
|
7 |
+
"bos_token_id": 0,
|
8 |
+
"eos_token_id": 2,
|
9 |
+
"hidden_act": "gelu",
|
10 |
+
"hidden_dropout_prob": 0.1,
|
11 |
+
"hidden_size": 768,
|
12 |
+
"initializer_range": 0.02,
|
13 |
+
"intermediate_size": 3072,
|
14 |
+
"layer_norm_eps": 1e-05,
|
15 |
+
"max_position_embeddings": 514,
|
16 |
+
"model_type": "mpnet",
|
17 |
+
"num_attention_heads": 12,
|
18 |
+
"num_hidden_layers": 12,
|
19 |
+
"pad_token_id": 1,
|
20 |
+
"relative_attention_num_buckets": 32,
|
21 |
+
"torch_dtype": "float32",
|
22 |
+
"transformers_version": "4.29.0",
|
23 |
+
"vocab_size": 30527
|
24 |
+
}
|
config_sentence_transformers.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"__version__": {
|
3 |
+
"sentence_transformers": "2.0.0",
|
4 |
+
"transformers": "4.7.0",
|
5 |
+
"pytorch": "1.9.0+cu102"
|
6 |
+
}
|
7 |
+
}
|
config_setfit.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"labels": [
|
3 |
+
"negative",
|
4 |
+
"positive"
|
5 |
+
],
|
6 |
+
"normalize_embeddings": false
|
7 |
+
}
|
model_head.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1a2b4b17b5e6b45edc289bf04cf1884158bc527d877bef5fcf2f7ba7b646f41b
|
3 |
+
size 6959
|
modules.json
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
]
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7ca435aa80c4000fb79462d03c61f95a83d8818f61fa319c3abf0fbb951c80db
|
3 |
+
size 438016493
|
sentence_bert_config.json
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"max_seq_length": 512,
|
3 |
+
"do_lower_case": false
|
4 |
+
}
|
special_tokens_map.json
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"cls_token": "<s>",
|
4 |
+
"eos_token": "</s>",
|
5 |
+
"mask_token": {
|
6 |
+
"content": "<mask>",
|
7 |
+
"lstrip": true,
|
8 |
+
"normalized": false,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false
|
11 |
+
},
|
12 |
+
"pad_token": "<pad>",
|
13 |
+
"sep_token": "</s>",
|
14 |
+
"unk_token": "[UNK]"
|
15 |
+
}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": {
|
3 |
+
"__type": "AddedToken",
|
4 |
+
"content": "<s>",
|
5 |
+
"lstrip": false,
|
6 |
+
"normalized": true,
|
7 |
+
"rstrip": false,
|
8 |
+
"single_word": false
|
9 |
+
},
|
10 |
+
"clean_up_tokenization_spaces": true,
|
11 |
+
"cls_token": {
|
12 |
+
"__type": "AddedToken",
|
13 |
+
"content": "<s>",
|
14 |
+
"lstrip": false,
|
15 |
+
"normalized": true,
|
16 |
+
"rstrip": false,
|
17 |
+
"single_word": false
|
18 |
+
},
|
19 |
+
"do_basic_tokenize": true,
|
20 |
+
"do_lower_case": true,
|
21 |
+
"eos_token": {
|
22 |
+
"__type": "AddedToken",
|
23 |
+
"content": "</s>",
|
24 |
+
"lstrip": false,
|
25 |
+
"normalized": true,
|
26 |
+
"rstrip": false,
|
27 |
+
"single_word": false
|
28 |
+
},
|
29 |
+
"mask_token": {
|
30 |
+
"__type": "AddedToken",
|
31 |
+
"content": "<mask>",
|
32 |
+
"lstrip": true,
|
33 |
+
"normalized": true,
|
34 |
+
"rstrip": false,
|
35 |
+
"single_word": false
|
36 |
+
},
|
37 |
+
"model_max_length": 512,
|
38 |
+
"never_split": null,
|
39 |
+
"pad_token": {
|
40 |
+
"__type": "AddedToken",
|
41 |
+
"content": "<pad>",
|
42 |
+
"lstrip": false,
|
43 |
+
"normalized": true,
|
44 |
+
"rstrip": false,
|
45 |
+
"single_word": false
|
46 |
+
},
|
47 |
+
"sep_token": {
|
48 |
+
"__type": "AddedToken",
|
49 |
+
"content": "</s>",
|
50 |
+
"lstrip": false,
|
51 |
+
"normalized": true,
|
52 |
+
"rstrip": false,
|
53 |
+
"single_word": false
|
54 |
+
},
|
55 |
+
"strip_accents": null,
|
56 |
+
"tokenize_chinese_chars": true,
|
57 |
+
"tokenizer_class": "MPNetTokenizer",
|
58 |
+
"unk_token": {
|
59 |
+
"__type": "AddedToken",
|
60 |
+
"content": "[UNK]",
|
61 |
+
"lstrip": false,
|
62 |
+
"normalized": true,
|
63 |
+
"rstrip": false,
|
64 |
+
"single_word": false
|
65 |
+
}
|
66 |
+
}
|
vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|