sickcell69 commited on
Commit
2edb505
1 Parent(s): c5245e5

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +147 -381
  2. model.safetensors +1 -1
  3. modules.json +2 -8
README.md CHANGED
@@ -1,411 +1,177 @@
1
  ---
2
- base_model: sentence-transformers/all-MiniLM-L6-v2
3
- datasets: []
4
- language: []
5
  library_name: sentence-transformers
6
- pipeline_tag: sentence-similarity
7
  tags:
8
  - sentence-transformers
9
- - sentence-similarity
10
  - feature-extraction
11
- - generated_from_trainer
12
- - dataset_size:68874
13
- - loss:MultipleNegativesRankingLoss
14
- widget:
15
- - source_sentence: two extracts utilities, steal email. to .pst APT1 and uses MAPIGET,
16
- GETMAIL emails GETMAIL Outlook from
17
- sentences:
18
- - April wild using takes Security the vulnerabilities attack , , 360 the lead new
19
- in group’s the APT-C-06 2018 (CVE-2018-8174) the Core . 0-day In capturing
20
- - in have and used scheduled droppers to persistence payloads tasks
21
- - two extracts utilities, steal email. to .pst APT1 and uses MAPIGET, GETMAIL emails
22
- GETMAIL Outlook from
23
- - source_sentence: screen victim's remote has obtain machines. management tool monitoring
24
- from and to captures ConnectWise SOUTHFIELD the
25
- sentences:
26
- - months any last intense evolve over team faster gathering 24 than capabilities
27
- Operation . the the observed technical of effort During observed we , Iranian
28
- intelligence rapidly the
29
- - screen victim's remote has obtain machines. management tool monitoring from and
30
- to captures ConnectWise SOUTHFIELD the
31
- - C :\Windows\system32\cmd.exe /C shell whoami /all
32
- - source_sentence: values database registry passwords from
33
- sentences:
34
- - BARIUM , a Chinese state player that also goes by APT17 , Axiom and Deputy Dog
35
- , was previously linked to the ShadowPad and CCleaner incidents , which were also
36
- supply-chain attacks that used software updates to sneak onto machines .
37
- - It makes direct system calls using the “syscall” instruction.
38
- - values database registry passwords from
39
- - source_sentence: Bazar can inject code through calling <code>VirtualAllocExNuma</code>.
40
- sentences:
41
- - Bazar can inject code through calling <code>VirtualAllocExNuma</code>.
42
- - input redirected and (cmd.exe) output. a process MCMD launch with can
43
- - and status</code> uses located determine is System files searches <code>/Library/Preferences/</code>
44
- enabled. Integrity firewall in XCSSET to Protection configuration
45
- - source_sentence: to communications. Shark use ability in C2 HTTP
46
- sentences:
47
- - altered change adding hashes. four samples apparently a random bytes likely the
48
- to Patchwork file attempt letters of in
49
- - malware. to a download of specific execute KONNI used PowerShell 64-bit and
50
- - to communications. Shark use ability in C2 HTTP
51
  ---
52
 
53
- # SentenceTransformer based on sentence-transformers/all-MiniLM-L6-v2
54
 
55
- This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2). It maps sentences & paragraphs to a 128-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
 
56
 
57
- ## Model Details
 
58
 
59
- ### Model Description
60
- - **Model Type:** Sentence Transformer
61
- - **Base model:** [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) <!-- at revision 8b3219a92973c328a8e22fadcfa821b5dc75636a -->
62
- - **Maximum Sequence Length:** 256 tokens
63
- - **Output Dimensionality:** 128 tokens
64
- - **Similarity Function:** Cosine Similarity
65
- <!-- - **Training Dataset:** Unknown -->
66
- <!-- - **Language:** Unknown -->
67
- <!-- - **License:** Unknown -->
68
 
69
- ### Model Sources
 
 
 
70
 
71
- - **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
72
- - **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
73
- - **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
 
74
 
75
- ### Full Model Architecture
 
76
 
77
- ```
78
- SentenceTransformer(
79
- (0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: BertModel
80
- (1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
81
- (2): Dense({'in_features': 384, 'out_features': 128, 'bias': True, 'activation_function': 'torch.nn.modules.activation.Tanh'})
82
- (3): Dropout(
83
- (dropout_layer): Dropout(p=0.3, inplace=False)
84
- )
85
- )
86
- ```
87
 
88
- ## Usage
 
 
 
 
89
 
