Deepa
commited on
Commit
•
125921e
1
Parent(s):
867b2cd
Add SetFit model
Browse files- 1_Pooling/config.json +7 -0
- README.md +194 -0
- config.json +26 -0
- config_sentence_transformers.json +7 -0
- config_setfit.json +4 -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 +7 -0
- tokenizer.json +0 -0
- tokenizer_config.json +22 -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,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: setfit
|
3 |
+
tags:
|
4 |
+
- setfit
|
5 |
+
- sentence-transformers
|
6 |
+
- text-classification
|
7 |
+
- generated_from_setfit_trainer
|
8 |
+
metrics:
|
9 |
+
- accuracy
|
10 |
+
widget:
|
11 |
+
- text: part-of-speech ( pos ) tagging is a fundamental language analysis task---part-of-speech
|
12 |
+
( pos ) tagging is a fundamental nlp task , used by a wide variety of applications
|
13 |
+
- text: the two baseline methods were implemented using scikit-learn in python---the
|
14 |
+
models were implemented using scikit-learn module
|
15 |
+
- text: semantic parsing is the task of converting a sentence into a representation
|
16 |
+
of its meaning , usually in a logical form grounded in the symbols of some fixed
|
17 |
+
ontology or relational database ( cite-p-21-3-3 , cite-p-21-3-4 , cite-p-21-1-11
|
18 |
+
)---for this language model , we built a trigram language model with kneser-ney
|
19 |
+
smoothing using srilm from the same automatically segmented corpus
|
20 |
+
- text: the results show that our model can clearly outperform the baselines in terms
|
21 |
+
of three evaluation metrics---for the extractive or abstractive summaries , we
|
22 |
+
use rouge scores , a metric used to evaluate automatic summarization performance
|
23 |
+
, to measure the pairwise agreement of summaries from different annotators
|
24 |
+
- text: language models were built with srilm , modified kneser-ney smoothing , default
|
25 |
+
pruning , and order 5---the language model used was a 5-gram with modified kneserney
|
26 |
+
smoothing , built with srilm toolkit
|
27 |
+
pipeline_tag: text-classification
|
28 |
+
inference: true
|
29 |
+
base_model: sentence-transformers/paraphrase-TinyBERT-L6-v2
|
30 |
+
---
|
31 |
+
|
32 |
+
# SetFit with sentence-transformers/paraphrase-TinyBERT-L6-v2
|
33 |
+
|
34 |
+
This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [sentence-transformers/paraphrase-TinyBERT-L6-v2](https://huggingface.co/sentence-transformers/paraphrase-TinyBERT-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.
|
35 |
+
|
36 |
+
The model has been trained using an efficient few-shot learning technique that involves:
|
37 |
+
|
38 |
+
1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
|
39 |
+
2. Training a classification head with features from the fine-tuned Sentence Transformer.
|
40 |
+
|
41 |
+
## Model Details
|
42 |
+
|
43 |
+
### Model Description
|
44 |
+
- **Model Type:** SetFit
|
45 |
+
- **Sentence Transformer body:** [sentence-transformers/paraphrase-TinyBERT-L6-v2](https://huggingface.co/sentence-transformers/paraphrase-TinyBERT-L6-v2)
|
46 |
+
- **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
|
47 |
+
- **Maximum Sequence Length:** 128 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 |
+
| 0 | <ul><li>'the defacto standard metric in machine translation is bleu---from character representations , we propose to generate vector representations of entire tweets from characters in our tweet2vec model'</li><li>'arabic is a highly inflectional language with 85 % of words derived from trilateral roots ( alfedaghi and al-anzi 1989 )---chen et al derive bilingual subtree constraints with auto-parsed source-language sentences'</li><li>'labeling of sentence boundaries is a necessary prerequisite for many natural language processing tasks , including part-of-speech tagging and sentence alignment---we have proposed a model for video description which uses neural networks for the entire pipeline from pixels to sentences'</li></ul> |
|
63 |
+
| 1 | <ul><li>'in this paper , we present a comprehensive analysis of the relationship between personal traits and brand preferences---in previous research , in this study , we want to systematically investigate the relationship between a comprehensive set of personal traits and brand preferences'</li><li>'the 50-dimensional pre-trained word embeddings are provided by glove , which are fixed during our model training---we use glove vectors with 200 dimensions as pre-trained word embeddings , which are tuned during training'</li><li>'we use glove vectors with 100 dimensions trained on wikipedia and gigaword as word embeddings , which we do not optimize during training---we use glove vectors with 100 dimensions trained on wikipedia and gigaword as word embeddings'</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 SetFitModel
|
79 |
+
|
80 |
+
# Download from the 🤗 Hub
|
81 |
+
model = SetFitModel.from_pretrained("whateverweird17/parasci3_1")
|
82 |
+
# Run inference
|
83 |
+
preds = model("the two baseline methods were implemented using scikit-learn in python---the models were implemented using scikit-learn module")
|
84 |
+
```
|
85 |
+
|
86 |
+
<!--
|
87 |
+
### Downstream Use
|
88 |
+
|
89 |
+
*List how someone could finetune this model on their own dataset.*
|
90 |
+
-->
|
91 |
+
|
92 |
+
<!--
|
93 |
+
### Out-of-Scope Use
|
94 |
+
|
95 |
+
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
|
96 |
+
-->
|
97 |
+
|
98 |
+
<!--
|
99 |
+
## Bias, Risks and Limitations
|
100 |
+
|
101 |
+
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
|
102 |
+
-->
|
103 |
+
|
104 |
+
<!--
|
105 |
+
### Recommendations
|
106 |
+
|
107 |
+
*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
|
108 |
+
-->
|
109 |
+
|
110 |
+
## Training Details
|
111 |
+
|
112 |
+
### Training Set Metrics
|
113 |
+
| Training set | Min | Median | Max |
|
114 |
+
|:-------------|:----|:--------|:----|
|
115 |
+
| Word count | 27 | 35.8125 | 54 |
|
116 |
+
|
117 |
+
| Label | Training Sample Count |
|
118 |
+
|:------|:----------------------|
|
119 |
+
| 0 | 8 |
|
120 |
+
| 1 | 8 |
|
121 |
+
|
122 |
+
### Training Hyperparameters
|
123 |
+
- batch_size: (8, 8)
|
124 |
+
- num_epochs: (10, 10)
|
125 |
+
- max_steps: -1
|
126 |
+
- sampling_strategy: oversampling
|
127 |
+
- num_iterations: 10
|
128 |
+
- body_learning_rate: (2e-05, 2e-05)
|
129 |
+
- head_learning_rate: 2e-05
|
130 |
+
- loss: CosineSimilarityLoss
|
131 |
+
- distance_metric: cosine_distance
|
132 |
+
- margin: 0.25
|
133 |
+
- end_to_end: False
|
134 |
+
- use_amp: False
|
135 |
+
- warmup_proportion: 0.1
|
136 |
+
- seed: 42
|
137 |
+
- eval_max_steps: -1
|
138 |
+
- load_best_model_at_end: False
|
139 |
+
|
140 |
+
### Training Results
|
141 |
+
| Epoch | Step | Training Loss | Validation Loss |
|
142 |
+
|:-----:|:----:|:-------------:|:---------------:|
|
143 |
+
| 0.025 | 1 | 0.1715 | - |
|
144 |
+
| 1.25 | 50 | 0.0028 | - |
|
145 |
+
| 2.5 | 100 | 0.0005 | - |
|
146 |
+
| 3.75 | 150 | 0.0002 | - |
|
147 |
+
| 5.0 | 200 | 0.0003 | - |
|
148 |
+
| 6.25 | 250 | 0.0001 | - |
|
149 |
+
| 7.5 | 300 | 0.0002 | - |
|
150 |
+
| 8.75 | 350 | 0.0001 | - |
|
151 |
+
| 10.0 | 400 | 0.0001 | - |
|
152 |
+
|
153 |
+
### Framework Versions
|
154 |
+
- Python: 3.10.12
|
155 |
+
- SetFit: 1.0.1
|
156 |
+
- Sentence Transformers: 2.2.2
|
157 |
+
- Transformers: 4.33.0
|
158 |
+
- PyTorch: 2.0.0
|
159 |
+
- Datasets: 2.16.0
|
160 |
+
- Tokenizers: 0.13.3
|
161 |
+
|
162 |
+
## Citation
|
163 |
+
|
164 |
+
### BibTeX
|
165 |
+
```bibtex
|
166 |
+
@article{https://doi.org/10.48550/arxiv.2209.11055,
|
167 |
+
doi = {10.48550/ARXIV.2209.11055},
|
168 |
+
url = {https://arxiv.org/abs/2209.11055},
|
169 |
+
author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
|
170 |
+
keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
|
171 |
+
title = {Efficient Few-Shot Learning Without Prompts},
|
172 |
+
publisher = {arXiv},
|
173 |
+
year = {2022},
|
174 |
+
copyright = {Creative Commons Attribution 4.0 International}
|
175 |
+
}
|
176 |
+
```
|
177 |
+
|
178 |
+
<!--
|
179 |
+
## Glossary
|
180 |
+
|
181 |
+
*Clearly define terms in order to be accessible across audiences.*
|
182 |
+
-->
|
183 |
+
|
184 |
+
<!--
|
185 |
+
## Model Card Authors
|
186 |
+
|
187 |
+
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
|
188 |
+
-->
|
189 |
+
|
190 |
+
<!--
|
191 |
+
## Model Card Contact
|
192 |
+
|
193 |
+
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
|
194 |
+
-->
|
config.json
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "/root/.cache/torch/sentence_transformers/sentence-transformers_paraphrase-TinyBERT-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": 768,
|
12 |
+
"initializer_range": 0.02,
|
13 |
+
"intermediate_size": 3072,
|
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.33.0",
|
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.7.0",
|
5 |
+
"pytorch": "1.9.0+cu102"
|
6 |
+
}
|
7 |
+
}
|
config_setfit.json
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"labels": null,
|
3 |
+
"normalize_embeddings": false
|
4 |
+
}
|
model_head.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f6fb4290f7d09e8d16a45ab7cfcc0fdc6e315c00b65abee77e9de03a45ba011a
|
3 |
+
size 6991
|
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:31c0d56a2b0e8c03eceb17327b08dbc609e29a569251fa55541985b3b2594e81
|
3 |
+
size 267854313
|
sentence_bert_config.json
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"max_seq_length": 128,
|
3 |
+
"do_lower_case": false
|
4 |
+
}
|
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,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"clean_up_tokenization_spaces": true,
|
3 |
+
"cls_token": "[CLS]",
|
4 |
+
"do_basic_tokenize": true,
|
5 |
+
"do_lower_case": true,
|
6 |
+
"mask_token": "[MASK]",
|
7 |
+
"max_length": 128,
|
8 |
+
"model_max_length": 512,
|
9 |
+
"never_split": null,
|
10 |
+
"pad_to_multiple_of": null,
|
11 |
+
"pad_token": "[PAD]",
|
12 |
+
"pad_token_type_id": 0,
|
13 |
+
"padding_side": "right",
|
14 |
+
"sep_token": "[SEP]",
|
15 |
+
"stride": 0,
|
16 |
+
"strip_accents": null,
|
17 |
+
"tokenize_chinese_chars": true,
|
18 |
+
"tokenizer_class": "BertTokenizer",
|
19 |
+
"truncation_side": "right",
|
20 |
+
"truncation_strategy": "longest_first",
|
21 |
+
"unk_token": "[UNK]"
|
22 |
+
}
|
vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|