xmanii commited on
Commit
fa3375e
·
verified ·
1 Parent(s): d528342

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +137 -322
README.md CHANGED
@@ -1,322 +1,137 @@
1
- ---
2
- tags:
3
- - sentence-transformers
4
- - sentence-similarity
5
- - feature-extraction
6
- - generated_from_trainer
7
- - dataset_size:80000
8
- - loss:MultipleNegativesRankingLoss
9
- base_model: Alibaba-NLP/gte-multilingual-base
10
- pipeline_tag: sentence-similarity
11
- library_name: sentence-transformers
12
- datasets:
13
- - mshojaei77/Persian_sft
14
- language:
15
- - fa
16
- ---
17
-
18
- # SentenceTransformer based on Alibaba-NLP/gte-multilingual-base
19
-
20
- This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [Alibaba-NLP/gte-multilingual-base](https://huggingface.co/Alibaba-NLP/gte-multilingual-base). It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
21
-
22
- ## Model Details
23
-
24
- ### Model Description
25
- - **Model Type:** Sentence Transformer
26
- - **Base model:** [Alibaba-NLP/gte-multilingual-base](https://huggingface.co/Alibaba-NLP/gte-multilingual-base) <!-- at revision 9fdd4ee8bba0e2808a34e0e739576f6740d2b225 -->
27
- - **Maximum Sequence Length:** 8192 tokens
28
- - **Output Dimensionality:** 768 dimensions
29
- - **Similarity Function:** Cosine Similarity
30
- - **Training Dataset:** [mshojaei77/Persian_sft](https://huggingface.co/datasets/mshojaei77/Persian_sft)
31
- <!-- - **Language:** Unknown -->
32
- <!-- - **License:** Unknown -->
33
-
34
- ### Model Sources
35
-
36
- - **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
37
- - **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
38
- - **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
39
-
40
- ### Full Model Architecture
41
-
42
- ```
43
- SentenceTransformer(
44
- (0): Transformer({'max_seq_length': 8192, 'do_lower_case': False}) with Transformer model: NewModel
45
- (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
46
- (2): Normalize()
47
- )
48
- ```
49
-
50
- ## Usage
51
-
52
- ### Direct Usage (Sentence Transformers)
53
-
54
- First install the Sentence Transformers library:
55
-
56
- ```bash
57
- pip install -U sentence-transformers
58
- ```
59
-
60
- Then you can load this model and run inference.
61
- ```python
62
- from sentence_transformers import SentenceTransformer
63
-
64
- # Download from the 🤗 Hub
65
- model = SentenceTransformer("sentence_transformers_model_id")
66
- # Run inference
67
- sentences = [
68
- 'برج میلاد در تهران هست',
69
- 'یکی از برج های مسکونی تهران برج تهران است',
70
- 'تهران برج های زیادی دارد'
71
- ]
72
- embeddings = model.encode(sentences)
73
- print(embeddings.shape)
74
- # [3, 768]
75
-
76
- # Get the similarity scores for the embeddings
77
- similarities = model.similarity(embeddings, embeddings)
78
- print(similarities.shape)
79
- # [3, 3]
80
- ```
81
-
82
- <!--
83
- ### Direct Usage (Transformers)
84
-
85
- <details><summary>Click to see the direct usage in Transformers</summary>
86
-
87
- </details>
88
- -->
89
-
90
- <!--
91
- ### Downstream Usage (Sentence Transformers)
92
-
93
- You can finetune this model on your own dataset.
94
-
95
- <details><summary>Click to expand</summary>
96
-
97
- </details>
98
- -->
99
-
100
- <!--
101
- ### Out-of-Scope Use
102
-
103
- *List how the model may foreseeably be misused and address what users ought not to do with the model.*
104
- -->
105
-
106
- <!--
107
- ## Bias, Risks and Limitations
108
-
109
- *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
110
- -->
111
-
112
- <!--
113
- ### Recommendations
114
-
115
- *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
116
- -->
117
-
118
-
119
- #### Persian_sft Dataset
120
- This model was also fine-tuned on the [mshojaei77/Persian_sft](https://huggingface.co/datasets/mshojaei77/Persian_sft) dataset.
121
-
122
-
123
- * Size: 80,000 training samples
124
- * Columns: <code>sentence_0</code> and <code>sentence_1</code>
125
- * Approximate statistics based on the first 1000 samples:
126
- | | sentence_0 | sentence_1 |
127
- |:--------|:-----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|
128
- | type | string | string |
129
- | details | <ul><li>min: 7 tokens</li><li>mean: 19.27 tokens</li><li>max: 276 tokens</li></ul> | <ul><li>min: 12 tokens</li><li>mean: 90.8 tokens</li><li>max: 514 tokens</li></ul> |
130
- * Loss: [<code>MultipleNegativesRankingLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#multiplenegativesrankingloss) with these parameters:
131
- ```json
132
- {
133
- "scale": 20.0,
134
- "similarity_fct": "cos_sim"
135
- }
136
- ```
137
-
138
- ### Training Hyperparameters
139
- #### Non-Default Hyperparameters
140
-
141
- - `per_device_train_batch_size`: 64
142
- - `per_device_eval_batch_size`: 64
143
- - `fp16`: bf16
144
- - `multi_dataset_batch_sampler`: round_robin
145
-
146
- #### All Hyperparameters
147
- <details><summary>Click to expand</summary>
148
-
149
- - `overwrite_output_dir`: False
150
- - `do_predict`: False
151
- - `eval_strategy`: no
152
- - `prediction_loss_only`: True
153
- - `per_device_train_batch_size`: 64
154
- - `per_device_eval_batch_size`: 64
155
- - `per_gpu_train_batch_size`: None
156
- - `per_gpu_eval_batch_size`: None
157
- - `gradient_accumulation_steps`: 1
158
- - `eval_accumulation_steps`: None
159
- - `torch_empty_cache_steps`: None
160
- - `learning_rate`: 5e-05
161
- - `weight_decay`: 0.0
162
- - `adam_beta1`: 0.9
163
- - `adam_beta2`: 0.999
164
- - `adam_epsilon`: 1e-08
165
- - `max_grad_norm`: 1
166
- - `num_train_epochs`: 3
167
- - `max_steps`: -1
168
- - `lr_scheduler_type`: linear
169
- - `lr_scheduler_kwargs`: {}
170
- - `warmup_ratio`: 0.0
171
- - `warmup_steps`: 0
172
- - `log_level`: passive
173
- - `log_level_replica`: warning
174
- - `log_on_each_node`: True
175
- - `logging_nan_inf_filter`: True
176
- - `save_safetensors`: True
177
- - `save_on_each_node`: False
178
- - `save_only_model`: False
179
- - `restore_callback_states_from_checkpoint`: False
180
- - `no_cuda`: False
181
- - `use_cpu`: False
182
- - `use_mps_device`: False
183
- - `seed`: 42
184
- - `data_seed`: None
185
- - `jit_mode_eval`: False
186
- - `use_ipex`: False
187
- - `bf16`: False
188
- - `fp16`: bf16
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
- - `tp_size`: 0
212
- - `fsdp_transformer_layer_cls_to_wrap`: None
213
- - `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
214
- - `deepspeed`: None
215
- - `label_smoothing_factor`: 0.0
216
- - `optim`: adamw_torch
217
- - `optim_args`: None
218
- - `adafactor`: False
219
- - `group_by_length`: False
220
- - `length_column_name`: length
221
- - `ddp_find_unused_parameters`: None
222
- - `ddp_bucket_cap_mb`: None
223
- - `ddp_broadcast_buffers`: False
224
- - `dataloader_pin_memory`: True
225
- - `dataloader_persistent_workers`: False
226
- - `skip_memory_metrics`: True
227
- - `use_legacy_prediction_loop`: False
228
- - `push_to_hub`: False
229
- - `resume_from_checkpoint`: None
230
- - `hub_model_id`: None
231
- - `hub_strategy`: every_save
232
- - `hub_private_repo`: None
233
- - `hub_always_push`: False
234
- - `gradient_checkpointing`: False
235
- - `gradient_checkpointing_kwargs`: None
236
- - `include_inputs_for_metrics`: False
237
- - `include_for_metrics`: []
238
- - `eval_do_concat_batches`: True
239
- - `fp16_backend`: auto
240
- - `push_to_hub_model_id`: None
241
- - `push_to_hub_organization`: None
242
- - `mp_parameters`:
243
- - `auto_find_batch_size`: False
244
- - `full_determinism`: False
245
- - `torchdynamo`: None
246
- - `ray_scope`: last
247
- - `ddp_timeout`: 1800
248
- - `torch_compile`: False
249
- - `torch_compile_backend`: None
250
- - `torch_compile_mode`: None
251
- - `include_tokens_per_second`: False
252
- - `include_num_input_tokens_seen`: False
253
- - `neftune_noise_alpha`: None
254
- - `optim_target_modules`: None
255
- - `batch_eval_metrics`: False
256
- - `eval_on_start`: False
257
- - `use_liger_kernel`: False
258
- - `eval_use_gather_object`: False
259
- - `average_tokens_across_devices`: False
260
- - `prompts`: None
261
- - `batch_sampler`: batch_sampler
262
- - `multi_dataset_batch_sampler`: round_robin
263
-
264
- </details>
265
-
266
- ### Framework Versions
267
- - Python: 3.10.8
268
- - Sentence Transformers: 4.1.0
269
- - Transformers: 4.51.3
270
- - PyTorch: 2.7.0+cu126
271
- - Accelerate: 1.6.0
272
- - Datasets: 3.6.0
273
- - Tokenizers: 0.21.1
274
-
275
- Special thanks to [mshojaei77](https://huggingface.co/mshojaei77) for providing the `Persian_sft` dataset used in fine-tuning this model.
276
-
277
- ## Citation
278
-
279
- ### BibTeX
280
-
281
- #### Sentence Transformers
282
- ```bibtex
283
- @inproceedings{reimers-2019-sentence-bert,
284
- title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
285
- author = "Reimers, Nils and Gurevych, Iryna",
286
- booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
287
- month = "11",
288
- year = "2019",
289
- publisher = "Association for Computational Linguistics",
290
- url = "https://arxiv.org/abs/1908.10084",
291
- }
292
- ```
293
-
294
- #### MultipleNegativesRankingLoss
295
- ```bibtex
296
- @misc{henderson2017efficient,
297
- title={Efficient Natural Language Response Suggestion for Smart Reply},
298
- 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},
299
- year={2017},
300
- eprint={1705.00652},
301
- archivePrefix={arXiv},
302
- primaryClass={cs.CL}
303
- }
304
- ```
305
-
306
- <!--
307
- ## Glossary
308
-
309
- *Clearly define terms in order to be accessible across audiences.*
310
- -->
311
-
312
- <!--
313
- ## Model Card Authors
314
-
315
- *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
316
- -->
317
-
318
- <!--
319
- ## Model Card Contact
320
-
321
- *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
322
- -->
 
1
+ ---
2
+ tags:
3
+ - sentence-transformers
4
+ - sentence-similarity
5
+ - feature-extraction
6
+ - generated_from_trainer
7
+ - dataset_size:80000
8
+ - loss:MultipleNegativesRankingLoss
9
+ base_model: Alibaba-NLP/gte-multilingual-base
10
+ pipeline_tag: sentence-similarity
11
+ library_name: sentence-transformers
12
+ datasets:
13
+ - mshojaei77/Persian_sft
14
+ language:
15
+ - fa
16
+ ---
17
+
18
+ # maux-gte-persian-v3 (fp16)
19
+ **A high-performance Persian sentence embedding model based on Alibaba-NLP/gte-multilingual-base, released in fp16 for efficient inference.**
20
+
21
+ ---
22
+
23
+ ## Model Overview
24
+
25
+ This is the **fp16 (half-precision)** version of [maux-gte-persian-v3](https://huggingface.co/xmanii/maux-gte-persian-v3), a Sentence Transformers model fine-tuned from [Alibaba-NLP/gte-multilingual-base](https://huggingface.co/Alibaba-NLP/gte-multilingual-base) for robust Persian sentence and paragraph embeddings.
26
+ The fp16 format enables faster and more memory-efficient inference, especially on modern GPUs.
27
+
28
+ **Key Features:**
29
+ - **Base Model:** Alibaba-NLP/gte-multilingual-base
30
+ - **Fine-tuned on:** [mshojaei77/Persian_sft](https://huggingface.co/datasets/mshojaei77/Persian_sft) (80,000 Persian sentence pairs)
31
+ - **Output Dimension:** 768
32
+ - **Max Sequence Length:** 8192 tokens
33
+ - **Similarity Function:** Cosine Similarity
34
+ - **Loss Function:** MultipleNegativesRankingLoss
35
+ - **Format:** fp16 (`model.safetensors`)
36
+
37
+ ---
38
+
39
+ ## Performance
40
+
41
+ - **Excellent performance** on Persian semantic similarity, search, and clustering tasks.
42
+ - **Outperforms** or matches [jinaai-v3](https://huggingface.co/jinaai/jina-embeddings-v3-base-fa) in most Persian benchmarks (see [comparison charts](./jinaai_v3_vs_maux_v3_comparison.png)).
43
+ - Efficient for large-scale inference due to fp16 weights.
44
+
45
+ ---
46
+
47
+ ## Model Architecture
48
+
49
+ ```python
50
+ SentenceTransformer(
51
+ (0): Transformer({'max_seq_length': 8192, 'do_lower_case': False}) with Transformer model: NewModel
52
+ (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, ...})
53
+ (2): Normalize()
54
+ )
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Usage
60
+
61
+ ```python
62
+ from sentence_transformers import SentenceTransformer
63
+
64
+ model = SentenceTransformer("xmanii/maux-gte-persian-v3-fp16", trust_remote_code=True)
65
+ sentences = [
66
+ 'برج میلاد در تهران هست',
67
+ 'یکی از برج های مسکونی تهران برج تهران است',
68
+ 'تهران برج های زیادی دارد'
69
+ ]
70
+ embeddings = model.encode(sentences)
71
+ print(embeddings.shape) # [3, 768]
72
+
73
+ # Compute cosine similarity
74
+ similarities = model.similarity(embeddings, embeddings)
75
+ print(similarities.shape) # [3, 3]
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Training Details
81
+
82
+ - **Dataset:** [mshojaei77/Persian_sft](https://huggingface.co/datasets/mshojaei77/Persian_sft)
83
+ - **Loss:** MultipleNegativesRankingLoss (scale=20.0, similarity_fct="cos_sim")
84
+ - **Batch size:** 64
85
+ - **Precision:** bf16 during training, fp16 for this release
86
+ - **Frameworks:** Python 3.10, Sentence Transformers 4.1.0, Transformers 4.51.3, PyTorch 2.7.0+cu126
87
+
88
+ ---
89
+
90
+ ## Files
91
+
92
+ - `model.safetensors` (fp16 weights)
93
+ - All necessary config and tokenizer files
94
+ - Custom code: `modeling.py`, `configuration.py` (required for loading)
95
+
96
+ ---
97
+
98
+ ## Citation
99
+
100
+ If you use this model, please cite:
101
+
102
+ ```bibtex
103
+ @inproceedings{reimers-2019-sentence-bert,
104
+ title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
105
+ author = "Reimers, Nils and Gurevych, Iryna",
106
+ booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
107
+ month = "11",
108
+ year = "2019",
109
+ publisher = "Association for Computational Linguistics",
110
+ url = "https://arxiv.org/abs/1908.10084",
111
+ }
112
+ @misc{henderson2017efficient,
113
+ title={Efficient Natural Language Response Suggestion for Smart Reply},
114
+ 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},
115
+ year={2017},
116
+ eprint={1705.00652},
117
+ archivePrefix={arXiv},
118
+ primaryClass={cs.CL}
119
+ }
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Acknowledgements
125
+
126
+ - Special thanks to [mshojaei77](https://huggingface.co/mshojaei77) for the Persian_sft dataset.
127
+ - Built on top of [Alibaba-NLP/gte-multilingual-base](https://huggingface.co/Alibaba-NLP/gte-multilingual-base).
128
+
129
+ ---
130
+
131
+ ## License
132
+
133
+ This model is distributed under the same license as the base model and dataset.
134
+
135
+ ---
136
+
137
+ **For questions or feedback, please open an issue or discussion on the Hugging Face model page.**