Abdelkareem commited on
Commit
0fd30b6
·
verified ·
1 Parent(s): 8b3d8aa

Add new SentenceTransformer model

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
1_Dense/config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"in_features": 768, "out_features": 128, "bias": false, "activation_function": "torch.nn.modules.linear.Identity"}
1_Dense/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0ccc5e57109eaa97ae02977a4fd42e78fb53304d71e093dc83ba83a8eee12c53
3
+ size 393304
README.md ADDED
@@ -0,0 +1,440 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - ColBERT
4
+ - PyLate
5
+ - sentence-transformers
6
+ - sentence-similarity
7
+ - feature-extraction
8
+ - generated_from_trainer
9
+ - dataset_size:74683
10
+ - loss:Contrastive
11
+ base_model: nomic-ai/nomic-embed-text-v2-moe
12
+ pipeline_tag: sentence-similarity
13
+ library_name: PyLate
14
+ ---
15
+
16
+ # PyLate model based on nomic-ai/nomic-embed-text-v2-moe
17
+
18
+ This is a [PyLate](https://github.com/lightonai/pylate) model finetuned from [nomic-ai/nomic-embed-text-v2-moe](https://huggingface.co/nomic-ai/nomic-embed-text-v2-moe). It maps sentences & paragraphs to sequences of 128-dimensional dense vectors and can be used for semantic textual similarity using the MaxSim operator.
19
+
20
+ ## Model Details
21
+
22
+ ### Model Description
23
+ - **Model Type:** PyLate model
24
+ - **Base model:** [nomic-ai/nomic-embed-text-v2-moe](https://huggingface.co/nomic-ai/nomic-embed-text-v2-moe) <!-- at revision 1066b6599d099fbb93dfcb64f9c37a7c9e503e85 -->
25
+ - **Document Length:** 180 tokens
26
+ - **Query Length:** 32 tokens
27
+ - **Output Dimensionality:** 128 tokens
28
+ - **Similarity Function:** MaxSim
29
+ <!-- - **Training Dataset:** Unknown -->
30
+ <!-- - **Language:** Unknown -->
31
+ <!-- - **License:** Unknown -->
32
+
33
+ ### Model Sources
34
+
35
+ - **Documentation:** [PyLate Documentation](https://lightonai.github.io/pylate/)
36
+ - **Repository:** [PyLate on GitHub](https://github.com/lightonai/pylate)
37
+ - **Hugging Face:** [PyLate models on Hugging Face](https://huggingface.co/models?library=PyLate)
38
+
39
+ ### Full Model Architecture
40
+
41
+ ```
42
+ ColBERT(
43
+ (0): Transformer({'max_seq_length': 179, 'do_lower_case': False}) with Transformer model: NomicBertModel
44
+ (1): Dense({'in_features': 768, 'out_features': 128, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity'})
45
+ )
46
+ ```
47
+
48
+ ## Usage
49
+ First install the PyLate library:
50
+
51
+ ```bash
52
+ pip install -U pylate
53
+ ```
54
+
55
+ ### Retrieval
56
+
57
+ PyLate provides a streamlined interface to index and retrieve documents using ColBERT models. The index leverages the Voyager HNSW index to efficiently handle document embeddings and enable fast retrieval.
58
+
59
+ #### Indexing documents
60
+
61
+ First, load the ColBERT model and initialize the Voyager index, then encode and index your documents:
62
+
63
+ ```python
64
+ from pylate import indexes, models, retrieve
65
+
66
+ # Step 1: Load the ColBERT model
67
+ model = models.ColBERT(
68
+ model_name_or_path=pylate_model_id,
69
+ )
70
+
71
+ # Step 2: Initialize the Voyager index
72
+ index = indexes.Voyager(
73
+ index_folder="pylate-index",
74
+ index_name="index",
75
+ override=True, # This overwrites the existing index if any
76
+ )
77
+
78
+ # Step 3: Encode the documents
79
+ documents_ids = ["1", "2", "3"]
80
+ documents = ["document 1 text", "document 2 text", "document 3 text"]
81
+
82
+ documents_embeddings = model.encode(
83
+ documents,
84
+ batch_size=32,
85
+ is_query=False, # Ensure that it is set to False to indicate that these are documents, not queries
86
+ show_progress_bar=True,
87
+ )
88
+
89
+ # Step 4: Add document embeddings to the index by providing embeddings and corresponding ids
90
+ index.add_documents(
91
+ documents_ids=documents_ids,
92
+ documents_embeddings=documents_embeddings,
93
+ )
94
+ ```
95
+
96
+ Note that you do not have to recreate the index and encode the documents every time. Once you have created an index and added the documents, you can re-use the index later by loading it:
97
+
98
+ ```python
99
+ # To load an index, simply instantiate it with the correct folder/name and without overriding it
100
+ index = indexes.Voyager(
101
+ index_folder="pylate-index",
102
+ index_name="index",
103
+ )
104
+ ```
105
+
106
+ #### Retrieving top-k documents for queries
107
+
108
+ Once the documents are indexed, you can retrieve the top-k most relevant documents for a given set of queries.
109
+ To do so, initialize the ColBERT retriever with the index you want to search in, encode the queries and then retrieve the top-k documents to get the top matches ids and relevance scores:
110
+
111
+ ```python
112
+ # Step 1: Initialize the ColBERT retriever
113
+ retriever = retrieve.ColBERT(index=index)
114
+
115
+ # Step 2: Encode the queries
116
+ queries_embeddings = model.encode(
117
+ ["query for document 3", "query for document 1"],
118
+ batch_size=32,
119
+ is_query=True, # # Ensure that it is set to False to indicate that these are queries
120
+ show_progress_bar=True,
121
+ )
122
+
123
+ # Step 3: Retrieve top-k documents
124
+ scores = retriever.retrieve(
125
+ queries_embeddings=queries_embeddings,
126
+ k=10, # Retrieve the top 10 matches for each query
127
+ )
128
+ ```
129
+
130
+ ### Reranking
131
+ If you only want to use the ColBERT model to perform reranking on top of your first-stage retrieval pipeline without building an index, you can simply use rank function and pass the queries and documents to rerank:
132
+
133
+ ```python
134
+ from pylate import rank, models
135
+
136
+ queries = [
137
+ "query A",
138
+ "query B",
139
+ ]
140
+
141
+ documents = [
142
+ ["document A", "document B"],
143
+ ["document 1", "document C", "document B"],
144
+ ]
145
+
146
+ documents_ids = [
147
+ [1, 2],
148
+ [1, 3, 2],
149
+ ]
150
+
151
+ model = models.ColBERT(
152
+ model_name_or_path=pylate_model_id,
153
+ )
154
+
155
+ queries_embeddings = model.encode(
156
+ queries,
157
+ is_query=True,
158
+ )
159
+
160
+ documents_embeddings = model.encode(
161
+ documents,
162
+ is_query=False,
163
+ )
164
+
165
+ reranked_documents = rank.rerank(
166
+ documents_ids=documents_ids,
167
+ queries_embeddings=queries_embeddings,
168
+ documents_embeddings=documents_embeddings,
169
+ )
170
+ ```
171
+
172
+ <!--
173
+ ### Direct Usage (Transformers)
174
+
175
+ <details><summary>Click to see the direct usage in Transformers</summary>
176
+
177
+ </details>
178
+ -->
179
+
180
+ <!--
181
+ ### Downstream Usage (Sentence Transformers)
182
+
183
+ You can finetune this model on your own dataset.
184
+
185
+ <details><summary>Click to expand</summary>
186
+
187
+ </details>
188
+ -->
189
+
190
+ <!--
191
+ ### Out-of-Scope Use
192
+
193
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
194
+ -->
195
+
196
+ <!--
197
+ ## Bias, Risks and Limitations
198
+
199
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
200
+ -->
201
+
202
+ <!--
203
+ ### Recommendations
204
+
205
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
206
+ -->
207
+
208
+ ## Training Details
209
+
210
+ ### Training Dataset
211
+
212
+ #### Unnamed Dataset
213
+
214
+
215
+ * Size: 74,683 training samples
216
+ * Columns: <code>query</code>, <code>positive</code>, and <code>negative</code>
217
+ * Approximate statistics based on the first 1000 samples:
218
+ | | query | positive | negative |
219
+ |:--------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|
220
+ | type | string | string | string |
221
+ | details | <ul><li>min: 6 tokens</li><li>mean: 22.92 tokens</li><li>max: 32 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 16.66 tokens</li><li>max: 32 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 15.57 tokens</li><li>max: 32 tokens</li></ul> |
222
+ * Samples:
223
+ | query | positive | negative |
224
+ |:-----------------------------------------------------------------------------------------------------|:-----------------------------------------------------|:----------------------------------------------------------------|
225
+ | <code>هل رأيت الآنسة (ديزي) تقود</code> | <code>هل حصلت على مشاهدة القيادة الآنسة ديزي.</code> | <code>أنا سعيد لأننا شاهدنا "قيادة الآنسة (ديزي) " سوياً</code> |
226
+ | <code>ونعم يا (ستيف) ، أريد أن أسمع نظريتك السياسية لـ (فيل هاريس).</code> | <code>(ستيف) لديه نظرية (فيل هاريس) للسياسة</code> | <code>الأخ والأخت يتعلمون القراءة</code> |
227
+ | <code>هكذا احتفل آل توكوجاوا بدين أسلافهم الشينتو المتمجد بالمزارات الفخمة التي بنوها في نيكو</code> | <code>دين الشنتو كان يحتفل به توكوجاوا</code> | <code>التوكوغاوا لم يبنوا أي معابد شنتو</code> |
228
+ * Loss: <code>pylate.losses.contrastive.Contrastive</code>
229
+
230
+ ### Evaluation Dataset
231
+
232
+ #### Unnamed Dataset
233
+
234
+
235
+ * Size: 4,149 evaluation samples
236
+ * Columns: <code>query</code>, <code>positive</code>, and <code>negative</code>
237
+ * Approximate statistics based on the first 1000 samples:
238
+ | | query | positive | negative |
239
+ |:--------|:---------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|
240
+ | type | string | string | string |
241
+ | details | <ul><li>min: 6 tokens</li><li>mean: 23.0 tokens</li><li>max: 32 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 16.79 tokens</li><li>max: 32 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 15.35 tokens</li><li>max: 32 tokens</li></ul> |
242
+ * Samples:
243
+ | query | positive | negative |
244
+ |:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------|:---------------------------------------------------------------------|
245
+ | <code>كيوتو هي المركز الوطني لتلك التخصصات التقليدية مثل تشا دو (احتفال الشاي) وإيكيبانا (ترتيب الزهور) ، وموطن ولادة الكابوكي، والمركز الرائد للكتابة الخطية والرسم والنحت.</code> | <code>يتم ممارسة الأنشطة التقليدية ، مثل ترتيب الزهور وحفلات الشاي ، في كيوتو.</code> | <code>(راؤول) قام بخيانة الساقي ولم يعط الساقي بقشيشاً واحداً</code> |
246
+ | <code>انت تعلم انهم مازالوا مدمنين للمخدرات ولكنهم شرعيين</code> | <code>إنها عادة مخدرات قانونية لكنها لا تزال عادة مخدرات</code> | <code>امرأة تقف على شاطئ رملي</code> |
247
+ | <code>زورق نهر أزرق مليء بالمرأة يطفو أمام زورق أصفر آخر</code> | <code>الطوف في الماء</code> | <code>تركيز الطفل كامل على الكتاب الذي يقرأه</code> |
248
+ * Loss: <code>pylate.losses.contrastive.Contrastive</code>
249
+
250
+ ### Training Hyperparameters
251
+ #### Non-Default Hyperparameters
252
+
253
+ - `per_device_train_batch_size`: 16
254
+ - `learning_rate`: 3e-06
255
+ - `num_train_epochs`: 1
256
+ - `fp16`: True
257
+
258
+ #### All Hyperparameters
259
+ <details><summary>Click to expand</summary>
260
+
261
+ - `overwrite_output_dir`: False
262
+ - `do_predict`: False
263
+ - `eval_strategy`: no
264
+ - `prediction_loss_only`: True
265
+ - `per_device_train_batch_size`: 16
266
+ - `per_device_eval_batch_size`: 8
267
+ - `per_gpu_train_batch_size`: None
268
+ - `per_gpu_eval_batch_size`: None
269
+ - `gradient_accumulation_steps`: 1
270
+ - `eval_accumulation_steps`: None
271
+ - `torch_empty_cache_steps`: None
272
+ - `learning_rate`: 3e-06
273
+ - `weight_decay`: 0.0
274
+ - `adam_beta1`: 0.9
275
+ - `adam_beta2`: 0.999
276
+ - `adam_epsilon`: 1e-08
277
+ - `max_grad_norm`: 1.0
278
+ - `num_train_epochs`: 1
279
+ - `max_steps`: -1
280
+ - `lr_scheduler_type`: linear
281
+ - `lr_scheduler_kwargs`: {}
282
+ - `warmup_ratio`: 0.0
283
+ - `warmup_steps`: 0
284
+ - `log_level`: passive
285
+ - `log_level_replica`: warning
286
+ - `log_on_each_node`: True
287
+ - `logging_nan_inf_filter`: True
288
+ - `save_safetensors`: True
289
+ - `save_on_each_node`: False
290
+ - `save_only_model`: False
291
+ - `restore_callback_states_from_checkpoint`: False
292
+ - `no_cuda`: False
293
+ - `use_cpu`: False
294
+ - `use_mps_device`: False
295
+ - `seed`: 42
296
+ - `data_seed`: None
297
+ - `jit_mode_eval`: False
298
+ - `use_ipex`: False
299
+ - `bf16`: False
300
+ - `fp16`: True
301
+ - `fp16_opt_level`: O1
302
+ - `half_precision_backend`: auto
303
+ - `bf16_full_eval`: False
304
+ - `fp16_full_eval`: False
305
+ - `tf32`: None
306
+ - `local_rank`: 0
307
+ - `ddp_backend`: None
308
+ - `tpu_num_cores`: None
309
+ - `tpu_metrics_debug`: False
310
+ - `debug`: []
311
+ - `dataloader_drop_last`: False
312
+ - `dataloader_num_workers`: 0
313
+ - `dataloader_prefetch_factor`: None
314
+ - `past_index`: -1
315
+ - `disable_tqdm`: False
316
+ - `remove_unused_columns`: True
317
+ - `label_names`: None
318
+ - `load_best_model_at_end`: False
319
+ - `ignore_data_skip`: False
320
+ - `fsdp`: []
321
+ - `fsdp_min_num_params`: 0
322
+ - `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
323
+ - `fsdp_transformer_layer_cls_to_wrap`: None
324
+ - `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
325
+ - `deepspeed`: None
326
+ - `label_smoothing_factor`: 0.0
327
+ - `optim`: adamw_torch
328
+ - `optim_args`: None
329
+ - `adafactor`: False
330
+ - `group_by_length`: False
331
+ - `length_column_name`: length
332
+ - `ddp_find_unused_parameters`: None
333
+ - `ddp_bucket_cap_mb`: None
334
+ - `ddp_broadcast_buffers`: False
335
+ - `dataloader_pin_memory`: True
336
+ - `dataloader_persistent_workers`: False
337
+ - `skip_memory_metrics`: True
338
+ - `use_legacy_prediction_loop`: False
339
+ - `push_to_hub`: False
340
+ - `resume_from_checkpoint`: None
341
+ - `hub_model_id`: None
342
+ - `hub_strategy`: every_save
343
+ - `hub_private_repo`: None
344
+ - `hub_always_push`: False
345
+ - `gradient_checkpointing`: False
346
+ - `gradient_checkpointing_kwargs`: None
347
+ - `include_inputs_for_metrics`: False
348
+ - `include_for_metrics`: []
349
+ - `eval_do_concat_batches`: True
350
+ - `fp16_backend`: auto
351
+ - `push_to_hub_model_id`: None
352
+ - `push_to_hub_organization`: None
353
+ - `mp_parameters`:
354
+ - `auto_find_batch_size`: False
355
+ - `full_determinism`: False
356
+ - `torchdynamo`: None
357
+ - `ray_scope`: last
358
+ - `ddp_timeout`: 1800
359
+ - `torch_compile`: False
360
+ - `torch_compile_backend`: None
361
+ - `torch_compile_mode`: None
362
+ - `include_tokens_per_second`: False
363
+ - `include_num_input_tokens_seen`: False
364
+ - `neftune_noise_alpha`: None
365
+ - `optim_target_modules`: None
366
+ - `batch_eval_metrics`: False
367
+ - `eval_on_start`: False
368
+ - `use_liger_kernel`: False
369
+ - `eval_use_gather_object`: False
370
+ - `average_tokens_across_devices`: False
371
+ - `prompts`: None
372
+ - `batch_sampler`: batch_sampler
373
+ - `multi_dataset_batch_sampler`: proportional
374
+
375
+ </details>
376
+
377
+ ### Training Logs
378
+ | Epoch | Step | Training Loss |
379
+ |:------:|:----:|:-------------:|
380
+ | 0.2142 | 500 | 0.574 |
381
+ | 0.4284 | 1000 | 0.5062 |
382
+ | 0.6427 | 1500 | 0.4676 |
383
+ | 0.8569 | 2000 | 0.4574 |
384
+
385
+
386
+ ### Framework Versions
387
+ - Python: 3.12.11
388
+ - Sentence Transformers: 4.0.2
389
+ - PyLate: 1.2.0
390
+ - Transformers: 4.52.4
391
+ - PyTorch: 2.7.1+cu126
392
+ - Accelerate: 1.7.0
393
+ - Datasets: 3.6.0
394
+ - Tokenizers: 0.21.1
395
+
396
+
397
+ ## Citation
398
+
399
+ ### BibTeX
400
+
401
+ #### Sentence Transformers
402
+ ```bibtex
403
+ @inproceedings{reimers-2019-sentence-bert,
404
+ title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
405
+ author = "Reimers, Nils and Gurevych, Iryna",
406
+ booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
407
+ month = "11",
408
+ year = "2019",
409
+ publisher = "Association for Computational Linguistics",
410
+ url = "https://arxiv.org/abs/1908.10084"
411
+ }
412
+ ```
413
+
414
+ #### PyLate
415
+ ```bibtex
416
+ @misc{PyLate,
417
+ title={PyLate: Flexible Training and Retrieval for Late Interaction Models},
418
+ author={Chaffin, Antoine and Sourty, Raphaël},
419
+ url={https://github.com/lightonai/pylate},
420
+ year={2024}
421
+ }
422
+ ```
423
+
424
+ <!--
425
+ ## Glossary
426
+
427
+ *Clearly define terms in order to be accessible across audiences.*
428
+ -->
429
+
430
+ <!--
431
+ ## Model Card Authors
432
+
433
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
434
+ -->
435
+
436
+ <!--
437
+ ## Model Card Contact
438
+
439
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
440
+ -->
config.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation_function": "gelu",
3
+ "add_pooling_layer": false,
4
+ "architectures": [
5
+ "NomicBertModel"
6
+ ],
7
+ "attn_pdrop": 0.0,
8
+ "auto_map": {
9
+ "AutoConfig": "configuration_hf_nomic_bert.NomicBertConfig",
10
+ "AutoModel": "nomic-ai/nomic-bert-2048--modeling_hf_nomic_bert.NomicBertModel",
11
+ "AutoModelForMaskedLM": "nomic-ai/nomic-bert-2048--modeling_hf_nomic_bert.NomicBertForPreTraining",
12
+ "AutoModelForMultipleChoice": "nomic-ai/nomic-bert-2048--modeling_hf_nomic_bert.NomicBertForMultipleChoice",
13
+ "AutoModelForQuestionAnswering": "nomic-ai/nomic-bert-2048--modeling_hf_nomic_bert.NomicBertForQuestionAnswering",
14
+ "AutoModelForSequenceClassification": "nomic-ai/nomic-bert-2048--modeling_hf_nomic_bert.NomicBertForSequenceClassification",
15
+ "AutoModelForTokenClassification": "nomic-ai/nomic-bert-2048--modeling_hf_nomic_bert.NomicBertForTokenClassification"
16
+ },
17
+ "bos_token_id": null,
18
+ "causal": false,
19
+ "dense_seq_output": true,
20
+ "embd_pdrop": 0.1,
21
+ "eos_token_id": null,
22
+ "expert_choice_router": false,
23
+ "ffn_div": 1,
24
+ "fused_bias_fc": true,
25
+ "fused_dropout_add_ln": true,
26
+ "initializer_range": 0.02,
27
+ "layer_norm_epsilon": 1e-05,
28
+ "max_trained_positions": 2048,
29
+ "mlp_fc1_bias": true,
30
+ "mlp_fc2_bias": true,
31
+ "model_type": "nomic_bert",
32
+ "moe_every_n_layers": 2,
33
+ "moe_impl": "megablocks",
34
+ "moe_normalize_expert_weights": false,
35
+ "moe_resid_pdrop": 0.0,
36
+ "moe_top_k": 2,
37
+ "n_embd": 768,
38
+ "n_head": 12,
39
+ "n_inner": 3072,
40
+ "n_layer": 12,
41
+ "n_positions": 2048,
42
+ "num_experts": 8,
43
+ "num_shared_experts": 0,
44
+ "pad_token_id": 1,
45
+ "pad_vocab_size_multiple": 64,
46
+ "parallel_block": false,
47
+ "parallel_block_tied_norm": false,
48
+ "prenorm": false,
49
+ "qkv_proj_bias": true,
50
+ "reorder_and_upcast_attn": false,
51
+ "resid_pdrop": 0.0,
52
+ "rotary_emb_base": 10000,
53
+ "rotary_emb_fraction": 1.0,
54
+ "rotary_emb_interleaved": false,
55
+ "rotary_emb_scale_base": null,
56
+ "rotary_scaling_factor": null,
57
+ "router_aux_loss_coef": 0.1,
58
+ "scale_attn_by_inverse_layer_idx": false,
59
+ "scale_attn_weights": true,
60
+ "summary_activation": null,
61
+ "summary_first_dropout": 0.1,
62
+ "summary_proj_to_labels": true,
63
+ "summary_type": "cls_index",
64
+ "summary_use_proj": true,
65
+ "torch_dtype": "float32",
66
+ "transformers_version": "4.52.4",
67
+ "type_vocab_size": 1,
68
+ "use_cache": true,
69
+ "use_flash_attn": true,
70
+ "use_rms_norm": null,
71
+ "use_xentropy": true,
72
+ "vocab_size": 250048
73
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "4.0.2",
4
+ "transformers": "4.52.4",
5
+ "pytorch": "2.7.1+cu126"
6
+ },
7
+ "prompts": {
8
+ "query": "search_query: ",
9
+ "passage": "search_document: ",
10
+ "Classification": "classification: ",
11
+ "MultilabelClassification": "classification: ",
12
+ "Clustering": "clustering: ",
13
+ "PairClassification": "classification: ",
14
+ "STS": "classification: ",
15
+ "Summarization": "classification: ",
16
+ "Speed": "search_document: "
17
+ },
18
+ "default_prompt_name": null,
19
+ "similarity_fn_name": "MaxSim",
20
+ "query_prefix": "[Q] ",
21
+ "document_prefix": "[D] ",
22
+ "query_length": 32,
23
+ "document_length": 180,
24
+ "attend_to_expansion_tokens": false,
25
+ "skiplist_words": [
26
+ "!",
27
+ "\"",
28
+ "#",
29
+ "$",
30
+ "%",
31
+ "&",
32
+ "'",
33
+ "(",
34
+ ")",
35
+ "*",
36
+ "+",
37
+ ",",
38
+ "-",
39
+ ".",
40
+ "/",
41
+ ":",
42
+ ";",
43
+ "<",
44
+ "=",
45
+ ">",
46
+ "?",
47
+ "@",
48
+ "[",
49
+ "\\",
50
+ "]",
51
+ "^",
52
+ "_",
53
+ "`",
54
+ "{",
55
+ "|",
56
+ "}",
57
+ "~"
58
+ ]
59
+ }
configuration_hf_nomic_bert.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import GPT2Config
2
+
3
+
4
+ class NomicBertConfig(GPT2Config):
5
+ model_type = "nomic_bert"
6
+
7
+ def __init__(
8
+ self,
9
+ prenorm=False,
10
+ parallel_block=False,
11
+ parallel_block_tied_norm=False,
12
+ rotary_emb_fraction=0.0,
13
+ fused_dropout_add_ln=False,
14
+ fused_bias_fc=False,
15
+ use_flash_attn=False,
16
+ use_xentropy=False,
17
+ qkv_proj_bias=True,
18
+ rotary_emb_base=10_000,
19
+ rotary_emb_scale_base=None,
20
+ rotary_emb_interleaved=False,
21
+ mlp_fc1_bias=True,
22
+ mlp_fc2_bias=True,
23
+ use_rms_norm=False,
24
+ causal=False,
25
+ type_vocab_size=2,
26
+ dense_seq_output=True,
27
+ pad_vocab_size_multiple=1,
28
+ tie_word_embeddings=True,
29
+ rotary_scaling_factor=None,
30
+ max_trained_positions=2048,
31
+ **kwargs,
32
+ ):
33
+ self.prenorm = prenorm
34
+ self.parallel_block = parallel_block
35
+ self.parallel_block_tied_norm = parallel_block_tied_norm
36
+ self.rotary_emb_fraction = rotary_emb_fraction
37
+ self.tie_word_embeddings = tie_word_embeddings
38
+ self.fused_dropout_add_ln = fused_dropout_add_ln
39
+ self.fused_bias_fc = fused_bias_fc
40
+ self.use_flash_attn = use_flash_attn
41
+ self.use_xentropy = use_xentropy
42
+ self.qkv_proj_bias = qkv_proj_bias
43
+ self.rotary_emb_base = rotary_emb_base
44
+ self.rotary_emb_scale_base = rotary_emb_scale_base
45
+ self.rotary_emb_interleaved = rotary_emb_interleaved
46
+ self.mlp_fc1_bias = mlp_fc1_bias
47
+ self.mlp_fc2_bias = mlp_fc2_bias
48
+ self.use_rms_norm = use_rms_norm
49
+ self.causal = causal
50
+ self.type_vocab_size = type_vocab_size
51
+ self.dense_seq_output = dense_seq_output
52
+ self.pad_vocab_size_multiple = pad_vocab_size_multiple
53
+ self.rotary_scaling_factor = rotary_scaling_factor
54
+ self.max_trained_positions = max_trained_positions
55
+
56
+ super().__init__(**kwargs)
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ab1dcd4c5e72543f2afa30c62db1113b4c0c4153844480dc961d8cc3fc36561
3
+ size 1901187232
modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Dense",
12
+ "type": "pylate.models.Dense.Dense"
13
+ }
14
+ ]
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 31,
3
+ "do_lower_case": false
4
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "cls_token": {
10
+ "content": "<s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "eos_token": {
17
+ "content": "</s>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "mask_token": {
24
+ "content": "<mask>",
25
+ "lstrip": true,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "pad_token": "<mask>",
31
+ "sep_token": {
32
+ "content": "</s>",
33
+ "lstrip": false,
34
+ "normalized": false,
35
+ "rstrip": false,
36
+ "single_word": false
37
+ },
38
+ "unk_token": {
39
+ "content": "<unk>",
40
+ "lstrip": false,
41
+ "normalized": false,
42
+ "rstrip": false,
43
+ "single_word": false
44
+ }
45
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:90cebc4c9a7d2a9bd962629f92b71f52656fe63bec030ac0bd3e45b8ecd99a18
3
+ size 17083003
tokenizer_config.json ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "<s>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "<pad>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "</s>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "<unk>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "250001": {
36
+ "content": "<mask>",
37
+ "lstrip": true,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "bos_token": "<s>",
45
+ "clean_up_tokenization_spaces": true,
46
+ "cls_token": "<s>",
47
+ "eos_token": "</s>",
48
+ "extra_special_tokens": {},
49
+ "mask_token": "<mask>",
50
+ "max_length": 179,
51
+ "model_max_length": 179,
52
+ "pad_to_multiple_of": null,
53
+ "pad_token": "<mask>",
54
+ "pad_token_type_id": 0,
55
+ "padding_side": "right",
56
+ "sep_token": "</s>",
57
+ "stride": 0,
58
+ "tokenizer_class": "XLMRobertaTokenizerFast",
59
+ "truncation_side": "right",
60
+ "truncation_strategy": "longest_first",
61
+ "unk_token": "<unk>"
62
+ }