jackenmail commited on
Commit
f7f9359
·
verified ·
1 Parent(s): 2cd1595

Add new SentenceTransformer model

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "embedding_dimension": 384,
3
+ "pooling_mode": "mean",
4
+ "include_prompt": true
5
+ }
README.md ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - sentence-transformers
4
+ - sentence-similarity
5
+ - feature-extraction
6
+ - generated_from_trainer
7
+ - dataset_size:2
8
+ - loss:MultipleNegativesRankingLoss
9
+ base_model: sentence-transformers/all-MiniLM-L6-v2
10
+ pipeline_tag: sentence-similarity
11
+ library_name: sentence-transformers
12
+ ---
13
+
14
+ # SentenceTransformer based on sentence-transformers/all-MiniLM-L6-v2
15
+
16
+ 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 retrieval.
17
+
18
+ ## Model Details
19
+
20
+ ### Model Description
21
+ - **Model Type:** Sentence Transformer
22
+ - **Base model:** [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) <!-- at revision c9745ed1d9f207416be6d2e6f8de32d1f16199bf -->
23
+ - **Maximum Sequence Length:** 256 tokens
24
+ - **Output Dimensionality:** 384 dimensions
25
+ - **Similarity Function:** Cosine Similarity
26
+ - **Supported Modality:** Text
27
+ <!-- - **Training Dataset:** Unknown -->
28
+ <!-- - **Language:** Unknown -->
29
+ <!-- - **License:** Unknown -->
30
+
31
+ ### Model Sources
32
+
33
+ - **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
34
+ - **Repository:** [Sentence Transformers on GitHub](https://github.com/huggingface/sentence-transformers)
35
+ - **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
36
+
37
+ ### Full Model Architecture
38
+
39
+ ```
40
+ SentenceTransformer(
41
+ (0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'BertModel'})
42
+ (1): Pooling({'embedding_dimension': 384, 'pooling_mode': 'mean', 'include_prompt': True})
43
+ (2): Normalize({})
44
+ )
45
+ ```
46
+
47
+ ## Usage
48
+
49
+ ### Direct Usage (Sentence Transformers)
50
+
51
+ First install the Sentence Transformers library:
52
+
53
+ ```bash
54
+ pip install -U sentence-transformers
55
+ ```
56
+ Then you can load this model and run inference.
57
+ ```python
58
+ from sentence_transformers import SentenceTransformer
59
+
60
+ # Download from the 🤗 Hub
61
+ model = SentenceTransformer("jackenmail/rag-embedder")
62
+ # Run inference
63
+ sentences = [
64
+ 'The weather is lovely today.',
65
+ "It's so sunny outside!",
66
+ 'He drove to the stadium.',
67
+ ]
68
+ embeddings = model.encode(sentences)
69
+ print(embeddings.shape)
70
+ # [3, 384]
71
+
72
+ # Get the similarity scores for the embeddings
73
+ similarities = model.similarity(embeddings, embeddings)
74
+ print(similarities)
75
+ # tensor([[1.0000, 0.6669, 0.1052],
76
+ # [0.6669, 1.0000, 0.1414],
77
+ # [0.1052, 0.1414, 1.0000]])
78
+ ```
79
+ <!--
80
+ ### Direct Usage (Transformers)
81
+
82
+ <details><summary>Click to see the direct usage in Transformers</summary>
83
+
84
+ </details>
85
+ -->
86
+
87
+ <!--
88
+ ### Downstream Usage (Sentence Transformers)
89
+
90
+ You can finetune this model on your own dataset.
91
+
92
+ <details><summary>Click to expand</summary>
93
+
94
+ </details>
95
+ -->
96
+
97
+ <!--
98
+ ### Out-of-Scope Use
99
+
100
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
101
+ -->
102
+
103
+ <!--
104
+ ## Bias, Risks and Limitations
105
+
106
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
107
+ -->
108
+
109
+ <!--
110
+ ### Recommendations
111
+
112
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
113
+ -->
114
+
115
+ ## Training Details
116
+
117
+ ### Training Dataset
118
+
119
+ #### Unnamed Dataset
120
+
121
+ * Size: 2 training samples
122
+ * Columns: <code>sentence_0</code> and <code>sentence_1</code>
123
+ * Approximate statistics based on the first 2 samples:
124
+ | | sentence_0 | sentence_1 |
125
+ |:--------|:-------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|
126
+ | type | string | string |
127
+ | details | <ul><li>min: 7 tokens</li><li>mean: 8.0 tokens</li><li>max: 9 tokens</li></ul> | <ul><li>min: 11 tokens</li><li>mean: 11.0 tokens</li><li>max: 11 tokens</li></ul> |
128
+ * Samples:
129
+ | sentence_0 | sentence_1 |
130
+ |:----------------------------------------|:-----------------------------------------------------------|
131
+ | <code>How to reset password?</code> | <code>Click forgot password on the login page.</code> |
132
+ | <code>What is our refund policy?</code> | <code>Refunds are processed within 5 business days.</code> |
133
+ * Loss: [<code>MultipleNegativesRankingLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#multiplenegativesrankingloss) with these parameters:
134
+ ```json
135
+ {
136
+ "scale": 20.0,
137
+ "similarity_fct": "cos_sim",
138
+ "gather_across_devices": false,
139
+ "directions": [
140
+ "query_to_doc"
141
+ ],
142
+ "partition_mode": "joint",
143
+ "hardness_mode": null,
144
+ "hardness_strength": 0.0
145
+ }
146
+ ```
147
+
148
+ ### Training Hyperparameters
149
+ #### Non-Default Hyperparameters
150
+
151
+ - `per_device_train_batch_size`: 16
152
+ - `per_device_eval_batch_size`: 16
153
+ - `multi_dataset_batch_sampler`: round_robin
154
+
155
+ #### All Hyperparameters
156
+ <details><summary>Click to expand</summary>
157
+
158
+ - `do_predict`: False
159
+ - `prediction_loss_only`: True
160
+ - `per_device_train_batch_size`: 16
161
+ - `per_device_eval_batch_size`: 16
162
+ - `gradient_accumulation_steps`: 1
163
+ - `eval_accumulation_steps`: None
164
+ - `torch_empty_cache_steps`: None
165
+ - `learning_rate`: 5e-05
166
+ - `weight_decay`: 0.0
167
+ - `adam_beta1`: 0.9
168
+ - `adam_beta2`: 0.999
169
+ - `adam_epsilon`: 1e-08
170
+ - `max_grad_norm`: 1
171
+ - `num_train_epochs`: 3
172
+ - `max_steps`: -1
173
+ - `lr_scheduler_type`: linear
174
+ - `lr_scheduler_kwargs`: None
175
+ - `warmup_ratio`: None
176
+ - `warmup_steps`: 0
177
+ - `log_level`: passive
178
+ - `log_level_replica`: warning
179
+ - `log_on_each_node`: True
180
+ - `logging_nan_inf_filter`: True
181
+ - `enable_jit_checkpoint`: False
182
+ - `save_on_each_node`: False
183
+ - `save_only_model`: False
184
+ - `restore_callback_states_from_checkpoint`: False
185
+ - `use_cpu`: False
186
+ - `seed`: 42
187
+ - `data_seed`: None
188
+ - `bf16`: False
189
+ - `fp16`: False
190
+ - `bf16_full_eval`: False
191
+ - `fp16_full_eval`: False
192
+ - `tf32`: None
193
+ - `local_rank`: -1
194
+ - `ddp_backend`: None
195
+ - `debug`: []
196
+ - `dataloader_drop_last`: False
197
+ - `dataloader_num_workers`: 0
198
+ - `dataloader_prefetch_factor`: None
199
+ - `disable_tqdm`: False
200
+ - `remove_unused_columns`: True
201
+ - `label_names`: None
202
+ - `load_best_model_at_end`: False
203
+ - `ignore_data_skip`: False
204
+ - `fsdp`: []
205
+ - `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
206
+ - `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
207
+ - `parallelism_config`: None
208
+ - `deepspeed`: None
209
+ - `label_smoothing_factor`: 0.0
210
+ - `optim`: adamw_torch_fused
211
+ - `optim_args`: None
212
+ - `group_by_length`: False
213
+ - `length_column_name`: length
214
+ - `project`: huggingface
215
+ - `trackio_space_id`: trackio
216
+ - `ddp_find_unused_parameters`: None
217
+ - `ddp_bucket_cap_mb`: None
218
+ - `ddp_broadcast_buffers`: False
219
+ - `dataloader_pin_memory`: True
220
+ - `dataloader_persistent_workers`: False
221
+ - `skip_memory_metrics`: True
222
+ - `push_to_hub`: False
223
+ - `resume_from_checkpoint`: None
224
+ - `hub_model_id`: None
225
+ - `hub_strategy`: every_save
226
+ - `hub_private_repo`: None
227
+ - `hub_always_push`: False
228
+ - `hub_revision`: None
229
+ - `gradient_checkpointing`: False
230
+ - `gradient_checkpointing_kwargs`: None
231
+ - `include_for_metrics`: []
232
+ - `eval_do_concat_batches`: True
233
+ - `auto_find_batch_size`: False
234
+ - `full_determinism`: False
235
+ - `ddp_timeout`: 1800
236
+ - `torch_compile`: False
237
+ - `torch_compile_backend`: None
238
+ - `torch_compile_mode`: None
239
+ - `include_num_input_tokens_seen`: no
240
+ - `neftune_noise_alpha`: None
241
+ - `optim_target_modules`: None
242
+ - `batch_eval_metrics`: False
243
+ - `eval_on_start`: False
244
+ - `use_liger_kernel`: False
245
+ - `liger_kernel_config`: None
246
+ - `eval_use_gather_object`: False
247
+ - `average_tokens_across_devices`: True
248
+ - `use_cache`: False
249
+ - `prompts`: None
250
+ - `batch_sampler`: batch_sampler
251
+ - `multi_dataset_batch_sampler`: round_robin
252
+ - `router_mapping`: {}
253
+ - `learning_rate_mapping`: {}
254
+
255
+ </details>
256
+
257
+ ### Training Time
258
+ - **Training**: 2.8 seconds
259
+
260
+ ### Framework Versions
261
+ - Python: 3.12.13
262
+ - Sentence Transformers: 5.4.1
263
+ - Transformers: 5.0.0
264
+ - PyTorch: 2.10.0+cu128
265
+ - Accelerate: 1.13.0
266
+ - Datasets: 4.0.0
267
+ - Tokenizers: 0.22.2
268
+
269
+ ## Citation
270
+
271
+ ### BibTeX
272
+
273
+ #### Sentence Transformers
274
+ ```bibtex
275
+ @inproceedings{reimers-2019-sentence-bert,
276
+ title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
277
+ author = "Reimers, Nils and Gurevych, Iryna",
278
+ booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
279
+ month = "11",
280
+ year = "2019",
281
+ publisher = "Association for Computational Linguistics",
282
+ url = "https://arxiv.org/abs/1908.10084",
283
+ }
284
+ ```
285
+
286
+ #### MultipleNegativesRankingLoss
287
+ ```bibtex
288
+ @misc{oord2019representationlearningcontrastivepredictive,
289
+ title={Representation Learning with Contrastive Predictive Coding},
290
+ author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
291
+ year={2019},
292
+ eprint={1807.03748},
293
+ archivePrefix={arXiv},
294
+ primaryClass={cs.LG},
295
+ url={https://arxiv.org/abs/1807.03748},
296
+ }
297
+ ```
298
+
299
+ <!--
300
+ ## Glossary
301
+
302
+ *Clearly define terms in order to be accessible across audiences.*
303
+ -->
304
+
305
+ <!--
306
+ ## Model Card Authors
307
+
308
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
309
+ -->
310
+
311
+ <!--
312
+ ## Model Card Contact
313
+
314
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
315
+ -->
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
+ "pytorch": "2.10.0+cu128",
4
+ "sentence_transformers": "5.4.1",
5
+ "transformers": "5.0.0"
6
+ },
7
+ "default_prompt_name": null,
8
+ "model_type": "SentenceTransformer",
9
+ "prompts": {
10
+ "document": "",
11
+ "query": ""
12
+ },
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:b82988cc2e7262619e6e51d6dc5bcce424cc20a0b5d673b34258dd80ffce1188
3
+ size 90864176
modules.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.base.modules.transformer.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.sentence_transformer.modules.pooling.Pooling"
13
+ },
14
+ {
15
+ "idx": 2,
16
+ "name": "2",
17
+ "path": "2_Normalize",
18
+ "type": "sentence_transformers.sentence_transformer.modules.normalize.Normalize"
19
+ }
20
+ ]
sentence_bert_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "transformer_task": "feature-extraction",
3
+ "modality_config": {
4
+ "text": {
5
+ "method": "forward",
6
+ "method_output_name": "last_hidden_state"
7
+ }
8
+ },
9
+ "module_output_name": "token_embeddings"
10
+ }
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
+ }