Andou2yu commited on
Commit
676469e
·
verified ·
1 Parent(s): a8a61ba

Upload Cross-Encoder weights (trained on BEDR pairs)

Browse files
README.md ADDED
@@ -0,0 +1,335 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - sentence-transformers
4
+ - cross-encoder
5
+ - reranker
6
+ - generated_from_trainer
7
+ - dataset_size:42906
8
+ - loss:BinaryCrossEntropyLoss
9
+ base_model: cross-encoder/ms-marco-MiniLM-L6-v2
10
+ pipeline_tag: text-ranking
11
+ library_name: sentence-transformers
12
+ ---
13
+
14
+ # CrossEncoder based on cross-encoder/ms-marco-MiniLM-L6-v2
15
+
16
+ This is a [Cross Encoder](https://www.sbert.net/docs/cross_encoder/usage/usage.html) model finetuned from [cross-encoder/ms-marco-MiniLM-L6-v2](https://huggingface.co/cross-encoder/ms-marco-MiniLM-L6-v2) using the [sentence-transformers](https://www.SBERT.net) library. It computes scores for pairs of texts, which can be used for text reranking and semantic search.
17
+
18
+ ## Model Details
19
+
20
+ ### Model Description
21
+ - **Model Type:** Cross Encoder
22
+ - **Base model:** [cross-encoder/ms-marco-MiniLM-L6-v2](https://huggingface.co/cross-encoder/ms-marco-MiniLM-L6-v2) <!-- at revision c5ee24cb16019beea0893ab7796b1df96625c6b8 -->
23
+ - **Maximum Sequence Length:** 512 tokens
24
+ - **Number of Output Labels:** 1 label
25
+ <!-- - **Training Dataset:** Unknown -->
26
+ <!-- - **Language:** Unknown -->
27
+ <!-- - **License:** Unknown -->
28
+
29
+ ### Model Sources
30
+
31
+ - **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
32
+ - **Documentation:** [Cross Encoder Documentation](https://www.sbert.net/docs/cross_encoder/usage/usage.html)
33
+ - **Repository:** [Sentence Transformers on GitHub](https://github.com/huggingface/sentence-transformers)
34
+ - **Hugging Face:** [Cross Encoders on Hugging Face](https://huggingface.co/models?library=sentence-transformers&other=cross-encoder)
35
+
36
+ ## Usage
37
+
38
+ ### Direct Usage (Sentence Transformers)
39
+
40
+ First install the Sentence Transformers library:
41
+
42
+ ```bash
43
+ pip install -U sentence-transformers
44
+ ```
45
+
46
+ Then you can load this model and run inference.
47
+ ```python
48
+ from sentence_transformers import CrossEncoder
49
+
50
+ # Download from the 🤗 Hub
51
+ model = CrossEncoder("cross_encoder_model_id")
52
+ # Get scores for pairs of texts
53
+ pairs = [
54
+ ['TA2541 has used process hollowing to execute CyberGate malware.', 'Woody RAT can create a suspended notepad process and write shellcode to delete a file into the suspended process using `NtWriteVirtualMemory`.'],
55
+ ['Attackers concealed command and control communications by hiding encoded data in the metadata of PNG files.', 'TA551 has hidden encoded data for malware DLLs in a PNG.'],
56
+ ['The cybercriminal created a deceptive Facebook account impersonating a tech support representative to establish initial contact with potential victims.', 'The adversary used klist.exe to view Kerberos ticket expiration times and session keys.'],
57
+ ['APT32 used GetPassword_x64 to harvest credentials.', 'Spyware updated TCC.db to grant full disk access to the malicious application.'],
58
+ ['APT1 uses two utilities, GETMAIL and MAPIGET, to steal email. GETMAIL extracts emails from archived Outlook .pst files.', 'During Frankenstein, the threat actors used MSbuild to execute an actor-created file.'],
59
+ ]
60
+ scores = model.predict(pairs)
61
+ print(scores.shape)
62
+ # (5,)
63
+
64
+ # Or rank different texts based on similarity to a single text
65
+ ranks = model.rank(
66
+ 'TA2541 has used process hollowing to execute CyberGate malware.',
67
+ [
68
+ 'Woody RAT can create a suspended notepad process and write shellcode to delete a file into the suspended process using `NtWriteVirtualMemory`.',
69
+ 'TA551 has hidden encoded data for malware DLLs in a PNG.',
70
+ 'The adversary used klist.exe to view Kerberos ticket expiration times and session keys.',
71
+ 'Spyware updated TCC.db to grant full disk access to the malicious application.',
72
+ 'During Frankenstein, the threat actors used MSbuild to execute an actor-created file.',
73
+ ]
74
+ )
75
+ # [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
76
+ ```
77
+
78
+ <!--
79
+ ### Direct Usage (Transformers)
80
+
81
+ <details><summary>Click to see the direct usage in Transformers</summary>
82
+
83
+ </details>
84
+ -->
85
+
86
+ <!--
87
+ ### Downstream Usage (Sentence Transformers)
88
+
89
+ You can finetune this model on your own dataset.
90
+
91
+ <details><summary>Click to expand</summary>
92
+
93
+ </details>
94
+ -->
95
+
96
+ <!--
97
+ ### Out-of-Scope Use
98
+
99
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
100
+ -->
101
+
102
+ <!--
103
+ ## Bias, Risks and Limitations
104
+
105
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
106
+ -->
107
+
108
+ <!--
109
+ ### Recommendations
110
+
111
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
112
+ -->
113
+
114
+ ## Training Details
115
+
116
+ ### Training Dataset
117
+
118
+ #### Unnamed Dataset
119
+
120
+ * Size: 42,906 training samples
121
+ * Columns: <code>sentence_0</code>, <code>sentence_1</code>, and <code>label</code>
122
+ * Approximate statistics based on the first 1000 samples:
123
+ | | sentence_0 | sentence_1 | label |
124
+ |:--------|:-------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------|:---------------------------------------------------------------|
125
+ | type | string | string | float |
126
+ | details | <ul><li>min: 32 characters</li><li>mean: 100.17 characters</li><li>max: 372 characters</li></ul> | <ul><li>min: 32 characters</li><li>mean: 100.99 characters</li><li>max: 403 characters</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.48</li><li>max: 1.0</li></ul> |
127
+ * Samples:
128
+ | sentence_0 | sentence_1 | label |
129
+ |:---------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------|
130
+ | <code>TA2541 has used process hollowing to execute CyberGate malware.</code> | <code>Woody RAT can create a suspended notepad process and write shellcode to delete a file into the suspended process using `NtWriteVirtualMemory`.</code> | <code>1.0</code> |
131
+ | <code>Attackers concealed command and control communications by hiding encoded data in the metadata of PNG files.</code> | <code>TA551 has hidden encoded data for malware DLLs in a PNG.</code> | <code>1.0</code> |
132
+ | <code>The cybercriminal created a deceptive Facebook account impersonating a tech support representative to establish initial contact with potential victims.</code> | <code>The adversary used klist.exe to view Kerberos ticket expiration times and session keys.</code> | <code>0.0</code> |
133
+ * Loss: [<code>BinaryCrossEntropyLoss</code>](https://sbert.net/docs/package_reference/cross_encoder/losses.html#binarycrossentropyloss) with these parameters:
134
+ ```json
135
+ {
136
+ "activation_fn": "torch.nn.modules.linear.Identity",
137
+ "pos_weight": null
138
+ }
139
+ ```
140
+
141
+ ### Training Hyperparameters
142
+ #### Non-Default Hyperparameters
143
+
144
+ - `per_device_train_batch_size`: 16
145
+ - `per_device_eval_batch_size`: 16
146
+
147
+ #### All Hyperparameters
148
+ <details><summary>Click to expand</summary>
149
+
150
+ - `overwrite_output_dir`: False
151
+ - `do_predict`: False
152
+ - `eval_strategy`: no
153
+ - `prediction_loss_only`: True
154
+ - `per_device_train_batch_size`: 16
155
+ - `per_device_eval_batch_size`: 16
156
+ - `per_gpu_train_batch_size`: None
157
+ - `per_gpu_eval_batch_size`: None
158
+ - `gradient_accumulation_steps`: 1
159
+ - `eval_accumulation_steps`: None
160
+ - `torch_empty_cache_steps`: None
161
+ - `learning_rate`: 5e-05
162
+ - `weight_decay`: 0.0
163
+ - `adam_beta1`: 0.9
164
+ - `adam_beta2`: 0.999
165
+ - `adam_epsilon`: 1e-08
166
+ - `max_grad_norm`: 1
167
+ - `num_train_epochs`: 3
168
+ - `max_steps`: -1
169
+ - `lr_scheduler_type`: linear
170
+ - `lr_scheduler_kwargs`: {}
171
+ - `warmup_ratio`: 0.0
172
+ - `warmup_steps`: 0
173
+ - `log_level`: passive
174
+ - `log_level_replica`: warning
175
+ - `log_on_each_node`: True
176
+ - `logging_nan_inf_filter`: True
177
+ - `save_safetensors`: True
178
+ - `save_on_each_node`: False
179
+ - `save_only_model`: False
180
+ - `restore_callback_states_from_checkpoint`: False
181
+ - `no_cuda`: False
182
+ - `use_cpu`: False
183
+ - `use_mps_device`: False
184
+ - `seed`: 42
185
+ - `data_seed`: None
186
+ - `jit_mode_eval`: False
187
+ - `bf16`: False
188
+ - `fp16`: False
189
+ - `fp16_opt_level`: O1
190
+ - `half_precision_backend`: auto
191
+ - `bf16_full_eval`: False
192
+ - `fp16_full_eval`: False
193
+ - `tf32`: None
194
+ - `local_rank`: 0
195
+ - `ddp_backend`: None
196
+ - `tpu_num_cores`: None
197
+ - `tpu_metrics_debug`: False
198
+ - `debug`: []
199
+ - `dataloader_drop_last`: False
200
+ - `dataloader_num_workers`: 0
201
+ - `dataloader_prefetch_factor`: None
202
+ - `past_index`: -1
203
+ - `disable_tqdm`: False
204
+ - `remove_unused_columns`: True
205
+ - `label_names`: None
206
+ - `load_best_model_at_end`: False
207
+ - `ignore_data_skip`: False
208
+ - `fsdp`: []
209
+ - `fsdp_min_num_params`: 0
210
+ - `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
211
+ - `fsdp_transformer_layer_cls_to_wrap`: None
212
+ - `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
213
+ - `parallelism_config`: None
214
+ - `deepspeed`: None
215
+ - `label_smoothing_factor`: 0.0
216
+ - `optim`: adamw_torch_fused
217
+ - `optim_args`: None
218
+ - `adafactor`: False
219
+ - `group_by_length`: False
220
+ - `length_column_name`: length
221
+ - `project`: huggingface
222
+ - `trackio_space_id`: trackio
223
+ - `ddp_find_unused_parameters`: None
224
+ - `ddp_bucket_cap_mb`: None
225
+ - `ddp_broadcast_buffers`: False
226
+ - `dataloader_pin_memory`: True
227
+ - `dataloader_persistent_workers`: False
228
+ - `skip_memory_metrics`: True
229
+ - `use_legacy_prediction_loop`: False
230
+ - `push_to_hub`: False
231
+ - `resume_from_checkpoint`: None
232
+ - `hub_model_id`: None
233
+ - `hub_strategy`: every_save
234
+ - `hub_private_repo`: None
235
+ - `hub_always_push`: False
236
+ - `hub_revision`: None
237
+ - `gradient_checkpointing`: False
238
+ - `gradient_checkpointing_kwargs`: None
239
+ - `include_inputs_for_metrics`: False
240
+ - `include_for_metrics`: []
241
+ - `eval_do_concat_batches`: True
242
+ - `fp16_backend`: auto
243
+ - `push_to_hub_model_id`: None
244
+ - `push_to_hub_organization`: None
245
+ - `mp_parameters`:
246
+ - `auto_find_batch_size`: False
247
+ - `full_determinism`: False
248
+ - `torchdynamo`: None
249
+ - `ray_scope`: last
250
+ - `ddp_timeout`: 1800
251
+ - `torch_compile`: False
252
+ - `torch_compile_backend`: None
253
+ - `torch_compile_mode`: None
254
+ - `include_tokens_per_second`: False
255
+ - `include_num_input_tokens_seen`: no
256
+ - `neftune_noise_alpha`: None
257
+ - `optim_target_modules`: None
258
+ - `batch_eval_metrics`: False
259
+ - `eval_on_start`: False
260
+ - `use_liger_kernel`: False
261
+ - `liger_kernel_config`: None
262
+ - `eval_use_gather_object`: False
263
+ - `average_tokens_across_devices`: True
264
+ - `prompts`: None
265
+ - `batch_sampler`: batch_sampler
266
+ - `multi_dataset_batch_sampler`: proportional
267
+ - `router_mapping`: {}
268
+ - `learning_rate_mapping`: {}
269
+
270
+ </details>
271
+
272
+ ### Training Logs
273
+ | Epoch | Step | Training Loss |
274
+ |:------:|:----:|:-------------:|
275
+ | 0.1864 | 500 | 0.6336 |
276
+ | 0.3729 | 1000 | 0.3383 |
277
+ | 0.5593 | 1500 | 0.3197 |
278
+ | 0.7457 | 2000 | 0.3031 |
279
+ | 0.9321 | 2500 | 0.2815 |
280
+ | 1.1186 | 3000 | 0.2555 |
281
+ | 1.3050 | 3500 | 0.2394 |
282
+ | 1.4914 | 4000 | 0.2496 |
283
+ | 1.6779 | 4500 | 0.2312 |
284
+ | 1.8643 | 5000 | 0.2253 |
285
+ | 2.0507 | 5500 | 0.2128 |
286
+ | 2.2371 | 6000 | 0.1872 |
287
+ | 2.4236 | 6500 | 0.2003 |
288
+ | 2.6100 | 7000 | 0.1864 |
289
+ | 2.7964 | 7500 | 0.1992 |
290
+ | 2.9828 | 8000 | 0.1873 |
291
+
292
+
293
+ ### Framework Versions
294
+ - Python: 3.10.19
295
+ - Sentence Transformers: 5.2.0
296
+ - Transformers: 4.57.3
297
+ - PyTorch: 2.9.1
298
+ - Accelerate: 1.12.0
299
+ - Datasets: 4.4.2
300
+ - Tokenizers: 0.22.1
301
+
302
+ ## Citation
303
+
304
+ ### BibTeX
305
+
306
+ #### Sentence Transformers
307
+ ```bibtex
308
+ @inproceedings{reimers-2019-sentence-bert,
309
+ title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
310
+ author = "Reimers, Nils and Gurevych, Iryna",
311
+ booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
312
+ month = "11",
313
+ year = "2019",
314
+ publisher = "Association for Computational Linguistics",
315
+ url = "https://arxiv.org/abs/1908.10084",
316
+ }
317
+ ```
318
+
319
+ <!--
320
+ ## Glossary
321
+
322
+ *Clearly define terms in order to be accessible across audiences.*
323
+ -->
324
+
325
+ <!--
326
+ ## Model Card Authors
327
+
328
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
329
+ -->
330
+
331
+ <!--
332
+ ## Model Card Contact
333
+
334
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
335
+ -->
config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertForSequenceClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "classifier_dropout": null,
7
+ "dtype": "float32",
8
+ "gradient_checkpointing": false,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 384,
12
+ "id2label": {
13
+ "0": "LABEL_0"
14
+ },
15
+ "initializer_range": 0.02,
16
+ "intermediate_size": 1536,
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": 6,
25
+ "pad_token_id": 0,
26
+ "position_embedding_type": "absolute",
27
+ "sentence_transformers": {
28
+ "activation_fn": "torch.nn.modules.linear.Identity",
29
+ "version": "5.2.0"
30
+ },
31
+ "transformers_version": "4.57.3",
32
+ "type_vocab_size": 2,
33
+ "use_cache": true,
34
+ "vocab_size": 30522
35
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9c35cc9db3d840da938d0c4540bb582dae56f7912ddcbe6bb49068c2db1a2af9
3
+ size 90866412
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,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "extra_special_tokens": {},
49
+ "mask_token": "[MASK]",
50
+ "model_max_length": 512,
51
+ "never_split": null,
52
+ "pad_token": "[PAD]",
53
+ "sep_token": "[SEP]",
54
+ "strip_accents": null,
55
+ "tokenize_chinese_chars": true,
56
+ "tokenizer_class": "BertTokenizer",
57
+ "unk_token": "[UNK]"
58
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff
 
write_test.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ Test write permission OK.