srijithrajamohan commited on
Commit
4aefdb2
·
1 Parent(s): 79f7b65

First commit of README file

Browse files
Files changed (1) hide show
  1. README.md +436 -3
README.md CHANGED
@@ -1,3 +1,436 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - sentence-transformers
4
+ - sentence-similarity
5
+ - feature-extraction
6
+ - generated_from_trainer
7
+ - dataset_size:2438
8
+ - loss:MatryoshkaLoss
9
+ - loss:OnlineContrastiveLoss
10
+ base_model: Alibaba-NLP/gte-modernbert-base
11
+
12
+ pipeline_tag: sentence-similarity
13
+ library_name: sentence-transformers
14
+ metrics:
15
+ - cosine_accuracy
16
+ - cosine_accuracy_threshold
17
+ - cosine_f1
18
+ - cosine_f1_threshold
19
+ - cosine_precision
20
+ - cosine_recall
21
+ - cosine_ap
22
+ - cosine_mcc
23
+ model-index:
24
+ - name: SentenceTransformer based on Alibaba-NLP/gte-modernbert-base
25
+ results:
26
+ - task:
27
+ type: my-binary-classification
28
+ name: My Binary Classification
29
+ dataset:
30
+ name: Unknown
31
+ type: unknown
32
+ metrics:
33
+ - type: cosine_accuracy
34
+ value: 0.9159836065573771
35
+ name: Cosine Accuracy
36
+ - type: cosine_accuracy_threshold
37
+ value: 0.8090976476669312
38
+ name: Cosine Accuracy Threshold
39
+ - type: cosine_f1
40
+ value: 0.9216061185468452
41
+ name: Cosine F1
42
+ - type: cosine_f1_threshold
43
+ value: 0.8090976476669312
44
+ name: Cosine F1 Threshold
45
+ - type: cosine_precision
46
+ value: 0.9305019305019305
47
+ name: Cosine Precision
48
+ - type: cosine_recall
49
+ value: 0.9128787878787878
50
+ name: Cosine Recall
51
+ - type: cosine_ap
52
+ value: 0.974188222191262
53
+ name: Cosine Ap
54
+ - type: cosine_mcc
55
+ value: 0.8312925398469787
56
+ name: Cosine Mcc
57
+ ---
58
+
59
+ # SentenceTransformer based on Alibaba-NLP/gte-modernbert-base
60
+
61
+ This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [Alibaba-NLP/gte-modernbert-base](https://huggingface.co/Alibaba-NLP/gte-modernbert-base) on the csv dataset. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
62
+
63
+ ## Model Details
64
+
65
+ ### Model Description
66
+ - **Model Type:** Sentence Transformer
67
+ - **Base model:** [Alibaba-NLP/gte-modernbert-base](https://huggingface.co/Alibaba-NLP/gte-modernbert-base) <!-- at revision bc02f0a92d1b6dd82108036f6cb4b7b423fb7434 -->
68
+ - **Maximum Sequence Length:** 8192 tokens
69
+ - **Output Dimensionality:** 768 dimensions
70
+ - **Similarity Function:** Cosine Similarity
71
+ - **Training Dataset:**
72
+ - csv
73
+ <!-- - **Language:** Unknown -->
74
+ <!-- - **License:** Unknown -->
75
+
76
+ ### Model Sources
77
+
78
+ - **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
79
+ - **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
80
+ - **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
81
+
82
+ ### Full Model Architecture
83
+
84
+ ```
85
+ SentenceTransformer(
86
+ (0): Transformer({'max_seq_length': 8192, 'do_lower_case': False}) with Transformer model: ModernBertModel
87
+ (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
88
+ )
89
+ ```
90
+
91
+ ## Usage
92
+
93
+ ### Direct Usage (Sentence Transformers)
94
+
95
+ First install the Sentence Transformers library:
96
+
97
+ ```bash
98
+ pip install -U sentence-transformers
99
+ ```
100
+
101
+ Then you can load this model and run inference.
102
+ ```python
103
+ from sentence_transformers import SentenceTransformer
104
+
105
+ # Download from the 🤗 Hub
106
+ model = SentenceTransformer("waris-gill/ModernBert-Medical-v1")
107
+ # Run inference
108
+ sentences = [
109
+ 'My rheumatologist said \'if a patient has lupus then prednisone doesn\'t work." why is that?',
110
+ "I have lupus,my rheumatologist told me that prednisone doesn't work in my case. Could you educate me why? What are my chances? ",
111
+ 'Hello doctor, my grandmother has 3rd degree bed sore. What can be done to help?',
112
+ ]
113
+ embeddings = model.encode(sentences)
114
+ print(embeddings.shape)
115
+ # [3, 768]
116
+
117
+ # Get the similarity scores for the embeddings
118
+ similarities = model.similarity(embeddings, embeddings)
119
+ print(similarities.shape)
120
+ # [3, 3]
121
+ ```
122
+
123
+ <!--
124
+ ### Direct Usage (Transformers)
125
+
126
+ <details><summary>Click to see the direct usage in Transformers</summary>
127
+
128
+ </details>
129
+ -->
130
+
131
+ <!--
132
+ ### Downstream Usage (Sentence Transformers)
133
+
134
+ You can finetune this model on your own dataset.
135
+
136
+ <details><summary>Click to expand</summary>
137
+
138
+ </details>
139
+ -->
140
+
141
+ <!--
142
+ ### Out-of-Scope Use
143
+
144
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
145
+ -->
146
+
147
+ ## Evaluation
148
+
149
+ ### Metrics
150
+
151
+ #### My Binary Classification
152
+
153
+ * Evaluated with <code>scache.train.MyBinaryClassificationEvaluator</code>
154
+
155
+ | Metric | Value |
156
+ |:--------------------------|:-----------|
157
+ | cosine_accuracy | 0.916 |
158
+ | cosine_accuracy_threshold | 0.8091 |
159
+ | cosine_f1 | 0.9216 |
160
+ | cosine_f1_threshold | 0.8091 |
161
+ | cosine_precision | 0.9305 |
162
+ | cosine_recall | 0.9129 |
163
+ | **cosine_ap** | **0.9742** |
164
+ | cosine_mcc | 0.8313 |
165
+
166
+ <!--
167
+ ## Bias, Risks and Limitations
168
+
169
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
170
+ -->
171
+
172
+ <!--
173
+ ### Recommendations
174
+
175
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
176
+ -->
177
+
178
+ ## Training Details
179
+
180
+ ### Training Dataset
181
+
182
+ #### csv
183
+
184
+ * Dataset: csv
185
+ * Size: 2,438 training samples
186
+ * Columns: <code>question_1</code>, <code>question_2</code>, and <code>label</code>
187
+ * Approximate statistics based on the first 1000 samples:
188
+
189
+ * Loss: [<code>MatryoshkaLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#matryoshkaloss) with these parameters:
190
+ ```json
191
+ {
192
+ "loss": "OnlineContrastiveLoss",
193
+ "matryoshka_dims": [
194
+ 768,
195
+ 512,
196
+ 256,
197
+ 128,
198
+ 64
199
+ ],
200
+ "matryoshka_weights": [
201
+ 1,
202
+ 1,
203
+ 1,
204
+ 1,
205
+ 1
206
+ ],
207
+ "n_dims_per_step": -1
208
+ }
209
+ ```
210
+
211
+ ### Evaluation Dataset
212
+
213
+ #### csv
214
+
215
+ * Dataset: csv
216
+ * Size: 2,438 evaluation samples
217
+
218
+
219
+ ### Training Hyperparameters
220
+ #### Non-Default Hyperparameters
221
+
222
+ - `eval_strategy`: steps
223
+ - `per_device_train_batch_size`: 16
224
+ - `per_device_eval_batch_size`: 256
225
+ - `learning_rate`: 6.5383156211679e-05
226
+ - `max_grad_norm`: 0.5
227
+ - `num_train_epochs`: 1
228
+ - `lr_scheduler_type`: constant
229
+ - `load_best_model_at_end`: True
230
+ - `torch_compile`: True
231
+ - `torch_compile_backend`: inductor
232
+ - `batch_sampler`: no_duplicates
233
+
234
+ #### All Hyperparameters
235
+ <details><summary>Click to expand</summary>
236
+
237
+ - `overwrite_output_dir`: False
238
+ - `do_predict`: False
239
+ - `eval_strategy`: steps
240
+ - `prediction_loss_only`: True
241
+ - `per_device_train_batch_size`: 16
242
+ - `per_device_eval_batch_size`: 256
243
+ - `per_gpu_train_batch_size`: None
244
+ - `per_gpu_eval_batch_size`: None
245
+ - `gradient_accumulation_steps`: 1
246
+ - `eval_accumulation_steps`: None
247
+ - `torch_empty_cache_steps`: None
248
+ - `learning_rate`: 6.5383156211679e-05
249
+ - `weight_decay`: 0.0
250
+ - `adam_beta1`: 0.9
251
+ - `adam_beta2`: 0.999
252
+ - `adam_epsilon`: 1e-08
253
+ - `max_grad_norm`: 0.5
254
+ - `num_train_epochs`: 1
255
+ - `max_steps`: -1
256
+ - `lr_scheduler_type`: constant
257
+ - `lr_scheduler_kwargs`: {}
258
+ - `warmup_ratio`: 0.0
259
+ - `warmup_steps`: 0
260
+ - `log_level`: passive
261
+ - `log_level_replica`: warning
262
+ - `log_on_each_node`: True
263
+ - `logging_nan_inf_filter`: True
264
+ - `save_safetensors`: True
265
+ - `save_on_each_node`: False
266
+ - `save_only_model`: False
267
+ - `restore_callback_states_from_checkpoint`: False
268
+ - `no_cuda`: False
269
+ - `use_cpu`: False
270
+ - `use_mps_device`: False
271
+ - `seed`: 42
272
+ - `data_seed`: None
273
+ - `jit_mode_eval`: False
274
+ - `use_ipex`: False
275
+ - `bf16`: False
276
+ - `fp16`: False
277
+ - `fp16_opt_level`: O1
278
+ - `half_precision_backend`: auto
279
+ - `bf16_full_eval`: False
280
+ - `fp16_full_eval`: False
281
+ - `tf32`: None
282
+ - `local_rank`: 0
283
+ - `ddp_backend`: None
284
+ - `tpu_num_cores`: None
285
+ - `tpu_metrics_debug`: False
286
+ - `debug`: []
287
+ - `dataloader_drop_last`: False
288
+ - `dataloader_num_workers`: 0
289
+ - `dataloader_prefetch_factor`: None
290
+ - `past_index`: -1
291
+ - `disable_tqdm`: False
292
+ - `remove_unused_columns`: True
293
+ - `label_names`: None
294
+ - `load_best_model_at_end`: True
295
+ - `ignore_data_skip`: False
296
+ - `fsdp`: []
297
+ - `fsdp_min_num_params`: 0
298
+ - `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
299
+ - `fsdp_transformer_layer_cls_to_wrap`: None
300
+ - `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
301
+ - `deepspeed`: None
302
+ - `label_smoothing_factor`: 0.0
303
+ - `optim`: adamw_torch
304
+ - `optim_args`: None
305
+ - `adafactor`: False
306
+ - `group_by_length`: False
307
+ - `length_column_name`: length
308
+ - `ddp_find_unused_parameters`: None
309
+ - `ddp_bucket_cap_mb`: None
310
+ - `ddp_broadcast_buffers`: False
311
+ - `dataloader_pin_memory`: True
312
+ - `dataloader_persistent_workers`: False
313
+ - `skip_memory_metrics`: True
314
+ - `use_legacy_prediction_loop`: False
315
+ - `push_to_hub`: False
316
+ - `resume_from_checkpoint`: None
317
+ - `hub_model_id`: None
318
+ - `hub_strategy`: every_save
319
+ - `hub_private_repo`: None
320
+ - `hub_always_push`: False
321
+ - `gradient_checkpointing`: False
322
+ - `gradient_checkpointing_kwargs`: None
323
+ - `include_inputs_for_metrics`: False
324
+ - `include_for_metrics`: []
325
+ - `eval_do_concat_batches`: True
326
+ - `fp16_backend`: auto
327
+ - `push_to_hub_model_id`: None
328
+ - `push_to_hub_organization`: None
329
+ - `mp_parameters`:
330
+ - `auto_find_batch_size`: False
331
+ - `full_determinism`: False
332
+ - `torchdynamo`: None
333
+ - `ray_scope`: last
334
+ - `ddp_timeout`: 1800
335
+ - `torch_compile`: True
336
+ - `torch_compile_backend`: inductor
337
+ - `torch_compile_mode`: None
338
+ - `dispatch_batches`: None
339
+ - `split_batches`: None
340
+ - `include_tokens_per_second`: False
341
+ - `include_num_input_tokens_seen`: False
342
+ - `neftune_noise_alpha`: None
343
+ - `optim_target_modules`: None
344
+ - `batch_eval_metrics`: False
345
+ - `eval_on_start`: False
346
+ - `use_liger_kernel`: False
347
+ - `eval_use_gather_object`: False
348
+ - `average_tokens_across_devices`: False
349
+ - `prompts`: None
350
+ - `batch_sampler`: no_duplicates
351
+ - `multi_dataset_batch_sampler`: proportional
352
+
353
+ </details>
354
+
355
+ ### Training Logs
356
+ | Epoch | Step | Training Loss | Validation Loss | cosine_ap |
357
+ |:----------:|:------:|:-------------:|:---------------:|:----------:|
358
+ | 0.0323 | 1 | 4.4977 | - | - |
359
+ | 0.0645 | 2 | 4.9952 | - | - |
360
+ | 0.0968 | 3 | 2.9984 | - | - |
361
+ | 0.1290 | 4 | 4.8052 | - | - |
362
+ | 0.1613 | 5 | 4.0031 | - | - |
363
+ | 0.1935 | 6 | 3.7682 | - | - |
364
+ | 0.2258 | 7 | 4.0361 | - | - |
365
+ | 0.2581 | 8 | 3.4003 | - | - |
366
+ | 0.2903 | 9 | 1.1674 | - | - |
367
+ | **0.3226** | **10** | **2.3826** | **14.3756** | **0.9742** |
368
+ | 0.3548 | 11 | 3.8777 | - | - |
369
+ | 0.3871 | 12 | 2.6367 | - | - |
370
+ | 0.4194 | 13 | 2.5763 | - | - |
371
+ | 0.4516 | 14 | 3.5591 | - | - |
372
+ | 0.4839 | 15 | 2.3568 | - | - |
373
+ | 0.5161 | 16 | 2.9432 | - | - |
374
+ | 0.5484 | 17 | 2.746 | - | - |
375
+ | 0.5806 | 18 | 3.647 | - | - |
376
+ | 0.6129 | 19 | 3.0907 | - | - |
377
+ | 0.6452 | 20 | 3.9776 | 12.4766 | 0.9771 |
378
+ | 0.6774 | 21 | 3.4131 | - | - |
379
+ | 0.7097 | 22 | 3.0084 | - | - |
380
+ | 0.7419 | 23 | 2.7182 | - | - |
381
+ | 0.7742 | 24 | 1.5211 | - | - |
382
+ | 0.8065 | 25 | 1.8332 | - | - |
383
+ | 0.8387 | 26 | 3.4883 | - | - |
384
+ | 0.8710 | 27 | 2.0585 | - | - |
385
+ | 0.9032 | 28 | 2.775 | - | - |
386
+ | 0.9355 | 29 | 2.9137 | - | - |
387
+ | 0.9677 | 30 | 2.4238 | 12.4805 | 0.9769 |
388
+ | 1.0 | 31 | 1.2115 | 14.3756 | 0.9742 |
389
+
390
+ * The bold row denotes the saved checkpoint.
391
+
392
+ ### Framework Versions
393
+ - Python: 3.11.11
394
+ - Sentence Transformers: 3.4.1
395
+ - Transformers: 4.49.0
396
+ - PyTorch: 2.5.1+cu124
397
+ - Accelerate: 1.4.0
398
+ - Datasets: 3.3.2
399
+ - Tokenizers: 0.21.0
400
+
401
+ ## Citation
402
+
403
+ ### BibTeX
404
+
405
+ #### Sentence Transformers
406
+ ```bibtex
407
+ @inproceedings{reimers-2019-sentence-bert,
408
+ title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
409
+ author = "Reimers, Nils and Gurevych, Iryna",
410
+ booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
411
+ month = "11",
412
+ year = "2019",
413
+ publisher = "Association for Computational Linguistics",
414
+ url = "https://arxiv.org/abs/1908.10084",
415
+ }
416
+ ```
417
+
418
+
419
+
420
+ <!--
421
+ ## Glossary
422
+
423
+ *Clearly define terms in order to be accessible across audiences.*
424
+ -->
425
+
426
+ <!--
427
+ ## Model Card Authors
428
+
429
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
430
+ -->
431
+
432
+ <!--
433
+ ## Model Card Contact
434
+
435
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
436
+ -->