CoolFace
Modelpublic

leafxyz/arabic-ecom-cross-encoder-v3

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes14downloads
Model Card

CrossEncoder based on cross-encoder/mmarco-mMiniLMv2-L12-H384-v1

This is a Cross Encoder model finetuned from cross-encoder/mmarco-mMiniLMv2-L12-H384-v1 on the arabic-ecom-data dataset using the sentence-transformers library. It computes scores for pairs of texts, which can be used for text reranking and semantic search.

Model Details

Model Description

  • —Model Type: Cross Encoder
  • —Base model: cross-encoder/mmarco-mMiniLMv2-L12-H384-v1 <!-- at revision 1427fd652930e4ba29e8149678df786c240d8825 -->
  • —Maximum Sequence Length: 128 tokens
  • —Number of Output Labels: 1 label
  • —Supported Modality: Text
  • —Training Dataset:
  • —arabic-ecom-data <!-- - Language: Unknown --> <!-- - License: Unknown -->

Model Sources

Full Model Architecture

CrossEncoder(
  (0): Transformer({'transformer_task': 'sequence-classification', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'logits'}}, 'module_output_name': 'scores', 'architecture': 'XLMRobertaForSequenceClassification'})
)

Usage

Direct Usage (Sentence Transformers)

First install the Sentence Transformers library:

bash
pip install -U sentence-transformers

Then you can load this model and run inference.

python
from sentence_transformers import CrossEncoder

# Download from the 🤗 Hub
model = CrossEncoder("leafxyz/arabic-ecom-cross-encoder-v3")
# Get scores for pairs of inputs
pairs = [
    ['مناديل مطبخ', 'صابون اواني جودي - 960 مل (الليمون الاخضر)'],
    ['جبنة هابي كاو', 'هابي كاو جبنة كريمى - 150 غ'],
    ['كريم تايغر للشعر', 'كريم ازالة شعر - Page Vine'],
    ['لانشون حلواني', 'لانشون حلواني دجاج - 250 غ'],
    ['صابون جودي 2.32', 'صابون اواني جودي برائحة الليمون الاخضر - 2.32 ل'],
]
scores = model.predict(pairs)
print(scores)
# [-5.0312  0.2981 -1.2588  0.6904  0.7002]

# Or rank different texts based on similarity to a single text
ranks = model.rank(
    'مناديل مطبخ',
    [
        'صابون اواني جودي - 960 مل (الليمون الاخضر)',
        'هابي كاو جبنة كريمى - 150 غ',
        'كريم ازالة شعر - Page Vine',
        'لانشون حلواني دجاج - 250 غ',
        'صابون اواني جودي برائحة الليمون الاخضر - 2.32 ل',
    ]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]

<!--

Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details> -->

<!--

Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details> -->

<!--

Out-of-Scope Use

List how the model may foreseeably be misused and address what users ought not to do with the model. -->

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Dataset

arabic-ecom-data
  • —Dataset: arabic-ecom-data
  • —Size: 246,013 training samples
  • —Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>label</code>
  • —Approximate statistics based on the first 1000 samples: | | sentence1 | sentence2 | label | |:--------|:---------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------| | type | string | string | float | | details | <ul><li>min: 3 tokens</li><li>mean: 7.77 tokens</li><li>max: 20 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 13.06 tokens</li><li>max: 27 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.49</li><li>max: 1.0</li></ul> |
  • —Samples: | sentence1 | sentence2 | label | |:-----------------------------------|:---------------------------------------------|:-----------------| | <code>فلوتس أصبع</code> | <code>كيت كات شوكلاتة 4 اصابع 36.5 جم</code> | <code>0.0</code> | | <code>بخور عود ند شيخ العرب</code> | <code>بخور العود- اصل العود</code> | <code>0.0</code> | | <code>احمر شفاه Rhode</code> | <code>احمر شفاه - Water Lip Matte</code> | <code>0.0</code> |
  • —Loss: <code>BinaryCrossEntropyLoss</code> with these parameters:
json
  {
      "activation_fn": "torch.nn.modules.linear.Identity",
      "pos_weight": null
  }

Evaluation Dataset

