Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 15
How to use ani122312/bge-m3-hamsai-finetuned with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("ani122312/bge-m3-hamsai-finetuned")
sentences = [
"Which customer condition applies according to سياسة الاسترجاع والاستبدال - Returns and Exchange Policy 4?",
"Billing and Payments section 1 applies to HamsAI Core CRM customers in Jeddah. The primary rule for invoice is 2 business days, while the escalation or completion target for Net 30 is 5 business days. Customers must submit the request through the HamsAI portal and include the contract id, invoice date, customer name, city, and affected service. The standard administrative amount for this case is SAR 225, and the equivalent reference value is also recorded with Eastern Arabic numeral marker ١. Exceptions require written approval from the enterprise success manager. This section is intentionally close to other billing sections so retrieval must distinguish numbers, product names, dates, and negation. The policy is effective from 30 May 2026 and remains valid until replaced by a newer document. Source evidence must cite this exact document when answering.",
"يوضح هذا المستند المختلط Mixed Policy رقم 6 قواعد سياسة الاسترجاع والاستبدال الخاصة بـ نظام HamsAI Core CRM / HamsAI Core CRM. The operational threshold for defect is 50 requests per month (٥٠ طلب)، and the fee for exceeding it is SAR 960. يجب استخدام المصطلح التقني shipping fee كما هو في تذاكر الدعم لأن فرق التشغيل في الرياض وجدة والدمام تعتمد عليه في التصنيف. If the customer asks in Arabic, the answer may still need to retrieve this mixed document because the product name, API code, or SLA label appears in English. لا يجوز تعميم هذه القاعدة على منتجات أخرى، ولا تنطبق عند وجود إعفاء مكتوب في العقد. Effective date: 30 May 2026.",
"يوضح هذا المستند المختلط Mixed Policy رقم 4 قواعد سياسة الاسترجاع والاستبدال الخاصة بـ كرسي Ergonomic Chair Pro / Ergonomic Chair Pro. The operational threshold for defect is 40 requests per month (٤٠ طلب)، and the fee for exceeding it is SAR 740. يجب استخدام المصطلح التقني shipping fee كما هو في تذاكر الدعم لأن فرق التشغيل في الرياض وجدة والدمام تعتمد عليه في التصنيف. If the customer asks in Arabic, the answer may still need to retrieve this mixed document because the product name, API code, or SLA label appears in English. لا يجوز تعميم هذه القاعدة على منتجات أخرى، ولا تنطبق عند وجود إعفاء مكتوب في العقد. Effective date: 30 May 2026."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from BAAI/bge-m3. It maps sentences & paragraphs to a 1024-dimensional dense vector space and can be used for retrieval.
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'XLMRobertaModel'})
(1): Pooling({'embedding_dimension': 1024, 'pooling_mode': 'cls', 'include_prompt': True})
(2): Normalize({})
)
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("ani122312/bge-m3-hamsai-finetuned")
# Run inference
sentences = [
'اشرح سياسة commercial المرتبطة بهذا المستند.',
'Subscription Pricing section 7 applies to HamsAI SmartDesk customers in Jeddah. The primary rule for SaaS Pro is 2 business days, while the escalation or completion target for Enterprise Suite is 5 business days. Customers must submit the request through the HamsAI portal and include the contract id, invoice date, customer name, city, and affected service. The standard administrative amount for this case is SAR 675, and the equivalent reference value is also recorded with Eastern Arabic numeral marker ٧. Exceptions require written approval from the enterprise success manager. This section is intentionally close to other pricing sections so retrieval must distinguish numbers, product names, dates, and negation. The policy is effective from 30 May 2026 and remains valid until replaced by a newer document. Source evidence must cite this exact document when answering.',
'Subscription Pricing section 4 applies to Ergonomic Chair Pro customers in Jeddah. The primary rule for SaaS Pro is 5 business days, while the escalation or completion target for Enterprise Suite is 8 business days. Customers must submit the request through the HamsAI portal and include the contract id, invoice date, customer name, city, and affected service. The standard administrative amount for this case is SAR 450, and the equivalent reference value is also recorded with Eastern Arabic numeral marker ٤. Exceptions require written approval from the enterprise success manager. This section is intentionally close to other pricing sections so retrieval must distinguish numbers, product names, dates, and negation. The policy is effective from 30 May 2026 and remains valid until replaced by a newer document. Source evidence must cite this exact document when answering.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1024]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.2996, 0.3105],
# [0.2996, 1.0000, 0.1838],
# [0.3105, 0.1838, 1.0000]])
anchor, positive, and negative| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| modality | text | text | text |
| details |
|
|
|
| anchor | positive | negative |
|---|---|---|
Which customer condition applies according to Returns and Exchange Policy - Section 5? |
Returns and Exchange Policy section 5 applies to HamsAI Cloud ERP customers in Dammam. The primary rule for return window is 6 business days, while the escalation or completion target for refund is 9 business days. Customers must submit the request through the HamsAI portal and include the contract id, invoice date, customer name, city, and affected service. The standard administrative amount for this case is SAR 525, and the equivalent reference value is also recorded with Eastern Arabic numeral marker ٥. Exceptions require written approval from the enterprise success manager. This section is intentionally close to other returns sections so retrieval must distinguish numbers, product names, dates, and negation. The policy is effective from 30 May 2026 and remains valid until replaced by a newer document. Source evidence must cite this exact document when answering. |
Returns and Exchange Policy section 2 applies to HamsAI SmartDesk customers in Dammam. The primary rule for return window is 3 business days, while the escalation or completion target for refund is 6 business days. Customers must submit the request through the HamsAI portal and include the contract id, invoice date, customer name, city, and affected service. The standard administrative amount for this case is SAR 300, and the equivalent reference value is also recorded with Eastern Arabic numeral marker ٢. Exceptions require written approval from the enterprise success manager. This section is intentionally close to other returns sections so retrieval must distinguish numbers, product names, dates, and negation. The policy is effective from 30 May 2026 and remains valid until replaced by a newer document. Source evidence must cite this exact document when answering. |
كم تبلغ الرسوم أو المهلة المذكورة في infrastructure_mixed_005؟ |
يوضح هذا المستند المختلط Mixed Policy رقم 5 قواعد متطلبات البنية التحتية الخاصة بـ نظام HamsAI Cloud ERP / HamsAI Cloud ERP. The operational threshold for PostgreSQL is 45 requests per month (٤٥ طلب)، and the fee for exceeding it is SAR 850. يجب استخدام المصطلح التقني Docker كما هو في تذاكر الدعم لأن فرق التشغيل في الرياض وجدة والدمام تعتمد عليه في التصنيف. If the customer asks in Arabic, the answer may still need to retrieve this mixed document because the product name, API code, or SLA label appears in English. لا يجوز تعميم هذه القاعدة على منتجات أخرى، ولا تنطبق عند وجود إعفاء مكتوب في العقد. Effective date: 30 May 2026. |
ينطبق قسم دليل واجهات API رقم 3 على عملاء خزانة HamsAI ServerRack X1 في الرياض. القاعدة الأساسية الخاصة بـ مصادقة OAuth2 هي 5 أيام عمل، بينما تكون مهلة حد الطلبات 9 أيام عمل من تاريخ قبول الطلب. يجب على العميل إرسال الطلب من خلال بوابة HamsAI مع رقم العقد وتاريخ الفاتورة واسم العميل والمدينة والخدمة المتأثرة. تبلغ الرسوم الإدارية لهذه الحالة 470 ريال سعودي (٤٧٠ ر.س). لا يتم تطبيق الاستثناءات إلا بعد موافقة مكتوبة من مدير نجاح العملاء. تم تصميم هذا النص ليكون قريباً دلالياً من أقسام أخرى في api حتى يختبر النظام الأرقام والتواريخ والأسماء وحالات النفي بدقة. تسري السياسة اعتباراً من 30 مايو 2026 ويجب الاستشهاد بهذا المستند تحديداً عند الإجابة. |
What is the SAR fee and Arabic condition in متطلبات البنية التحتية - Infrastructure Requirements 2? |
يوضح هذا المستند المختلط Mixed Policy رقم 2 قواعد متطلبات البنية التحتية الخاصة بـ مكتب HamsAI SmartDesk / HamsAI SmartDesk. The operational threshold for PostgreSQL is 30 requests per month (٣٠ طلب)، and the fee for exceeding it is SAR 520. يجب استخدام المصطلح التقني Docker كما هو في تذاكر الدعم لأن فرق التشغيل في الرياض وجدة والدمام تعتمد عليه في التصنيف. If the customer asks in Arabic, the answer may still need to retrieve this mixed document because the product name, API code, or SLA label appears in English. لا يجوز تعميم هذه القاعدة على منتجات أخرى، ولا تنطبق عند وجود إعفاء مكتوب في العقد. Effective date: 30 May 2026. |
يوضح هذا المستند المختلط Mixed Policy رقم 6 قواعد متطلبات البنية التحتية الخاصة بـ نظام HamsAI Core CRM / HamsAI Core CRM. The operational threshold for PostgreSQL is 50 requests per month (٥٠ طلب)، and the fee for exceeding it is SAR 960. يجب استخدام المصطلح التقني Docker كما هو في تذاكر الدعم لأن فرق التشغيل في الرياض وجدة والدمام تعتمد عليه في التصنيف. If the customer asks in Arabic, the answer may still need to retrieve this mixed document because the product name, API code, or SLA label appears in English. لا يجوز تعميم هذه القاعدة على منتجات أخرى، ولا تنطبق عند وجود إعفاء مكتوب في العقد. Effective date: 30 May 2026. |
TripletLoss with these parameters:{
"distance_metric": "TripletDistanceMetric.EUCLIDEAN",
"triplet_margin": 5
}
anchor, positive, and negative| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| modality | text | text | text |
| details |
|
|
|
| anchor | positive | negative |
|---|---|---|
What fee, date, or deadline is stated in api_en_001? |
API Integration Guide section 1 applies to HamsAI Core CRM customers in Jeddah. The primary rule for OAuth2 is 2 business days, while the escalation or completion target for rate limit is 5 business days. Customers must submit the request through the HamsAI portal and include the contract id, invoice date, customer name, city, and affected service. The standard administrative amount for this case is SAR 225, and the equivalent reference value is also recorded with Eastern Arabic numeral marker ١. Exceptions require written approval from the enterprise success manager. This section is intentionally close to other api sections so retrieval must distinguish numbers, product names, dates, and negation. The policy is effective from 30 May 2026 and remains valid until replaced by a newer document. Source evidence must cite this exact document when answering. |
ينطبق قسم متطلبات البنية التحتية رقم 2 على عملاء مكتب HamsAI SmartDesk في الدمام. القاعدة الأساسية الخاصة بـ أنوية المعالج هي 4 أيام عمل، بينما تكون مهلة الذاكرة 8 أيام عمل من تاريخ قبول الطلب. يجب على العميل إرسال الطلب من خلال بوابة HamsAI مع رقم العقد وتاريخ الفاتورة واسم العميل والمدينة والخدمة المتأثرة. تبلغ الرسوم الإدارية لهذه الحالة 380 ريال سعودي (٣٨٠ ر.س). لا يتم تطبيق الاستثناءات إلا بعد موافقة مكتوبة من مدير نجاح العملاء. تم تصميم هذا النص ليكون قريباً دلالياً من أقسام أخرى في infrastructure حتى يختبر النظام الأرقام والتواريخ والأسماء وحالات النفي بدقة. تسري السياسة اعتباراً من 30 مايو 2026 ويجب الاستشهاد بهذا المستند تحديداً عند الإجابة. |
اذكر threshold و الرسوم في warranty_mixed_001. |
يوضح هذا المستند المختلط Mixed Policy رقم 1 قواعد ضمان الأجهزة والأثاث الخاصة بـ نظام HamsAI Core CRM / HamsAI Core CRM. The operational threshold for technician visit is 25 requests per month (٢٥ طلب)، and the fee for exceeding it is SAR 410. يجب استخدام المصطلح التقني replacement كما هو في تذاكر الدعم لأن فرق التشغيل في الرياض وجدة والدمام تعتمد عليه في التصنيف. If the customer asks in Arabic, the answer may still need to retrieve this mixed document because the product name, API code, or SLA label appears in English. لا يجوز تعميم هذه القاعدة على منتجات أخرى، ولا تنطبق عند وجود إعفاء مكتوب في العقد. Effective date: 30 May 2026. |
ينطبق قسم ضمان الأجهزة والأثاث رقم 6 على عملاء نظام HamsAI Core CRM في الرياض. القاعدة الأساسية الخاصة بـ الضمان المحدود هي 8 أيام عمل، بينما تكون مهلة تمديد الضمان 12 أيام عمل من تاريخ قبول الطلب. يجب على العميل إرسال الطلب من خلال بوابة HamsAI مع رقم العقد وتاريخ الفاتورة واسم العميل والمدينة والخدمة المتأثرة. تبلغ الرسوم الإدارية لهذه الحالة 740 ريال سعودي (٧٤٠ ر.س). لا يتم تطبيق الاستثناءات إلا بعد موافقة مكتوبة من مدير نجاح العملاء. تم تصميم هذا النص ليكون قريباً دلالياً من أقسام أخرى في warranty حتى يختبر النظام الأرقام والتواريخ والأسماء وحالات النفي بدقة. تسري السياسة اعتباراً من 30 مايو 2026 ويجب الاستشهاد بهذا المستند تحديداً عند الإجابة. |
ما هي القاعدة الأساسية في مستند ضمان الأجهزة والأثاث - Hardware and Furniture Warranty 1؟ |
يوضح هذا المستند المختلط Mixed Policy رقم 1 قواعد ضمان الأجهزة والأثاث الخاصة بـ نظام HamsAI Core CRM / HamsAI Core CRM. The operational threshold for technician visit is 25 requests per month (٢٥ طلب)، and the fee for exceeding it is SAR 410. يجب استخدام المصطلح التقني replacement كما هو في تذاكر الدعم لأن فرق التشغيل في الرياض وجدة والدمام تعتمد عليه في التصنيف. If the customer asks in Arabic, the answer may still need to retrieve this mixed document because the product name, API code, or SLA label appears in English. لا يجوز تعميم هذه القاعدة على منتجات أخرى، ولا تنطبق عند وجود إعفاء مكتوب في العقد. Effective date: 30 May 2026. |
يوضح هذا المستند المختلط Mixed Policy رقم 7 قواعد ضمان الأجهزة والأثاث الخاصة بـ مكتب HamsAI SmartDesk / HamsAI SmartDesk. The operational threshold for technician visit is 55 requests per month (٥٥ طلب)، and the fee for exceeding it is SAR 1070. يجب استخدام المصطلح التقني replacement كما هو في تذاكر الدعم لأن فرق التشغيل في الرياض وجدة والدمام تعتمد عليه في التصنيف. If the customer asks in Arabic, the answer may still need to retrieve this mixed document because the product name, API code, or SLA label appears in English. لا يجوز تعميم هذه القاعدة على منتجات أخرى، ولا تنطبق عند وجود إعفاء مكتوب في العقد. Effective date: 30 May 2026. |
TripletLoss with these parameters:{
"distance_metric": "TripletDistanceMetric.EUCLIDEAN",
"triplet_margin": 5
}
learning_rate: 2e-05weight_decay: 0.01warmup_steps: 0.1fp16: Trueload_best_model_at_end: Truedo_predict: Falseprediction_loss_only: Trueper_device_train_batch_size: 8per_device_eval_batch_size: 8gradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 2e-05weight_decay: 0.01adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 3max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_ratio: Nonewarmup_steps: 0.1log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Trueenable_jit_checkpoint: Falsesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseuse_cpu: Falseseed: 42data_seed: Nonebf16: Falsefp16: Truebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: -1ddp_backend: Nonedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonedisable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Trueignore_data_skip: Falsefsdp: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Nonegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Truepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsehub_revision: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_for_metrics: []eval_do_concat_batches: Trueauto_find_batch_size: Falsefull_determinism: Falseddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_num_input_tokens_seen: noneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Trueuse_cache: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | Validation Loss |
|---|---|---|---|
| 0.2273 | 20 | 4.9095 | - |
| 0.4545 | 40 | 4.4791 | - |
| 0.6818 | 60 | 4.3311 | - |
| 0.9091 | 80 | 4.3261 | - |
| 1.0 | 88 | - | 4.0396 |
| 1.1364 | 100 | 4.2389 | - |
| 1.3636 | 120 | 4.2062 | - |
| 1.5909 | 140 | 4.2809 | - |
| 1.8182 | 160 | 4.2606 | - |
| 2.0 | 176 | - | 4.0310 |
| 2.0455 | 180 | 4.2687 | - |
| 2.2727 | 200 | 4.2284 | - |
| 2.5 | 220 | 4.1868 | - |
| 2.7273 | 240 | 4.2012 | - |
| 2.9545 | 260 | 4.2047 | - |
| 3.0 | 264 | - | 4.0241 |
@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/1908.10084",
}
@misc{hermans2017defense,
title={In Defense of the Triplet Loss for Person Re-Identification},
author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
year={2017},
eprint={1703.07737},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
Base model
BAAI/bge-m3