Add SetFit model
Browse files- 1_Pooling/config.json +10 -0
- README.md +183 -0
- config.json +26 -0
- config_sentence_transformers.json +10 -0
- config_setfit.json +4 -0
- model.safetensors +3 -0
- model_head.pkl +3 -0
- modules.json +20 -0
- sentence_bert_config.json +4 -0
- special_tokens_map.json +37 -0
- tokenizer.json +0 -0
- tokenizer_config.json +64 -0
- vocab.txt +0 -0
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
ADDED
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
base_model: sentence-transformers/all-MiniLM-L6-v2
|
3 |
+
library_name: setfit
|
4 |
+
metrics:
|
5 |
+
- accuracy
|
6 |
+
pipeline_tag: text-classification
|
7 |
+
tags:
|
8 |
+
- setfit
|
9 |
+
- sentence-transformers
|
10 |
+
- text-classification
|
11 |
+
- generated_from_setfit_trainer
|
12 |
+
widget:
|
13 |
+
- text: Crisis Group telephone interview, UNRWA official, November 2023.
|
14 |
+
- text: Testimony of Maryam al-Khdeirat (55) from Khirbet Zanutah, Hebron 14 Box 3.
|
15 |
+
- text: Consulte los materiales adjuntos para lecturas adicionales.
|
16 |
+
- text: Témoignage de Leila, réfugiée syrienne en Jordanie 29 Boîte 4.
|
17 |
+
- text: Interview téléphonique, représentant de l'ONU, février 2024.
|
18 |
+
inference: true
|
19 |
+
---
|
20 |
+
|
21 |
+
# SetFit with sentence-transformers/all-MiniLM-L6-v2
|
22 |
+
|
23 |
+
This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. 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.
|
24 |
+
|
25 |
+
The model has been trained using an efficient few-shot learning technique that involves:
|
26 |
+
|
27 |
+
1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
|
28 |
+
2. Training a classification head with features from the fine-tuned Sentence Transformer.
|
29 |
+
|
30 |
+
## Model Details
|
31 |
+
|
32 |
+
### Model Description
|
33 |
+
- **Model Type:** SetFit
|
34 |
+
- **Sentence Transformer body:** [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)
|
35 |
+
- **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
|
36 |
+
- **Maximum Sequence Length:** 256 tokens
|
37 |
+
- **Number of Classes:** 2 classes
|
38 |
+
<!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
|
39 |
+
<!-- - **Language:** Unknown -->
|
40 |
+
<!-- - **License:** Unknown -->
|
41 |
+
|
42 |
+
### Model Sources
|
43 |
+
|
44 |
+
- **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
|
45 |
+
- **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
|
46 |
+
- **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
|
47 |
+
|
48 |
+
### Model Labels
|
49 |
+
| Label | Examples |
|
50 |
+
|:------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
51 |
+
| 1 | <ul><li>'In addition to date, UNFPA has distributed dignity kits to 12,650 people through partners.'</li><li>'In particular, WHO, acting on the eight pillars of the global WHO Strategic Preparedness and Response Plan, continues engaging the MoH and health partners to enhance technical capacity and awareness, including on rational use of PPEs, case management, infection prevention and control, environmental disinfection, and risk communication; and is focused on procuring and enhancing integral medical supplies including in laboratory testing and PPE for case management and healthcare facilities'</li><li>'Adicionalmente, la propuesta incluyóla entrega de mercados para asistencia alimentaria al menos a 244 personas sobrevivientes de Minas Antipersonal (MAP), Municiones sin Explotar (MSE) y/o Artefactos Explosivos Improvisados (AEI) y sus núcleos familiares.'</li></ul> |
|
52 |
+
| 0 | <ul><li>'Labor market indicators by age 42 List of figures Figure 2.'</li><li>'Women’s involvement in conflict mediation: percentage of women leading initiatives 52 List of boxes Box 2.'</li><li>'Entrevista telefónica, funcionario de la ONU, octubre de 2023.'</li></ul> |
|
53 |
+
|
54 |
+
## Uses
|
55 |
+
|
56 |
+
### Direct Use for Inference
|
57 |
+
|
58 |
+
First install the SetFit library:
|
59 |
+
|
60 |
+
```bash
|
61 |
+
pip install setfit
|
62 |
+
```
|
63 |
+
|
64 |
+
Then you can load this model and run inference.
|
65 |
+
|
66 |
+
```python
|
67 |
+
from setfit import SetFitModel
|
68 |
+
|
69 |
+
# Download from the 🤗 Hub
|
70 |
+
model = SetFitModel.from_pretrained("setfit_model_id")
|
71 |
+
# Run inference
|
72 |
+
preds = model("Consulte los materiales adjuntos para lecturas adicionales.")
|
73 |
+
```
|
74 |
+
|
75 |
+
<!--
|
76 |
+
### Downstream Use
|
77 |
+
|
78 |
+
*List how someone could finetune this model on their own dataset.*
|
79 |
+
-->
|
80 |
+
|
81 |
+
<!--
|
82 |
+
### Out-of-Scope Use
|
83 |
+
|
84 |
+
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
|
85 |
+
-->
|
86 |
+
|
87 |
+
<!--
|
88 |
+
## Bias, Risks and Limitations
|
89 |
+
|
90 |
+
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
|
91 |
+
-->
|
92 |
+
|
93 |
+
<!--
|
94 |
+
### Recommendations
|
95 |
+
|
96 |
+
*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
|
97 |
+
-->
|
98 |
+
|
99 |
+
## Training Details
|
100 |
+
|
101 |
+
### Training Set Metrics
|
102 |
+
| Training set | Min | Median | Max |
|
103 |
+
|:-------------|:----|:--------|:----|
|
104 |
+
| Word count | 2 | 24.6961 | 85 |
|
105 |
+
|
106 |
+
| Label | Training Sample Count |
|
107 |
+
|:------|:----------------------|
|
108 |
+
| 0 | 81 |
|
109 |
+
| 1 | 100 |
|
110 |
+
|
111 |
+
### Training Hyperparameters
|
112 |
+
- batch_size: (32, 32)
|
113 |
+
- num_epochs: (1, 1)
|
114 |
+
- max_steps: -1
|
115 |
+
- sampling_strategy: oversampling
|
116 |
+
- num_iterations: 35
|
117 |
+
- body_learning_rate: (2e-05, 2e-05)
|
118 |
+
- head_learning_rate: 2e-05
|
119 |
+
- loss: CosineSimilarityLoss
|
120 |
+
- distance_metric: cosine_distance
|
121 |
+
- margin: 0.25
|
122 |
+
- end_to_end: False
|
123 |
+
- use_amp: False
|
124 |
+
- warmup_proportion: 0.1
|
125 |
+
- l2_weight: 0.01
|
126 |
+
- seed: 42
|
127 |
+
- eval_max_steps: -1
|
128 |
+
- load_best_model_at_end: False
|
129 |
+
|
130 |
+
### Training Results
|
131 |
+
| Epoch | Step | Training Loss | Validation Loss |
|
132 |
+
|:------:|:----:|:-------------:|:---------------:|
|
133 |
+
| 0.0025 | 1 | 0.3104 | - |
|
134 |
+
| 0.1263 | 50 | 0.2567 | - |
|
135 |
+
| 0.2525 | 100 | 0.0406 | - |
|
136 |
+
| 0.3788 | 150 | 0.0034 | - |
|
137 |
+
| 0.5051 | 200 | 0.0017 | - |
|
138 |
+
| 0.6313 | 250 | 0.0012 | - |
|
139 |
+
| 0.7576 | 300 | 0.0009 | - |
|
140 |
+
| 0.8838 | 350 | 0.0008 | - |
|
141 |
+
|
142 |
+
### Framework Versions
|
143 |
+
- Python: 3.11.5
|
144 |
+
- SetFit: 1.1.0
|
145 |
+
- Sentence Transformers: 3.1.1
|
146 |
+
- Transformers: 4.45.1
|
147 |
+
- PyTorch: 2.1.0
|
148 |
+
- Datasets: 2.17.1
|
149 |
+
- Tokenizers: 0.20.0
|
150 |
+
|
151 |
+
## Citation
|
152 |
+
|
153 |
+
### BibTeX
|
154 |
+
```bibtex
|
155 |
+
@article{https://doi.org/10.48550/arxiv.2209.11055,
|
156 |
+
doi = {10.48550/ARXIV.2209.11055},
|
157 |
+
url = {https://arxiv.org/abs/2209.11055},
|
158 |
+
author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
|
159 |
+
keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
|
160 |
+
title = {Efficient Few-Shot Learning Without Prompts},
|
161 |
+
publisher = {arXiv},
|
162 |
+
year = {2022},
|
163 |
+
copyright = {Creative Commons Attribution 4.0 International}
|
164 |
+
}
|
165 |
+
```
|
166 |
+
|
167 |
+
<!--
|
168 |
+
## Glossary
|
169 |
+
|
170 |
+
*Clearly define terms in order to be accessible across audiences.*
|
171 |
+
-->
|
172 |
+
|
173 |
+
<!--
|
174 |
+
## Model Card Authors
|
175 |
+
|
176 |
+
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
|
177 |
+
-->
|
178 |
+
|
179 |
+
<!--
|
180 |
+
## Model Card Contact
|
181 |
+
|
182 |
+
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
|
183 |
+
-->
|
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.45.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.1.1",
|
4 |
+
"transformers": "4.45.1",
|
5 |
+
"pytorch": "2.1.0"
|
6 |
+
},
|
7 |
+
"prompts": {},
|
8 |
+
"default_prompt_name": null,
|
9 |
+
"similarity_fn_name": null
|
10 |
+
}
|
config_setfit.json
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"normalize_embeddings": false,
|
3 |
+
"labels": null
|
4 |
+
}
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ed53c8b21ad29f1c1e381f1085c9a21909b5fdedc79790967199778db95e283c
|
3 |
+
size 90864192
|
model_head.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ed1ed5b95618a112ed6d40fd5adafb1e87b44bb960d4a846a82abda9091a7f2d
|
3 |
+
size 3935
|
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": false,
|
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
|
|