arabic-ecom-data
  • —Dataset: arabic-ecom-data
  • —Size: 5,021 evaluation samples
  • —Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>label</code>
  • —Approximate statistics based on the first 1000 samples: | | sentence1 | sentence2 | label | |:--------|:---------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------| | type | string | string | float | | details | <ul><li>min: 3 tokens</li><li>mean: 7.86 tokens</li><li>max: 16 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 13.19 tokens</li><li>max: 33 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.48</li><li>max: 1.0</li></ul> |
  • —Samples: | sentence1 | sentence2 | label | |:------------------------------|:--------------------------------------------------------|:-----------------| | <code>مناديل مطبخ</code> | <code>صابون اواني جودي - 960 مل (الليمون الاخضر)</code> | <code>0.0</code> | | <code>جبنة هابي كاو</code> | <code>هابي كاو جبنة كريمى - 150 غ</code> | <code>1.0</code> | | <code>كريم تايغر للشعر</code> | <code>كريم ازالة شعر - Page Vine</code> | <code>0.0</code> |
  • —Loss: <code>BinaryCrossEntropyLoss</code> with these parameters:
json
  {
      "activation_fn": "torch.nn.modules.linear.Identity",
      "pos_weight": null
  }

Training Hyperparameters

Non-Default Hyperparameters
  • —per_device_train_batch_size: 32
  • —per_device_eval_batch_size: 32
  • —learning_rate: 2e-05
  • —num_train_epochs: 2
  • —warmup_steps: 0.1
  • —fp16: True
All Hyperparameters

<details><summary>Click to expand</summary>

  • —do_predict: False
  • —prediction_loss_only: True
  • —per_device_train_batch_size: 32
  • —per_device_eval_batch_size: 32
  • —gradient_accumulation_steps: 1
  • —eval_accumulation_steps: None
  • —torch_empty_cache_steps: None
  • —learning_rate: 2e-05
  • —weight_decay: 0.0
  • —adam_beta1: 0.9
  • —adam_beta2: 0.999
  • —adam_epsilon: 1e-08
  • —max_grad_norm: 1.0
  • —num_train_epochs: 2
  • —max_steps: -1
  • —lr_scheduler_type: linear
  • —lr_scheduler_kwargs: None
  • —warmup_ratio: None
  • —warmup_steps: 0.1
  • —log_level: passive
  • —log_level_replica: warning
  • —log_on_each_node: True
  • —logging_nan_inf_filter: True
  • —enable_jit_checkpoint: False
  • —save_on_each_node: False
  • —save_only_model: False
  • —restore_callback_states_from_checkpoint: False
  • —use_cpu: False
  • —seed: 42
  • —data_seed: None
  • —bf16: False
  • —fp16: True
  • —bf16_full_eval: False
  • —fp16_full_eval: False
  • —tf32: None
  • —local_rank: -1
  • —ddp_backend: None
  • —debug: []
  • —dataloader_drop_last: False
  • —dataloader_num_workers: 0
  • —dataloader_prefetch_factor: None
  • —disable_tqdm: False
  • —remove_unused_columns: True
  • —label_names: None
  • —load_best_model_at_end: False
  • —ignore_data_skip: False
  • —fsdp: []
  • —fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • —parallelism_config: None
  • —deepspeed: None
  • —label_smoothing_factor: 0.0
  • —optim: adamwtorchfused
  • —optim_args: None
  • —group_by_length: False
  • —length_column_name: length
  • —project: huggingface
  • —trackio_space_id: trackio
  • —ddp_find_unused_parameters: None
  • —ddp_bucket_cap_mb: None
  • —ddp_broadcast_buffers: False
  • —dataloader_pin_memory: True
  • —dataloader_persistent_workers: False
  • —skip_memory_metrics: True
  • —push_to_hub: False
  • —resume_from_checkpoint: None
  • —hub_model_id: None
  • —hub_strategy: every_save
  • —hub_private_repo: None
  • —hub_always_push: False
  • —hub_revision: None
  • —gradient_checkpointing: False
  • —gradient_checkpointing_kwargs: None
  • —include_for_metrics: []
  • —eval_do_concat_batches: True
  • —auto_find_batch_size: False
  • —full_determinism: False
  • —ddp_timeout: 1800
  • —torch_compile: False
  • —torch_compile_backend: None
  • —torch_compile_mode: None
  • —include_num_input_tokens_seen: no
  • —neftune_noise_alpha: None
  • —optim_target_modules: None
  • —batch_eval_metrics: False
  • —eval_on_start: False
  • —use_liger_kernel: False
  • —liger_kernel_config: None
  • —eval_use_gather_object: False
  • —average_tokens_across_devices: True
  • —use_cache: False
  • —prompts: None
  • —batch_sampler: batch_sampler
  • —multi_dataset_batch_sampler: proportional
  • —router_mapping: {}
  • —learning_rate_mapping: {}

</details>

Training Logs

<details><summary>Click to expand</summary>

