MiguelRod commited on
Commit
d402ee3
·
verified ·
1 Parent(s): bc0a1ed

Upload folder using huggingface_hub

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
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
+ "pooling_mode_weightedmean_tokens": false,
8
+ "pooling_mode_lasttoken": false,
9
+ "include_prompt": true
10
+ }
README.md ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - setfit
4
+ - sentence-transformers
5
+ - text-classification
6
+ - generated_from_setfit_trainer
7
+ widget:
8
+ - text: 'lymphocyte activation: Morphologic alteration of small B LYMPHOCYTES or T
9
+ LYMPHOCYTES in culture into large blast-like cells able to synthesize DNA and
10
+ RNA and to divide mitotically. It is induced by INTERLEUKINS; MITOGENS such as
11
+ PHYTOHEMAGGLUTININS, and by specific ANTIGENS. It may also occur in vivo as in
12
+ GRAFT REJECTION.'
13
+ - text: 'burns: Injuries to tissues caused by contact with heat, steam, chemicals
14
+ (BURNS, CHEMICAL), electricity (BURNS, ELECTRIC), or the like.'
15
+ - text: 'solutions: "The homogeneous mixtures formed by the mixing of a solid, liquid,
16
+ or gaseous substance (solute) with a liquid (the solvent), from which the dissolved
17
+ substances can be recovered by physical processes. (From Grant & Hackhs Chemical
18
+ Dictionary, 5th ed)"'
19
+ - text: 'tooth discoloration: Any change in the hue, color, or translucency of a tooth
20
+ due to any cause. Restorative filling materials, drugs (both topical and systemic),
21
+ pulpal necrosis, or hemorrhage may be responsible. (Jablonski, Dictionary of Dentistry,
22
+ 1992, p253)'
23
+ - text: 'foreign-body reaction: Chronic inflammation and granuloma formation around
24
+ irritating foreign bodies.'
25
+ metrics:
26
+ - accuracy
27
+ pipeline_tag: text-classification
28
+ library_name: setfit
29
+ inference: false
30
+ base_model: cambridgeltl/SapBERT-from-PubMedBERT-fulltext
31
+ model-index:
32
+ - name: SetFit with cambridgeltl/SapBERT-from-PubMedBERT-fulltext
33
+ results:
34
+ - task:
35
+ type: text-classification
36
+ name: Text Classification
37
+ dataset:
38
+ name: Unknown
39
+ type: unknown
40
+ split: test
41
+ metrics:
42
+ - type: accuracy
43
+ value: 0.5240963855421686
44
+ name: Accuracy
45
+ ---
46
+
47
+ # SetFit with cambridgeltl/SapBERT-from-PubMedBERT-fulltext
48
+
49
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [cambridgeltl/SapBERT-from-PubMedBERT-fulltext](https://huggingface.co/cambridgeltl/SapBERT-from-PubMedBERT-fulltext) as the Sentence Transformer embedding model. A OneVsRestClassifier instance is used for classification.
50
+
51
+ The model has been trained using an efficient few-shot learning technique that involves:
52
+
53
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
54
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
55
+
56
+ ## Model Details
57
+
58
+ ### Model Description
59
+ - **Model Type:** SetFit
60
+ - **Sentence Transformer body:** [cambridgeltl/SapBERT-from-PubMedBERT-fulltext](https://huggingface.co/cambridgeltl/SapBERT-from-PubMedBERT-fulltext)
61
+ - **Classification head:** a OneVsRestClassifier instance
62
+ - **Maximum Sequence Length:** 512 tokens
63
+ <!-- - **Number of Classes:** Unknown -->
64
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
65
+ <!-- - **Language:** Unknown -->
66
+ <!-- - **License:** Unknown -->
67
+
68
+ ### Model Sources
69
+
70
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
71
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
72
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
73
+
74
+ ## Evaluation
75
+
76
+ ### Metrics
77
+ | Label | Accuracy |
78
+ |:--------|:---------|
79
+ | **all** | 0.5241 |
80
+
81
+ ## Uses
82
+
83
+ ### Direct Use for Inference
84
+
85
+ First install the SetFit library:
86
+
87
+ ```bash
88
+ pip install setfit
89
+ ```
90
+
91
+ Then you can load this model and run inference.
92
+
93
+ ```python
94
+ from setfit import SetFitModel
95
+
96
+ # Download from the 🤗 Hub
97
+ model = SetFitModel.from_pretrained("setfit_model_id")
98
+ # Run inference
99
+ preds = model("foreign-body reaction: Chronic inflammation and granuloma formation around irritating foreign bodies.")
100
+ ```
101
+
102
+ <!--
103
+ ### Downstream Use
104
+
105
+ *List how someone could finetune this model on their own dataset.*
106
+ -->
107
+
108
+ <!--
109
+ ### Out-of-Scope Use
110
+
111
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
112
+ -->
113
+
114
+ <!--
115
+ ## Bias, Risks and Limitations
116
+
117
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
118
+ -->
119
+
120
+ <!--
121
+ ### Recommendations
122
+
123
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
124
+ -->
125
+
126
+ ## Training Details
127
+
128
+ ### Training Set Metrics
129
+ | Training set | Min | Median | Max |
130
+ |:-------------|:----|:--------|:----|
131
+ | Word count | 2 | 30.4473 | 134 |
132
+
133
+ ### Training Hyperparameters
134
+ - batch_size: (16, 16)
135
+ - num_epochs: (1, 1)
136
+ - max_steps: -1
137
+ - sampling_strategy: oversampling
138
+ - num_iterations: 20
139
+ - body_learning_rate: (2e-05, 2e-05)
140
+ - head_learning_rate: 2e-05
141
+ - loss: CosineSimilarityLoss
142
+ - distance_metric: cosine_distance
143
+ - margin: 0.25
144
+ - end_to_end: False
145
+ - use_amp: False
146
+ - warmup_proportion: 0.1
147
+ - l2_weight: 0.01
148
+ - seed: 42
149
+ - eval_max_steps: -1
150
+ - load_best_model_at_end: False
151
+
152
+ ### Training Results
153
+ | Epoch | Step | Training Loss | Validation Loss |
154
+ |:------:|:----:|:-------------:|:---------------:|
155
+ | 0.0003 | 1 | 0.2929 | - |
156
+ | 0.0136 | 50 | 0.2377 | - |
157
+ | 0.0272 | 100 | 0.2321 | - |
158
+ | 0.0408 | 150 | 0.2199 | - |
159
+ | 0.0544 | 200 | 0.1726 | - |
160
+ | 0.0680 | 250 | 0.1355 | - |
161
+ | 0.0816 | 300 | 0.1207 | - |
162
+ | 0.0952 | 350 | 0.1138 | - |
163
+ | 0.1088 | 400 | 0.1154 | - |
164
+ | 0.1223 | 450 | 0.095 | - |
165
+ | 0.1359 | 500 | 0.106 | - |
166
+ | 0.1495 | 550 | 0.0913 | - |
167
+ | 0.1631 | 600 | 0.0943 | - |
168
+ | 0.1767 | 650 | 0.0974 | - |
169
+ | 0.1903 | 700 | 0.0923 | - |
170
+ | 0.2039 | 750 | 0.0893 | - |
171
+ | 0.2175 | 800 | 0.0804 | - |
172
+ | 0.2311 | 850 | 0.0849 | - |
173
+ | 0.2447 | 900 | 0.0766 | - |
174
+ | 0.2583 | 950 | 0.0838 | - |
175
+ | 0.2719 | 1000 | 0.0725 | - |
176
+ | 0.2855 | 1050 | 0.073 | - |
177
+ | 0.2991 | 1100 | 0.055 | - |
178
+ | 0.3127 | 1150 | 0.0758 | - |
179
+ | 0.3263 | 1200 | 0.0709 | - |
180
+ | 0.3399 | 1250 | 0.0569 | - |
181
+ | 0.3535 | 1300 | 0.0535 | - |
182
+ | 0.3670 | 1350 | 0.0557 | - |
183
+ | 0.3806 | 1400 | 0.0596 | - |
184
+ | 0.3942 | 1450 | 0.0453 | - |
185
+ | 0.4078 | 1500 | 0.0428 | - |
186
+ | 0.4214 | 1550 | 0.0482 | - |
187
+ | 0.4350 | 1600 | 0.0465 | - |
188
+ | 0.4486 | 1650 | 0.0469 | - |
189
+ | 0.4622 | 1700 | 0.0479 | - |
190
+ | 0.4758 | 1750 | 0.0451 | - |
191
+ | 0.4894 | 1800 | 0.0613 | - |
192
+ | 0.5030 | 1850 | 0.0533 | - |
193
+ | 0.5166 | 1900 | 0.0476 | - |
194
+ | 0.5302 | 1950 | 0.0449 | - |
195
+ | 0.5438 | 2000 | 0.0543 | - |
196
+ | 0.5574 | 2050 | 0.0509 | - |
197
+ | 0.5710 | 2100 | 0.043 | - |
198
+ | 0.5846 | 2150 | 0.0482 | - |
199
+ | 0.5982 | 2200 | 0.0513 | - |
200
+ | 0.6117 | 2250 | 0.0366 | - |
201
+ | 0.6253 | 2300 | 0.0385 | - |
202
+ | 0.6389 | 2350 | 0.0446 | - |
203
+ | 0.6525 | 2400 | 0.0411 | - |
204
+ | 0.6661 | 2450 | 0.037 | - |
205
+ | 0.6797 | 2500 | 0.0321 | - |
206
+ | 0.6933 | 2550 | 0.0468 | - |
207
+ | 0.7069 | 2600 | 0.0331 | - |
208
+ | 0.7205 | 2650 | 0.0315 | - |
209
+ | 0.7341 | 2700 | 0.0435 | - |
210
+ | 0.7477 | 2750 | 0.0394 | - |
211
+ | 0.7613 | 2800 | 0.0381 | - |
212
+ | 0.7749 | 2850 | 0.0418 | - |
213
+ | 0.7885 | 2900 | 0.0347 | - |
214
+ | 0.8021 | 2950 | 0.0468 | - |
215
+ | 0.8157 | 3000 | 0.0352 | - |
216
+ | 0.8293 | 3050 | 0.0416 | - |
217
+ | 0.8428 | 3100 | 0.0354 | - |
218
+ | 0.8564 | 3150 | 0.0329 | - |
219
+ | 0.8700 | 3200 | 0.0359 | - |
220
+ | 0.8836 | 3250 | 0.036 | - |
221
+ | 0.8972 | 3300 | 0.0362 | - |
222
+ | 0.9108 | 3350 | 0.0296 | - |
223
+ | 0.9244 | 3400 | 0.041 | - |
224
+ | 0.9380 | 3450 | 0.0375 | - |
225
+ | 0.9516 | 3500 | 0.0282 | - |
226
+ | 0.9652 | 3550 | 0.0341 | - |
227
+ | 0.9788 | 3600 | 0.0283 | - |
228
+ | 0.9924 | 3650 | 0.0339 | - |
229
+
230
+ ### Framework Versions
231
+ - Python: 3.11.11
232
+ - SetFit: 1.1.1
233
+ - Sentence Transformers: 3.4.1
234
+ - Transformers: 4.50.0
235
+ - PyTorch: 2.6.0+cu124
236
+ - Datasets: 3.4.1
237
+ - Tokenizers: 0.21.1
238
+
239
+ ## Citation
240
+
241
+ ### BibTeX
242
+ ```bibtex
243
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
244
+ doi = {10.48550/ARXIV.2209.11055},
245
+ url = {https://arxiv.org/abs/2209.11055},
246
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
247
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
248
+ title = {Efficient Few-Shot Learning Without Prompts},
249
+ publisher = {arXiv},
250
+ year = {2022},
251
+ copyright = {Creative Commons Attribution 4.0 International}
252
+ }
253
+ ```
254
+
255
+ <!--
256
+ ## Glossary
257
+
258
+ *Clearly define terms in order to be accessible across audiences.*
259
+ -->
260
+
261
+ <!--
262
+ ## Model Card Authors
263
+
264
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
265
+ -->
266
+
267
+ <!--
268
+ ## Model Card Contact
269
+
270
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
271
+ -->
config.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertModel"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "classifier_dropout": null,
7
+ "gradient_checkpointing": false,
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 768,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 3072,
13
+ "layer_norm_eps": 1e-12,
14
+ "max_position_embeddings": 512,
15
+ "model_type": "bert",
16
+ "num_attention_heads": 12,
17
+ "num_hidden_layers": 12,
18
+ "pad_token_id": 0,
19
+ "position_embedding_type": "absolute",
20
+ "torch_dtype": "float32",
21
+ "transformers_version": "4.50.0",
22
+ "type_vocab_size": 2,
23
+ "use_cache": true,
24
+ "vocab_size": 30522
25
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "3.4.1",
4
+ "transformers": "4.50.0",
5
+ "pytorch": "2.6.0+cu124"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null,
9
+ "similarity_fn_name": "cosine"
10
+ }
config_setfit.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "labels": null,
3
+ "normalize_embeddings": false
4
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:11551bb0e8b36527ccbb9c561b54ed3f3a59e124e3a194baae2c942e1e4c4fa0
3
+ size 437951328
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cf59c6868d5270009202f730a22f0b7bd15a3a94cc4fa69578c6cefba8d421bc
3
+ size 150052
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
+ ]
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,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,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "1": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "4": {
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
+ "extra_special_tokens": {},
49
+ "full_tokenizer_file": null,
50
+ "mask_token": "[MASK]",
51
+ "model_max_length": 1000000000000000019884624838656,
52
+ "never_split": null,
53
+ "pad_token": "[PAD]",
54
+ "sep_token": "[SEP]",
55
+ "strip_accents": null,
56
+ "tokenize_chinese_chars": true,
57
+ "tokenizer_class": "BertTokenizer",
58
+ "unk_token": "[UNK]"
59
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff