Add SetFit model
Browse files- 1_Pooling/config.json +9 -0
- README.md +220 -0
- config.json +32 -0
- config_sentence_transformers.json +7 -0
- config_setfit.json +8 -0
- model.safetensors +3 -0
- model_head.pkl +3 -0
- modules.json +20 -0
- sentence_bert_config.json +4 -0
- special_tokens_map.json +7 -0
- tokenizer.json +0 -0
- tokenizer_config.json +57 -0
- vocab.txt +0 -0
1_Pooling/config.json
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"word_embedding_dimension": 768,
|
3 |
+
"pooling_mode_cls_token": true,
|
4 |
+
"pooling_mode_mean_tokens": false,
|
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,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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: Unconditional Reduction The level of reduction planned unconditionally is
|
12 |
+
expected to be up to 35% by 2030 as compared to the Business As Usual (BAU) scenario,
|
13 |
+
taking 2005 as the reference year. Conditional Reduction In a conditional mitigation
|
14 |
+
scenario Angola plans to reduce further its emissions. Therefore, the mitigation
|
15 |
+
options identified in this scenario are expected to reduce an additional 15% below
|
16 |
+
BAU emission levels by 2030.
|
17 |
+
- text: Measure 300 MW total installed biomass power capacity in the country by Sector
|
18 |
+
Energy GHG mitigation target 84 ktCO2e on average per year between 2020 and 2030
|
19 |
+
Monitoring procedures Newly added biomass capacity will be monitored on an annual
|
20 |
+
basis by the Department of Climate Change of the Ministry of Natural Resources
|
21 |
+
and Environment using data from the Ministry of Energy and Mines Comments - Installed
|
22 |
+
capacity as of 2019 is around 40MW Measure 30% Electric Vehicles penetration
|
23 |
+
for 2-wheelers and passengers cars in national vehicles mix Sector Transport
|
24 |
+
GHG mitigation target 30 ktCO2e on average per year between 2020 and 2030 Monitoring
|
25 |
+
procedures Share of Electric Vehicles in national vehicle mix will be monitored
|
26 |
+
on an annual basis by the Department of Climate Change of the Ministry of Natural
|
27 |
+
Resources and Environment using data from the Ministry of Public Works and Transport.
|
28 |
+
- text: � Australia adopts a target of net zero emissions by 2050. This is an economy-wide
|
29 |
+
target, covering all sectors and gases included in Australia’s national inventory.
|
30 |
+
� In order to achieve net zero by 2050, Australia commits to seven low emissions
|
31 |
+
technology stretch goals - ambitious but realistic goals to bring priority low
|
32 |
+
emissions technologies to economic parity with existing mature technologies.
|
33 |
+
- text: 'The GoP has taken a series of major initiatives as outlined in chapters 4
|
34 |
+
and 5. Hence, Pakistan intends to set a cumulative ambitious conditional target
|
35 |
+
of overall 50% reduction of its projected emissions by 2030, with 15% from the
|
36 |
+
country’s own resources and 35% subject to provision of international grant finance
|
37 |
+
that would require USD 101 billion just for energy transition. 7.1 HIGH PRIORITY
|
38 |
+
ACTIONS Addressing the Global Climate Summit at the United Nations in December
|
39 |
+
2020, the Prime Minister of Pakistan made an announcement to reduce future GHG
|
40 |
+
emissions on a high priority basis if international financial and technical resources
|
41 |
+
were made available: MITIGATION: 1.'
|
42 |
+
- text: This document enfolds Iceland’s first communication on its long-term strategy
|
43 |
+
(LTS), to be updated when further analysis and policy documents are published
|
44 |
+
on the matter. Iceland is committed to reducing its overall greenhouse gas emissions
|
45 |
+
and reaching climate neutrality no later than 2040 and become fossil fuel free
|
46 |
+
in 2050, which should set Iceland on a path to net negative emissions.
|
47 |
+
pipeline_tag: text-classification
|
48 |
+
inference: false
|
49 |
+
co2_eq_emissions:
|
50 |
+
emissions: 268.4261122496047
|
51 |
+
source: codecarbon
|
52 |
+
training_type: fine-tuning
|
53 |
+
on_cloud: false
|
54 |
+
cpu_model: Intel(R) Xeon(R) CPU @ 2.20GHz
|
55 |
+
ram_total_size: 12.674789428710938
|
56 |
+
hours_used: 2.03
|
57 |
+
hardware_used: 1 x Tesla V100-SXM2-16GB
|
58 |
+
base_model: BAAI/bge-base-en-v1.5
|
59 |
+
---
|
60 |
+
|
61 |
+
# SetFit with BAAI/bge-base-en-v1.5
|
62 |
+
|
63 |
+
This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [BAAI/bge-base-en-v1.5](https://huggingface.co/BAAI/bge-base-en-v1.5) as the Sentence Transformer embedding model. A [SetFitHead](huggingface.co/docs/setfit/reference/main#setfit.SetFitHead) instance is used for classification.
|
64 |
+
|
65 |
+
The model has been trained using an efficient few-shot learning technique that involves:
|
66 |
+
|
67 |
+
1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
|
68 |
+
2. Training a classification head with features from the fine-tuned Sentence Transformer.
|
69 |
+
|
70 |
+
## Model Details
|
71 |
+
|
72 |
+
### Model Description
|
73 |
+
- **Model Type:** SetFit
|
74 |
+
- **Sentence Transformer body:** [BAAI/bge-base-en-v1.5](https://huggingface.co/BAAI/bge-base-en-v1.5)
|
75 |
+
- **Classification head:** a [SetFitHead](huggingface.co/docs/setfit/reference/main#setfit.SetFitHead) instance
|
76 |
+
- **Maximum Sequence Length:** 512 tokens
|
77 |
+
- **Number of Classes:** 3 classes
|
78 |
+
<!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
|
79 |
+
<!-- - **Language:** Unknown -->
|
80 |
+
<!-- - **License:** Unknown -->
|
81 |
+
|
82 |
+
### Model Sources
|
83 |
+
|
84 |
+
- **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
|
85 |
+
- **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
|
86 |
+
- **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
|
87 |
+
|
88 |
+
## Uses
|
89 |
+
|
90 |
+
### Direct Use for Inference
|
91 |
+
|
92 |
+
First install the SetFit library:
|
93 |
+
|
94 |
+
```bash
|
95 |
+
pip install setfit
|
96 |
+
```
|
97 |
+
|
98 |
+
Then you can load this model and run inference.
|
99 |
+
|
100 |
+
```python
|
101 |
+
from setfit import SetFitModel
|
102 |
+
|
103 |
+
# Download from the 🤗 Hub
|
104 |
+
model = SetFitModel.from_pretrained("ppsingh/SUBTARGET_multilabel_bge")
|
105 |
+
# Run inference
|
106 |
+
preds = model("This document enfolds Iceland’s first communication on its long-term strategy (LTS), to be updated when further analysis and policy documents are published on the matter. Iceland is committed to reducing its overall greenhouse gas emissions and reaching climate neutrality no later than 2040 and become fossil fuel free in 2050, which should set Iceland on a path to net negative emissions.")
|
107 |
+
```
|
108 |
+
|
109 |
+
<!--
|
110 |
+
### Downstream Use
|
111 |
+
|
112 |
+
*List how someone could finetune this model on their own dataset.*
|
113 |
+
-->
|
114 |
+
|
115 |
+
<!--
|
116 |
+
### Out-of-Scope Use
|
117 |
+
|
118 |
+
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
|
119 |
+
-->
|
120 |
+
|
121 |
+
<!--
|
122 |
+
## Bias, Risks and Limitations
|
123 |
+
|
124 |
+
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
|
125 |
+
-->
|
126 |
+
|
127 |
+
<!--
|
128 |
+
### Recommendations
|
129 |
+
|
130 |
+
*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
|
131 |
+
-->
|
132 |
+
|
133 |
+
## Training Details
|
134 |
+
|
135 |
+
### Training Set Metrics
|
136 |
+
| Training set | Min | Median | Max |
|
137 |
+
|:-------------|:----|:--------|:----|
|
138 |
+
| Word count | 19 | 78.5467 | 173 |
|
139 |
+
|
140 |
+
### Training Hyperparameters
|
141 |
+
- batch_size: (8, 2)
|
142 |
+
- num_epochs: (1, 0)
|
143 |
+
- max_steps: -1
|
144 |
+
- sampling_strategy: undersampling
|
145 |
+
- body_learning_rate: (6.86e-06, 1e-05)
|
146 |
+
- head_learning_rate: 0.01
|
147 |
+
- loss: CosineSimilarityLoss
|
148 |
+
- distance_metric: cosine_distance
|
149 |
+
- margin: 0.25
|
150 |
+
- end_to_end: False
|
151 |
+
- use_amp: False
|
152 |
+
- warmup_proportion: 0.01
|
153 |
+
- seed: 42
|
154 |
+
- eval_max_steps: -1
|
155 |
+
- load_best_model_at_end: False
|
156 |
+
|
157 |
+
### Training Results
|
158 |
+
| Epoch | Step | Training Loss | Validation Loss |
|
159 |
+
|:------:|:-----:|:-------------:|:---------------:|
|
160 |
+
| 0.0000 | 1 | 0.2227 | - |
|
161 |
+
| 0.1519 | 5000 | 0.015 | 0.0831 |
|
162 |
+
| 0.3038 | 10000 | 0.0146 | 0.0924 |
|
163 |
+
| 0.4557 | 15000 | 0.0197 | 0.0827 |
|
164 |
+
| 0.6076 | 20000 | 0.0031 | 0.0883 |
|
165 |
+
| 0.7595 | 25000 | 0.0439 | 0.0865 |
|
166 |
+
| 0.9114 | 30000 | 0.0029 | 0.0914 |
|
167 |
+
|
168 |
+
### Environmental Impact
|
169 |
+
Carbon emissions were measured using [CodeCarbon](https://github.com/mlco2/codecarbon).
|
170 |
+
- **Carbon Emitted**: 0.268 kg of CO2
|
171 |
+
- **Hours Used**: 2.03 hours
|
172 |
+
|
173 |
+
### Training Hardware
|
174 |
+
- **On Cloud**: No
|
175 |
+
- **GPU Model**: 1 x Tesla V100-SXM2-16GB
|
176 |
+
- **CPU Model**: Intel(R) Xeon(R) CPU @ 2.20GHz
|
177 |
+
- **RAM Size**: 12.67 GB
|
178 |
+
|
179 |
+
### Framework Versions
|
180 |
+
- Python: 3.10.12
|
181 |
+
- SetFit: 1.0.3
|
182 |
+
- Sentence Transformers: 2.3.1
|
183 |
+
- Transformers: 4.35.2
|
184 |
+
- PyTorch: 2.1.0+cu121
|
185 |
+
- Datasets: 2.17.0
|
186 |
+
- Tokenizers: 0.15.2
|
187 |
+
|
188 |
+
## Citation
|
189 |
+
|
190 |
+
### BibTeX
|
191 |
+
```bibtex
|
192 |
+
@article{https://doi.org/10.48550/arxiv.2209.11055,
|
193 |
+
doi = {10.48550/ARXIV.2209.11055},
|
194 |
+
url = {https://arxiv.org/abs/2209.11055},
|
195 |
+
author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
|
196 |
+
keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
|
197 |
+
title = {Efficient Few-Shot Learning Without Prompts},
|
198 |
+
publisher = {arXiv},
|
199 |
+
year = {2022},
|
200 |
+
copyright = {Creative Commons Attribution 4.0 International}
|
201 |
+
}
|
202 |
+
```
|
203 |
+
|
204 |
+
<!--
|
205 |
+
## Glossary
|
206 |
+
|
207 |
+
*Clearly define terms in order to be accessible across audiences.*
|
208 |
+
-->
|
209 |
+
|
210 |
+
<!--
|
211 |
+
## Model Card Authors
|
212 |
+
|
213 |
+
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
|
214 |
+
-->
|
215 |
+
|
216 |
+
<!--
|
217 |
+
## Model Card Contact
|
218 |
+
|
219 |
+
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
|
220 |
+
-->
|
config.json
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "BAAI/bge-base-en-v1.5",
|
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 |
+
"id2label": {
|
13 |
+
"0": "LABEL_0"
|
14 |
+
},
|
15 |
+
"initializer_range": 0.02,
|
16 |
+
"intermediate_size": 3072,
|
17 |
+
"label2id": {
|
18 |
+
"LABEL_0": 0
|
19 |
+
},
|
20 |
+
"layer_norm_eps": 1e-12,
|
21 |
+
"max_position_embeddings": 512,
|
22 |
+
"model_type": "bert",
|
23 |
+
"num_attention_heads": 12,
|
24 |
+
"num_hidden_layers": 12,
|
25 |
+
"pad_token_id": 0,
|
26 |
+
"position_embedding_type": "absolute",
|
27 |
+
"torch_dtype": "float32",
|
28 |
+
"transformers_version": "4.35.2",
|
29 |
+
"type_vocab_size": 2,
|
30 |
+
"use_cache": true,
|
31 |
+
"vocab_size": 30522
|
32 |
+
}
|
config_sentence_transformers.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"__version__": {
|
3 |
+
"sentence_transformers": "2.2.2",
|
4 |
+
"transformers": "4.28.1",
|
5 |
+
"pytorch": "1.13.0+cu117"
|
6 |
+
}
|
7 |
+
}
|
config_setfit.json
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"normalize_embeddings": true,
|
3 |
+
"labels": [
|
4 |
+
"GHGLabel",
|
5 |
+
"NetzeroLabel",
|
6 |
+
"NonGHGLabel"
|
7 |
+
]
|
8 |
+
}
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a471343df3045f10e592c2ab4acde1b7a94710eb246bd36f3a7ec722ea2e11f4
|
3 |
+
size 437951328
|
model_head.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5818d39dd0b125cf38b0ba4d989524e1853f3f13f7fc23a053b799fdf6708d2c
|
3 |
+
size 10778
|
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": 512,
|
3 |
+
"do_lower_case": true
|
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,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
"model_max_length": 512,
|
50 |
+
"never_split": null,
|
51 |
+
"pad_token": "[PAD]",
|
52 |
+
"sep_token": "[SEP]",
|
53 |
+
"strip_accents": null,
|
54 |
+
"tokenize_chinese_chars": true,
|
55 |
+
"tokenizer_class": "BertTokenizer",
|
56 |
+
"unk_token": "[UNK]"
|
57 |
+
}
|
vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|