shubham-t commited on
Commit
40c2d7b
·
verified ·
1 Parent(s): f6d68af

Add new SentenceTransformer model

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 384,
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,328 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - sentence-transformers
4
+ - sentence-similarity
5
+ - feature-extraction
6
+ - dense
7
+ - generated_from_trainer
8
+ - dataset_size:5749
9
+ - loss:CosineSimilarityLoss
10
+ base_model: sentence-transformers/all-MiniLM-L6-v2
11
+ widget:
12
+ - source_sentence: Army jets kill 38 militants in NW Pakistan air raids
13
+ sentences:
14
+ - U.S. drone kills 4 militants in Pakistan
15
+ - mexico wishes to avoid more violence.
16
+ - '- wolf I think stories like this are stupid.'
17
+ - source_sentence: '[Ticker] Fitch upgrades Greek credit rating'
18
+ sentences:
19
+ - Moody's upgrades Greek credit rating
20
+ - A large group of people have formed a line outside.
21
+ - 9 killed, 31 wounded in car bombs in Iraq's Kirkuk
22
+ - source_sentence: Two people sit on a dock near the water.
23
+ sentences:
24
+ - A young girl is using sign language.
25
+ - get a cooling trend from because of the recent decline.
26
+ - Two people sit on the end of a dock in the middle of still water.
27
+ - source_sentence: Obama signs up for Obamacare
28
+ sentences:
29
+ - Edward Snowden's father in Moscow
30
+ - Facebook profits jump as user base expands
31
+ - Americans scramble to sign up for Obamacare by deadline
32
+ - source_sentence: Sony to sell PC unit and cut jobs
33
+ sentences:
34
+ - Sony to axe PC unit in major business overhaul
35
+ - Rebels kill two park rangers in eastern Congo
36
+ - Indian rape accused found guilty
37
+ pipeline_tag: sentence-similarity
38
+ library_name: sentence-transformers
39
+ ---
40
+
41
+ # SentenceTransformer based on sentence-transformers/all-MiniLM-L6-v2
42
+
43
+ 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 384-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
44
+
45
+ ## Model Details
46
+
47
+ ### Model Description
48
+ - **Model Type:** Sentence Transformer
49
+ - **Base model:** [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) <!-- at revision c9745ed1d9f207416be6d2e6f8de32d1f16199bf -->
50
+ - **Maximum Sequence Length:** 256 tokens
51
+ - **Output Dimensionality:** 384 dimensions
52
+ - **Similarity Function:** Cosine Similarity
53
+ <!-- - **Training Dataset:** Unknown -->
54
+ <!-- - **Language:** Unknown -->
55
+ <!-- - **License:** Unknown -->
56
+
57
+ ### Model Sources
58
+
59
+ - **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
60
+ - **Repository:** [Sentence Transformers on GitHub](https://github.com/huggingface/sentence-transformers)
61
+ - **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
62
+
63
+ ### Full Model Architecture
64
+
65
+ ```
66
+ SentenceTransformer(
67
+ (0): Transformer({'max_seq_length': 256, 'do_lower_case': False, 'architecture': 'BertModel'})
68
+ (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})
69
+ (2): Normalize()
70
+ )
71
+ ```
72
+
73
+ ## Usage
74
+
75
+ ### Direct Usage (Sentence Transformers)
76
+
77
+ First install the Sentence Transformers library:
78
+
79
+ ```bash
80
+ pip install -U sentence-transformers
81
+ ```
82
+
83
+ Then you can load this model and run inference.
84
+ ```python
85
+ from sentence_transformers import SentenceTransformer
86
+
87
+ # Download from the 🤗 Hub
88
+ model = SentenceTransformer("shubham-t/plagiarism-sbert")
89
+ # Run inference
90
+ sentences = [
91
+ 'Sony to sell PC unit and cut jobs',
92
+ 'Sony to axe PC unit in major business overhaul',
93
+ 'Rebels kill two park rangers in eastern Congo',
94
+ ]
95
+ embeddings = model.encode(sentences)
96
+ print(embeddings.shape)
97
+ # [3, 384]
98
+
99
+ # Get the similarity scores for the embeddings
100
+ similarities = model.similarity(embeddings, embeddings)
101
+ print(similarities)
102
+ # tensor([[1.0000, 0.7396, 0.1263],
103
+ # [0.7396, 1.0000, 0.1315],
104
+ # [0.1263, 0.1315, 1.0000]])
105
+ ```
106
+
107
+ <!--
108
+ ### Direct Usage (Transformers)
109
+
110
+ <details><summary>Click to see the direct usage in Transformers</summary>
111
+
112
+ </details>
113
+ -->
114
+
115
+ <!--
116
+ ### Downstream Usage (Sentence Transformers)
117
+
118
+ You can finetune this model on your own dataset.
119
+
120
+ <details><summary>Click to expand</summary>
121
+
122
+ </details>
123
+ -->
124
+
125
+ <!--
126
+ ### Out-of-Scope Use
127
+
128
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
129
+ -->
130
+
131
+ <!--
132
+ ## Bias, Risks and Limitations
133
+
134
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
135
+ -->
136
+
137
+ <!--
138
+ ### Recommendations
139
+
140
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
141
+ -->
142
+
143
+ ## Training Details
144
+
145
+ ### Training Dataset
146
+
147
+ #### Unnamed Dataset
148
+
149
+ * Size: 5,749 training samples
150
+ * Columns: <code>sentence_0</code>, <code>sentence_1</code>, and <code>label</code>
151
+ * Approximate statistics based on the first 1000 samples:
152
+ | | sentence_0 | sentence_1 | label |
153
+ |:--------|:---------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------|
154
+ | type | string | string | float |
155
+ | details | <ul><li>min: 6 tokens</li><li>mean: 14.4 tokens</li><li>max: 44 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 14.48 tokens</li><li>max: 63 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.55</li><li>max: 1.0</li></ul> |
156
+ * Samples:
157
+ | sentence_0 | sentence_1 | label |
158
+ |:----------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------|:--------------------------------|
159
+ | <code>Vivendi shares closed 3.8 percent up in Paris at 15.78 euros.</code> | <code>Vivendi shares were 0.3 percent up at 15.62 euros in Paris at 0841 GMT.</code> | <code>0.5199999809265137</code> |
160
+ | <code>Deal reached on new Italian government</code> | <code>Italy to swear in new coalition government</code> | <code>0.6800000190734863</code> |
161
+ | <code>He had been arrested twice before for trespassing and barred from the complex - home to his mother and two children.</code> | <code>He had been arrested twice before for trespassing and was barred from the complex.</code> | <code>0.7199999809265136</code> |
162
+ * Loss: [<code>CosineSimilarityLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosinesimilarityloss) with these parameters:
163
+ ```json
164
+ {
165
+ "loss_fct": "torch.nn.modules.loss.MSELoss"
166
+ }
167
+ ```
168
+
169
+ ### Training Hyperparameters
170
+ #### Non-Default Hyperparameters
171
+
172
+ - `per_device_train_batch_size`: 16
173
+ - `per_device_eval_batch_size`: 16
174
+ - `num_train_epochs`: 2
175
+ - `multi_dataset_batch_sampler`: round_robin
176
+
177
+ #### All Hyperparameters
178
+ <details><summary>Click to expand</summary>
179
+
180
+ - `do_predict`: False
181
+ - `eval_strategy`: no
182
+ - `prediction_loss_only`: True
183
+ - `per_device_train_batch_size`: 16
184
+ - `per_device_eval_batch_size`: 16
185
+ - `gradient_accumulation_steps`: 1
186
+ - `eval_accumulation_steps`: None
187
+ - `torch_empty_cache_steps`: None
188
+ - `learning_rate`: 5e-05
189
+ - `weight_decay`: 0.0
190
+ - `adam_beta1`: 0.9
191
+ - `adam_beta2`: 0.999
192
+ - `adam_epsilon`: 1e-08
193
+ - `max_grad_norm`: 1
194
+ - `num_train_epochs`: 2
195
+ - `max_steps`: -1
196
+ - `lr_scheduler_type`: linear
197
+ - `lr_scheduler_kwargs`: None
198
+ - `warmup_ratio`: None
199
+ - `warmup_steps`: 0
200
+ - `log_level`: passive
201
+ - `log_level_replica`: warning
202
+ - `log_on_each_node`: True
203
+ - `logging_nan_inf_filter`: True
204
+ - `enable_jit_checkpoint`: False
205
+ - `save_on_each_node`: False
206
+ - `save_only_model`: False
207
+ - `restore_callback_states_from_checkpoint`: False
208
+ - `use_cpu`: False
209
+ - `seed`: 42
210
+ - `data_seed`: None
211
+ - `bf16`: False
212
+ - `fp16`: False
213
+ - `bf16_full_eval`: False
214
+ - `fp16_full_eval`: False
215
+ - `tf32`: None
216
+ - `local_rank`: -1
217
+ - `ddp_backend`: None
218
+ - `debug`: []
219
+ - `dataloader_drop_last`: False
220
+ - `dataloader_num_workers`: 0
221
+ - `dataloader_prefetch_factor`: None
222
+ - `disable_tqdm`: False
223
+ - `remove_unused_columns`: True
224
+ - `label_names`: None
225
+ - `load_best_model_at_end`: False
226
+ - `ignore_data_skip`: False
227
+ - `fsdp`: []
228
+ - `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
229
+ - `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
230
+ - `parallelism_config`: None
231
+ - `deepspeed`: None
232
+ - `label_smoothing_factor`: 0.0
233
+ - `optim`: adamw_torch_fused
234
+ - `optim_args`: None
235
+ - `group_by_length`: False
236
+ - `length_column_name`: length
237
+ - `project`: huggingface
238
+ - `trackio_space_id`: trackio
239
+ - `ddp_find_unused_parameters`: None
240
+ - `ddp_bucket_cap_mb`: None
241
+ - `ddp_broadcast_buffers`: False
242
+ - `dataloader_pin_memory`: True
243
+ - `dataloader_persistent_workers`: False
244
+ - `skip_memory_metrics`: True
245
+ - `push_to_hub`: False
246
+ - `resume_from_checkpoint`: None
247
+ - `hub_model_id`: None
248
+ - `hub_strategy`: every_save
249
+ - `hub_private_repo`: None
250
+ - `hub_always_push`: False
251
+ - `hub_revision`: None
252
+ - `gradient_checkpointing`: False
253
+ - `gradient_checkpointing_kwargs`: None
254
+ - `include_for_metrics`: []
255
+ - `eval_do_concat_batches`: True
256
+ - `auto_find_batch_size`: False
257
+ - `full_determinism`: False
258
+ - `ddp_timeout`: 1800
259
+ - `torch_compile`: False
260
+ - `torch_compile_backend`: None
261
+ - `torch_compile_mode`: None
262
+ - `include_num_input_tokens_seen`: no
263
+ - `neftune_noise_alpha`: None
264
+ - `optim_target_modules`: None
265
+ - `batch_eval_metrics`: False
266
+ - `eval_on_start`: False
267
+ - `use_liger_kernel`: False
268
+ - `liger_kernel_config`: None
269
+ - `eval_use_gather_object`: False
270
+ - `average_tokens_across_devices`: True
271
+ - `use_cache`: False
272
+ - `prompts`: None
273
+ - `batch_sampler`: batch_sampler
274
+ - `multi_dataset_batch_sampler`: round_robin
275
+ - `router_mapping`: {}
276
+ - `learning_rate_mapping`: {}
277
+
278
+ </details>
279
+
280
+ ### Training Logs
281
+ | Epoch | Step | Training Loss |
282
+ |:------:|:----:|:-------------:|
283
+ | 1.3889 | 500 | 0.0213 |
284
+
285
+
286
+ ### Framework Versions
287
+ - Python: 3.12.12
288
+ - Sentence Transformers: 5.2.3
289
+ - Transformers: 5.0.0
290
+ - PyTorch: 2.10.0+cu128
291
+ - Accelerate: 1.12.0
292
+ - Datasets: 4.5.0
293
+ - Tokenizers: 0.22.2
294
+
295
+ ## Citation
296
+
297
+ ### BibTeX
298
+
299
+ #### Sentence Transformers
300
+ ```bibtex
301
+ @inproceedings{reimers-2019-sentence-bert,
302
+ title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
303
+ author = "Reimers, Nils and Gurevych, Iryna",
304
+ booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
305
+ month = "11",
306
+ year = "2019",
307
+ publisher = "Association for Computational Linguistics",
308
+ url = "https://arxiv.org/abs/1908.10084",
309
+ }
310
+ ```
311
+
312
+ <!--
313
+ ## Glossary
314
+
315
+ *Clearly define terms in order to be accessible across audiences.*
316
+ -->
317
+
318
+ <!--
319
+ ## Model Card Authors
320
+
321
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
322
+ -->
323
+
324
+ <!--
325
+ ## Model Card Contact
326
+
327
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
328
+ -->
config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_cross_attention": false,
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": null,
8
+ "classifier_dropout": null,
9
+ "dtype": "float32",
10
+ "eos_token_id": null,
11
+ "gradient_checkpointing": false,
12
+ "hidden_act": "gelu",
13
+ "hidden_dropout_prob": 0.1,
14
+ "hidden_size": 384,
15
+ "initializer_range": 0.02,
16
+ "intermediate_size": 1536,
17
+ "is_decoder": false,
18
+ "layer_norm_eps": 1e-12,
19
+ "max_position_embeddings": 512,
20
+ "model_type": "bert",
21
+ "num_attention_heads": 12,
22
+ "num_hidden_layers": 6,
23
+ "pad_token_id": 0,
24
+ "position_embedding_type": "absolute",
25
+ "tie_word_embeddings": true,
26
+ "transformers_version": "5.0.0",
27
+ "type_vocab_size": 2,
28
+ "use_cache": true,
29
+ "vocab_size": 30522
30
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "5.2.3",
4
+ "transformers": "5.0.0",
5
+ "pytorch": "2.10.0+cu128"
6
+ },
7
+ "model_type": "SentenceTransformer",
8
+ "prompts": {
9
+ "query": "",
10
+ "document": ""
11
+ },
12
+ "default_prompt_name": null,
13
+ "similarity_fn_name": "cosine"
14
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1e4fb7c72f0b248ec2bf75445f54737171f95c2d4ba2aaede2ef2fd7acad565c
3
+ size 90864176
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": 256,
3
+ "do_lower_case": false
4
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "cls_token": "[CLS]",
4
+ "do_basic_tokenize": true,
5
+ "do_lower_case": true,
6
+ "is_local": false,
7
+ "mask_token": "[MASK]",
8
+ "model_max_length": 256,
9
+ "never_split": null,
10
+ "pad_token": "[PAD]",
11
+ "sep_token": "[SEP]",
12
+ "strip_accents": null,
13
+ "tokenize_chinese_chars": true,
14
+ "tokenizer_class": "BertTokenizer",
15
+ "unk_token": "[UNK]"
16
+ }