90
- ### Direct Usage (Sentence Transformers)
91
 
92
- First install the Sentence Transformers library:
 
93
 
94
- ```bash
95
- pip install -U sentence-transformers
96
- ```
97
 
98
- Then you can load this model and run inference.
99
- ```python
100
- from sentence_transformers import SentenceTransformer
101
 
102
- # Download from the 🤗 Hub
103
- model = SentenceTransformer("sentence_transformers_model_id")
104
- # Run inference
105
- sentences = [
106
- 'to communications. Shark use ability in C2 HTTP',
107
- 'to communications. Shark use ability in C2 HTTP',
108
- 'altered change adding hashes. four samples apparently a random bytes likely the to Patchwork file attempt letters of in',
109
- ]
110
- embeddings = model.encode(sentences)
111
- print(embeddings.shape)
112
- # [3, 128]
113
 
114
- # Get the similarity scores for the embeddings
115
- similarities = model.similarity(embeddings, embeddings)
116
- print(similarities.shape)
117
- # [3, 3]
118
- ```
119
 
120
- <!--
121
- ### Direct Usage (Transformers)
122
-
123
- <details><summary>Click to see the direct usage in Transformers</summary>
124
-
125
- </details>
126
- -->
127
-
128
- <!--
129
- ### Downstream Usage (Sentence Transformers)
130
-
131
- You can finetune this model on your own dataset.
132
-
133
- <details><summary>Click to expand</summary>
134
-
135
- </details>
136
- -->
137
-
138
- <!--
139
- ### Out-of-Scope Use
140
-
141
- *List how the model may foreseeably be misused and address what users ought not to do with the model.*
142
- -->
143
-
144
- <!--
145
- ## Bias, Risks and Limitations
146
-
147
- *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
148
- -->
149
-
150
- <!--
151
- ### Recommendations
152
-
153
- *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
154
- -->
155
-
156
- ## Training Details
157
-
158
- ### Training Dataset
159
-
160
- #### Unnamed Dataset
161
-
162
-
163
- * Size: 68,874 training samples
164
- * Columns: <code>sentence_0</code> and <code>sentence_1</code>
165
- * Approximate statistics based on the first 1000 samples:
166
- | | sentence_0 | sentence_1 |
167
- |:--------|:-----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|
168
- | type | string | string |
169
- | details | <ul><li>min: 3 tokens</li><li>mean: 24.91 tokens</li><li>max: 111 tokens</li></ul> | <ul><li>min: 3 tokens</li><li>mean: 24.91 tokens</li><li>max: 111 tokens</li></ul> |
170
- * Samples:
171
- | sentence_0 | sentence_1 |
172
- |:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
173
- | <code>RDAT can upload a file via HTTP POST response to the C2 split into 102,400-byte portions. RDAT can also download data from the C2 which is split into 81,920-byte portions.</code> | <code>RDAT can upload a file via HTTP POST response to the C2 split into 102,400-byte portions. RDAT can also download data from the C2 which is split into 81,920-byte portions.</code> |
174
- | <code>The threat actor attempted to compromise critical assets , such as database servers , billing servers , and the active directory .</code> | <code>The threat actor attempted to compromise critical assets , such as database servers , billing servers , and the active directory .</code> |
175
- | <code>computers leaked in two WannaCry , exploit Windows a any unpatched into turn EternalBlue computers used vulnerabilities to incorporated CVE-2017-0145 ransomware the vulnerable to the the . to victim's the that spreading connected and also capable other itself of network CVE-2017-0144 to worm and known</code> | <code>computers leaked in two WannaCry , exploit Windows a any unpatched into turn EternalBlue computers used vulnerabilities to incorporated CVE-2017-0145 ransomware the vulnerable to the the . to victim's the that spreading connected and also capable other itself of network CVE-2017-0144 to worm and known</code> |
176
- * Loss: [<code>MultipleNegativesRankingLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#multiplenegativesrankingloss) with these parameters:
177
- ```json
178
- {
179
- "scale": 20.0,
180
- "similarity_fct": "cos_sim"
181
- }
182
- ```
183
-
184
- ### Training Hyperparameters
185
- #### Non-Default Hyperparameters
186
-
187
- - `per_device_train_batch_size`: 16
188
- - `per_device_eval_batch_size`: 16
189
- - `num_train_epochs`: 5
190
- - `multi_dataset_batch_sampler`: round_robin
191
-
192
- #### All Hyperparameters
193
- <details><summary>Click to expand</summary>
194
-
195
- - `overwrite_output_dir`: False
196
- - `do_predict`: False
197
- - `eval_strategy`: no
198
- - `prediction_loss_only`: True
199
- - `per_device_train_batch_size`: 16
200
- - `per_device_eval_batch_size`: 16
201
- - `per_gpu_train_batch_size`: None
202
- - `per_gpu_eval_batch_size`: None
203
- - `gradient_accumulation_steps`: 1
204
- - `eval_accumulation_steps`: None
205
- - `torch_empty_cache_steps`: None
206
- - `learning_rate`: 5e-05
207
- - `weight_decay`: 0.0
208
- - `adam_beta1`: 0.9
209
- - `adam_beta2`: 0.999
210
- - `adam_epsilon`: 1e-08
211
- - `max_grad_norm`: 1
212
- - `num_train_epochs`: 5
213
- - `max_steps`: -1
214
- - `lr_scheduler_type`: linear
215
- - `lr_scheduler_kwargs`: {}
216
- - `warmup_ratio`: 0.0
217
- - `warmup_steps`: 0
218
- - `log_level`: passive
219
- - `log_level_replica`: warning
220
- - `log_on_each_node`: True
221
- - `logging_nan_inf_filter`: True
222
- - `save_safetensors`: True
223
- - `save_on_each_node`: False
224
- - `save_only_model`: False
225
- - `restore_callback_states_from_checkpoint`: False
226
- - `no_cuda`: False
227
- - `use_cpu`: False
228
- - `use_mps_device`: False
229
- - `seed`: 42
230
- - `data_seed`: None
231
- - `jit_mode_eval`: False
232
- - `use_ipex`: False
233
- - `bf16`: False
234
- - `fp16`: False
235
- - `fp16_opt_level`: O1
236
- - `half_precision_backend`: auto
237
- - `bf16_full_eval`: False
238
- - `fp16_full_eval`: False
239
- - `tf32`: None
240
- - `local_rank`: 0
241
- - `ddp_backend`: None
242
- - `tpu_num_cores`: None
243
- - `tpu_metrics_debug`: False
244
- - `debug`: []
245
- - `dataloader_drop_last`: False
246
- - `dataloader_num_workers`: 0
247
- - `dataloader_prefetch_factor`: None
248
- - `past_index`: -1
249
- - `disable_tqdm`: False
250
- - `remove_unused_columns`: True
251
- - `label_names`: None
252
- - `load_best_model_at_end`: False
253
- - `ignore_data_skip`: False
254
- - `fsdp`: []
255
- - `fsdp_min_num_params`: 0
256
- - `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
257
- - `fsdp_transformer_layer_cls_to_wrap`: None
258
- - `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
259
- - `deepspeed`: None
260
- - `label_smoothing_factor`: 0.0
261
- - `optim`: adamw_torch
262
- - `optim_args`: None
263
- - `adafactor`: False
264
- - `group_by_length`: False
265
- - `length_column_name`: length
266
- - `ddp_find_unused_parameters`: None
267
- - `ddp_bucket_cap_mb`: None
268
- - `ddp_broadcast_buffers`: False
269
- - `dataloader_pin_memory`: True
270
- - `dataloader_persistent_workers`: False
271
- - `skip_memory_metrics`: True
272
- - `use_legacy_prediction_loop`: False
273
- - `push_to_hub`: False
274
- - `resume_from_checkpoint`: None
275
- - `hub_model_id`: None
276
- - `hub_strategy`: every_save
277
- - `hub_private_repo`: False
278
- - `hub_always_push`: False
279
- - `gradient_checkpointing`: False
280
- - `gradient_checkpointing_kwargs`: None
281
- - `include_inputs_for_metrics`: False
282
- - `eval_do_concat_batches`: True
283
- - `fp16_backend`: auto
284
- - `push_to_hub_model_id`: None
285
- - `push_to_hub_organization`: None
286
- - `mp_parameters`:
287
- - `auto_find_batch_size`: False
288
- - `full_determinism`: False
289
- - `torchdynamo`: None
290
- - `ray_scope`: last
291
- - `ddp_timeout`: 1800
292
- - `torch_compile`: False
293
- - `torch_compile_backend`: None
294
- - `torch_compile_mode`: None
295
- - `dispatch_batches`: None
296
- - `split_batches`: None
297
- - `include_tokens_per_second`: False
298
- - `include_num_input_tokens_seen`: False
299
- - `neftune_noise_alpha`: None
300
- - `optim_target_modules`: None
301
- - `batch_eval_metrics`: False
302
- - `eval_on_start`: False
303
- - `eval_use_gather_object`: False
304
- - `batch_sampler`: batch_sampler
305
- - `multi_dataset_batch_sampler`: round_robin
306
-
307
- </details>
308
-
309
- ### Training Logs
310
- | Epoch | Step | Training Loss |
311
- |:------:|:-----:|:-------------:|
312
- | 0.1161 | 500 | 0.0029 |
313
- | 0.2323 | 1000 | 0.0017 |
314
- | 0.3484 | 1500 | 0.0015 |
315
- | 0.4646 | 2000 | 0.0015 |
316
- | 0.5807 | 2500 | 0.0023 |
317
- | 0.6969 | 3000 | 0.0016 |
318
- | 0.8130 | 3500 | 0.0017 |
319
- | 0.9292 | 4000 | 0.0013 |
320
- | 1.0453 | 4500 | 0.0011 |
321
- | 1.1614 | 5000 | 0.001 |
322
- | 1.2776 | 5500 | 0.0009 |
323
- | 1.3937 | 6000 | 0.0009 |
324
- | 1.5099 | 6500 | 0.0012 |
325
- | 1.6260 | 7000 | 0.0013 |
326
- | 1.7422 | 7500 | 0.0013 |
327
- | 1.8583 | 8000 | 0.0013 |
328
- | 1.9744 | 8500 | 0.0008 |
329
- | 2.0906 | 9000 | 0.0007 |
330
- | 2.2067 | 9500 | 0.0007 |
331
- | 2.3229 | 10000 | 0.0009 |
332
- | 2.4390 | 10500 | 0.0007 |
333
- | 2.5552 | 11000 | 0.0011 |
334
- | 2.6713 | 11500 | 0.0009 |
335
- | 2.7875 | 12000 | 0.0008 |
336
- | 2.9036 | 12500 | 0.0006 |
337
- | 3.0197 | 13000 | 0.0006 |
338
- | 3.1359 | 13500 | 0.0007 |
339
- | 3.2520 | 14000 | 0.0006 |
340
- | 3.3682 | 14500 | 0.0007 |
341
- | 3.4843 | 15000 | 0.0006 |
342
- | 3.6005 | 15500 | 0.0013 |
343
- | 3.7166 | 16000 | 0.0008 |
344
- | 3.8328 | 16500 | 0.0008 |
345
- | 3.9489 | 17000 | 0.0006 |
346
- | 4.0650 | 17500 | 0.0006 |
347
- | 4.1812 | 18000 | 0.0006 |
348
- | 4.2973 | 18500 | 0.0005 |
349
- | 4.4135 | 19000 | 0.0006 |
350
- | 4.5296 | 19500 | 0.0008 |
351
- | 4.6458 | 20000 | 0.0006 |
352
- | 4.7619 | 20500 | 0.0006 |
353
- | 4.8780 | 21000 | 0.0005 |
354
- | 4.9942 | 21500 | 0.0005 |
355
-
356
-
357
- ### Framework Versions
358
- - Python: 3.11.7
359
- - Sentence Transformers: 3.0.1
360
- - Transformers: 4.43.3
361
- - PyTorch: 2.4.0+cu118
362
- - Accelerate: 0.33.0
363
- - Datasets: 2.20.0
364
- - Tokenizers: 0.19.1
365
-
366
- ## Citation
367
-
368
- ### BibTeX
369
-
370
- #### Sentence Transformers
371
- ```bibtex
372
- @inproceedings{reimers-2019-sentence-bert,
373
- title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
374
- author = "Reimers, Nils and Gurevych, Iryna",
375
- booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
376
- month = "11",
377
- year = "2019",
378
- publisher = "Association for Computational Linguistics",
379
- url = "https://arxiv.org/abs/1908.10084",
380
- }
381
- ```
382
 
383
- #### MultipleNegativesRankingLoss
384
- ```bibtex
385
- @misc{henderson2017efficient,
386
- title={Efficient Natural Language Response Suggestion for Smart Reply},
387
- author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
388
- year={2017},
389
- eprint={1705.00652},
390
- archivePrefix={arXiv},
391
- primaryClass={cs.CL}
392
- }
393
  ```
394
 
395
- <!--
396
- ## Glossary
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
397
 
398
- *Clearly define terms in order to be accessible across audiences.*
399
- -->
 
400
 
401
- <!--
402
- ## Model Card Authors
403
 
404
- *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
405
- -->
406
 
407
- <!--
408
- ## Model Card Contact
409
 
410
- *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
411
- -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language: en
3
+ license: apache-2.0
 
4
  library_name: sentence-transformers
 
5
  tags:
6
  - sentence-transformers
 
7
  - feature-extraction
8
+ - sentence-similarity
9
+ - transformers
10
+ datasets:
11
+ - s2orc
12
+ - flax-sentence-embeddings/stackexchange_xml
13
+ - ms_marco
14
+ - gooaq
15
+ - yahoo_answers_topics
16
+ - code_search_net
17
+ - search_qa
18
+ - eli5
19
+ - snli
20
+ - multi_nli
21
+ - wikihow
22
+ - natural_questions
23
+ - trivia_qa
24
+ - embedding-data/sentence-compression
25
+ - embedding-data/flickr30k-captions
26
+ - embedding-data/altlex
27
+ - embedding-data/simple-wiki
28
+ - embedding-data/QQP
29
+ - embedding-data/SPECTER
30
+ - embedding-data/PAQ_pairs
31
+ - embedding-data/WikiAnswers
32
+ pipeline_tag: sentence-similarity
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  ---
34
 
 
35
 
36
+ # all-MiniLM-L6-v2
37
+ This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search.
38
 
39
+ ## Usage (Sentence-Transformers)
40
+ Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
41
 
42
+ ```
43
+ pip install -U sentence-transformers
44
+ ```
 
 
 
 
 
 
45
 
46
+ Then you can use the model like this:
47
+ ```python
48
+ from sentence_transformers import SentenceTransformer
49
+ sentences = ["This is an example sentence", "Each sentence is converted"]
50
 
51
+ model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
52
+ embeddings = model.encode(sentences)
53
+ print(embeddings)
54
+ ```
55
 
56
+ ## Usage (HuggingFace Transformers)
57
+ Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.
58
 
59
+ ```python
60
+ from transformers import AutoTokenizer, AutoModel
61
+ import torch
62
+ import torch.nn.functional as F
 
 
 
 
 
 
63
 
64
+ #Mean Pooling - Take attention mask into account for correct averaging
65
+ def mean_pooling(model_output, attention_mask):
66
+ token_embeddings = model_output[0] #First element of model_output contains all token embeddings
67
+ input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
68
+ return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
69
 
 
70
 
71
+ # Sentences we want sentence embeddings for
72
+ sentences = ['This is an example sentence', 'Each sentence is converted']
73
 
74
+ # Load model from HuggingFace Hub
75
+ tokenizer = AutoTokenizer.from_pretrained('sentence-transformers/all-MiniLM-L6-v2')
76
+ model = AutoModel.from_pretrained('sentence-transformers/all-MiniLM-L6-v2')
77
 
78
+ # Tokenize sentences
79
+ encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
 
80
 
81
+ # Compute token embeddings
82
+ with torch.no_grad():
83
+ model_output = model(**encoded_input)
 
 
 
 
 
 
 
 
84
 
85
+ # Perform pooling
86
+ sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
 
 
 
87
 
88
+ # Normalize embeddings
89
+ sentence_embeddings = F.normalize(sentence_embeddings, p=2, dim=1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
+ print("Sentence embeddings:")
92
+ print(sentence_embeddings)
 
 
 
 
 
 
 
 
93
  ```
94
 
95
+ ## Evaluation Results
96
+
97
+ For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name=sentence-transformers/all-MiniLM-L6-v2)
98
+
99
+ ------
100
+
101
+ ## Background
102
+
103
+ The project aims to train sentence embedding models on very large sentence level datasets using a self-supervised
104
+ contrastive learning objective. We used the pretrained [`nreimers/MiniLM-L6-H384-uncased`](https://huggingface.co/nreimers/MiniLM-L6-H384-uncased) model and fine-tuned in on a
105
+ 1B sentence pairs dataset. We use a contrastive learning objective: given a sentence from the pair, the model should predict which out of a set of randomly sampled other sentences, was actually paired with it in our dataset.
106
+
107
+ We developed this model during the
108
+ [Community week using JAX/Flax for NLP & CV](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104),
109
+ organized by Hugging Face. We developed this model as part of the project:
110
+ [Train the Best Sentence Embedding Model Ever with 1B Training Pairs](https://discuss.huggingface.co/t/train-the-best-sentence-embedding-model-ever-with-1b-training-pairs/7354). We benefited from efficient hardware infrastructure to run the project: 7 TPUs v3-8, as well as intervention from Googles Flax, JAX, and Cloud team member about efficient deep learning frameworks.
111
+
112
+ ## Intended uses
113
+
114
+ Our model is intended to be used as a sentence and short paragraph encoder. Given an input text, it outputs a vector which captures
115
+ the semantic information. The sentence vector may be used for information retrieval, clustering or sentence similarity tasks.
116
+
117
+ By default, input text longer than 256 word pieces is truncated.
118
+
119
+
120
+ ## Training procedure
121
+
122
+ ### Pre-training
123
+
124
+ We use the pretrained [`nreimers/MiniLM-L6-H384-uncased`](https://huggingface.co/nreimers/MiniLM-L6-H384-uncased) model. Please refer to the model card for more detailed information about the pre-training procedure.
125
+
126
+ ### Fine-tuning
127
+
128
+ We fine-tune the model using a contrastive objective. Formally, we compute the cosine similarity from each possible sentence pairs from the batch.
129
+ We then apply the cross entropy loss by comparing with true pairs.
130
+
131
+ #### Hyper parameters
132
 
133
+ We trained our model on a TPU v3-8. We train the model during 100k steps using a batch size of 1024 (128 per TPU core).
134
+ We use a learning rate warm up of 500. The sequence length was limited to 128 tokens. We used the AdamW optimizer with
135
+ a 2e-5 learning rate. The full training script is accessible in this current repository: `train_script.py`.
136
 
137
+ #### Training data
 
138
 
139
+ We use the concatenation from multiple datasets to fine-tune our model. The total number of sentence pairs is above 1 billion sentences.
140
+ We sampled each dataset given a weighted probability which configuration is detailed in the `data_config.json` file.
141
 
 
 
142
 
143
+ | Dataset | Paper | Number of training tuples |
144
+ |--------------------------------------------------------|:----------------------------------------:|:--------------------------:|
145
+ | [Reddit comments (2015-2018)](https://github.com/PolyAI-LDN/conversational-datasets/tree/master/reddit) | [paper](https://arxiv.org/abs/1904.06472) | 726,484,430 |
146
+ | [S2ORC](https://github.com/allenai/s2orc) Citation pairs (Abstracts) | [paper](https://aclanthology.org/2020.acl-main.447/) | 116,288,806 |
147
+ | [WikiAnswers](https://github.com/afader/oqa#wikianswers-corpus) Duplicate question pairs | [paper](https://doi.org/10.1145/2623330.2623677) | 77,427,422 |
148
+ | [PAQ](https://github.com/facebookresearch/PAQ) (Question, Answer) pairs | [paper](https://arxiv.org/abs/2102.07033) | 64,371,441 |
149
+ | [S2ORC](https://github.com/allenai/s2orc) Citation pairs (Titles) | [paper](https://aclanthology.org/2020.acl-main.447/) | 52,603,982 |
150
+ | [S2ORC](https://github.com/allenai/s2orc) (Title, Abstract) | [paper](https://aclanthology.org/2020.acl-main.447/) | 41,769,185 |
151
+ | [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) (Title, Body) pairs | - | 25,316,456 |
152
+ | [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) (Title+Body, Answer) pairs | - | 21,396,559 |
153
+ | [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) (Title, Answer) pairs | - | 21,396,559 |
154
+ | [MS MARCO](https://microsoft.github.io/msmarco/) triplets | [paper](https://doi.org/10.1145/3404835.3462804) | 9,144,553 |
155
+ | [GOOAQ: Open Question Answering with Diverse Answer Types](https://github.com/allenai/gooaq) | [paper](https://arxiv.org/pdf/2104.08727.pdf) | 3,012,496 |
156
+ | [Yahoo Answers](https://www.kaggle.com/soumikrakshit/yahoo-answers-dataset) (Title, Answer) | [paper](https://proceedings.neurips.cc/paper/2015/hash/250cf8b51c773f3f8dc8b4be867a9a02-Abstract.html) | 1,198,260 |
157
+ | [Code Search](https://huggingface.co/datasets/code_search_net) | - | 1,151,414 |
158
+ | [COCO](https://cocodataset.org/#home) Image captions | [paper](https://link.springer.com/chapter/10.1007%2F978-3-319-10602-1_48) | 828,395|
159
+ | [SPECTER](https://github.com/allenai/specter) citation triplets | [paper](https://doi.org/10.18653/v1/2020.acl-main.207) | 684,100 |
160
+ | [Yahoo Answers](https://www.kaggle.com/soumikrakshit/yahoo-answers-dataset) (Question, Answer) | [paper](https://proceedings.neurips.cc/paper/2015/hash/250cf8b51c773f3f8dc8b4be867a9a02-Abstract.html) | 681,164 |
161
+ | [Yahoo Answers](https://www.kaggle.com/soumikrakshit/yahoo-answers-dataset) (Title, Question) | [paper](https://proceedings.neurips.cc/paper/2015/hash/250cf8b51c773f3f8dc8b4be867a9a02-Abstract.html) | 659,896 |
162
+ | [SearchQA](https://huggingface.co/datasets/search_qa) | [paper](https://arxiv.org/abs/1704.05179) | 582,261 |
163
+ | [Eli5](https://huggingface.co/datasets/eli5) | [paper](https://doi.org/10.18653/v1/p19-1346) | 325,475 |
164
+ | [Flickr 30k](https://shannon.cs.illinois.edu/DenotationGraph/) | [paper](https://transacl.org/ojs/index.php/tacl/article/view/229/33) | 317,695 |
165
+ | [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) Duplicate questions (titles) | | 304,525 |
166
+ | AllNLI ([SNLI](https://nlp.stanford.edu/projects/snli/) and [MultiNLI](https://cims.nyu.edu/~sbowman/multinli/) | [paper SNLI](https://doi.org/10.18653/v1/d15-1075), [paper MultiNLI](https://doi.org/10.18653/v1/n18-1101) | 277,230 |
167
+ | [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) Duplicate questions (bodies) | | 250,519 |
168
+ | [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) Duplicate questions (titles+bodies) | | 250,460 |
169
+ | [Sentence Compression](https://github.com/google-research-datasets/sentence-compression) | [paper](https://www.aclweb.org/anthology/D13-1155/) | 180,000 |
170
+ | [Wikihow](https://github.com/pvl/wikihow_pairs_dataset) | [paper](https://arxiv.org/abs/1810.09305) | 128,542 |
171
+ | [Altlex](https://github.com/chridey/altlex/) | [paper](https://aclanthology.org/P16-1135.pdf) | 112,696 |
172
+ | [Quora Question Triplets](https://quoradata.quora.com/First-Quora-Dataset-Release-Question-Pairs) | - | 103,663 |
173
+ | [Simple Wikipedia](https://cs.pomona.edu/~dkauchak/simplification/) | [paper](https://www.aclweb.org/anthology/P11-2117/) | 102,225 |
174
+ | [Natural Questions (NQ)](https://ai.google.com/research/NaturalQuestions) | [paper](https://transacl.org/ojs/index.php/tacl/article/view/1455) | 100,231 |
175
+ | [SQuAD2.0](https://rajpurkar.github.io/SQuAD-explorer/) | [paper](https://aclanthology.org/P18-2124.pdf) | 87,599 |
176
+ | [TriviaQA](https://huggingface.co/datasets/trivia_qa) | - | 73,346 |
177
+ | **Total** | | **1,170,060,424** |
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:790ae806f396f666042d9b0e126632f35d97a6f3b9421a5eb4aa1a9bafa63231
3
  size 90864192
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1377e9af0ca0b016a9f2aa584d6fc71ab3ea6804fae21ef9fb1416e2944057ac
3
  size 90864192
modules.json CHANGED
@@ -14,13 +14,7 @@
14
  {
15
  "idx": 2,
16
  "name": "2",
17
- "path": "2_Dense",
18
- "type": "sentence_transformers.models.Dense"
19
- },
20
- {
21
- "idx": 3,
22
- "name": "3",
23
- "path": "3_Dropout",
24
- "type": "sentence_transformers.models.Dropout"
25
  }
26
  ]
 
14
  {
15
  "idx": 2,
16
  "name": "2",
17
+ "path": "2_Normalize",
18
+ "type": "sentence_transformers.models.Normalize"
 
 
 
 
 
 
19
  }
20
  ]