EpochStepTraining LossValidation Loss
0.01301000.8919-
0.02602000.6599-
0.03903000.5613-
0.05204000.5168-
0.06505000.52780.4916
0.07806000.5182-
0.09117000.4833-
0.10418000.4863-
0.11719000.5011-
0.130110000.47400.4477
0.143111000.4480-
0.156112000.4536-
0.169113000.4604-
0.182114000.4704-
0.195115000.45140.4282
0.208116000.4358-
0.221117000.4472-
0.234118000.4382-
0.247119000.4524-
0.260120000.43680.4112
0.273221000.4272-
0.286222000.4280-
0.299223000.4276-
0.312224000.4067-
0.325225000.42600.4026
0.338226000.4321-
0.351227000.4333-
0.364228000.4246-
0.377229000.4304-
0.390230000.42370.3938
0.403231000.4181-
0.416232000.4224-
0.429233000.4096-
0.442234000.4069-
0.455335000.40450.3963
0.468336000.4164-
0.481337000.3996-
0.494338000.4053-
0.507339000.3853-
0.520340000.40350.3818
0.533341000.4043-
0.546342000.3914-
0.559343000.4022-
0.572344000.3949-
0.585345000.40940.3821
0.598346000.3782-
0.611347000.3908-
0.624348000.3944-
0.637449000.4112-
0.650450000.40770.3676
0.663451000.4034-
0.676452000.3958-
0.689453000.3988-
0.702454000.3835-
0.715455000.40650.3680
0.728456000.3910-
0.741457000.3959-
0.754458000.4005-
0.767459000.3967-
0.780460000.39470.3734
0.793461000.3916-
0.806562000.4023-
0.819563000.3869-
0.832564000.3821-
0.845565000.38450.3716
0.858566000.3637-
0.871567000.3828-
0.884568000.3703-
0.897569000.3962-
0.910570000.38800.3592
0.923571000.3846-
0.936572000.3722-
0.949573000.3946-
0.962574000.3779-
0.975575000.39570.3550
0.988676000.3763-
1.001677000.3732-
1.014678000.3763-
1.027679000.3713-
1.040680000.35940.3597
1.053681000.3510-
1.066682000.3738-
1.079683000.3554-
1.092684000.3524-
1.105685000.35070.3577
1.118686000.3483-
1.131687000.3692-
1.144688000.3676-
1.157689000.3484-
1.170790000.38590.3502
1.183791000.3590-
1.196792000.3746-
1.209793000.3559-
1.222794000.3631-
1.235795000.35000.3685
1.248796000.3496-
1.261797000.3803-
1.274798000.3442-
1.287799000.3503-
1.3007100000.36360.3504
1.3137101000.3479-
1.3267102000.3768-
1.3398103000.3501-
1.3528104000.3563-
1.3658105000.35510.3515
1.3788106000.3645-
1.3918107000.3466-
1.4048108000.3622-
1.4178109000.3535-
1.4308110000.37080.3452
1.4438111000.3484-
1.4568112000.3593-
1.4698113000.3554-
1.4828114000.3362-
1.4958115000.37070.3458
1.5088116000.3559-
1.5219117000.3501-
1.5349118000.3771-
1.5479119000.3586-
1.5609120000.34620.3478
1.5739121000.3448-
1.5869122000.3516-
1.5999123000.3582-
1.6129124000.3621-
1.6259125000.37240.3436
1.6389126000.3598-
1.6519127000.3616-
1.6649128000.3537-
1.6779129000.3462-
1.6909130000.36750.3443
1.7040131000.3506-
1.7170132000.3389-
1.7300133000.3454-
1.7430134000.3588-
1.7560135000.35210.3427
1.7690136000.3462-
1.7820137000.3513-
1.7950138000.3484-
1.8080139000.3522-
1.8210140000.34260.3447
1.8340141000.3497-
1.8470142000.3464-
1.8600143000.3427-
1.8730144000.3422-
1.8861145000.33980.3447
1.8991146000.3487-
1.9121147000.3608-
1.9251148000.3515-
1.9381149000.3456-
1.9511150000.34990.3445
1.9641151000.3404-
1.9771152000.3482-
1.9901153000.3464-

</details>

Training Time

  • —Training: 21.4 minutes

Framework Versions

  • —Python: 3.12.13
  • —Sentence Transformers: 5.4.1
  • —Transformers: 5.0.0
  • —PyTorch: 2.10.0+cu128
  • —Accelerate: 1.13.0
  • —Datasets: 5.0.0
  • —Tokenizers: 0.22.2

Citation

BibTeX

Sentence Transformers
bibtex
@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",
}

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->