CoolFace
Modelpublic

leafxyz/arabic-ecom-cross-encoder-v4

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes11downloads
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 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: Unknown --> <!-- - 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-v4")
# Get scores for pairs of inputs
pairs = [
    ['اطعمة معلبة', 'درب شتورة حمص طحينة بالفلفل الحار - 400 غ'],
    ['عطر بيبي روج', 'زيت للأطفال \u200f- Babirose'],
    ['قرص فنش', 'سياقة كونتيسا - 40 سم'],
    ['فمّا قرفة مطحونة', 'زنجبيل مطحون الخليج - 70 غ'],
    ['كيرود', 'كيرود علبة هندسية لون ازرق - 8 قطع'],
]
scores = model.predict(pairs)
print(scores)
# [ 0.6948 -4.2344 -3.0059 -5.4609 -0.0091]

# Or rank different texts based on similarity to a single text
ranks = model.rank(
    'اطعمة معلبة',
    [
        'درب شتورة حمص طحينة بالفلفل الحار - 400 غ',
        'زيت للأطفال \u200f- Babirose',
        'سياقة كونتيسا - 40 سم',
        'زنجبيل مطحون الخليج - 70 غ',
        'كيرود علبة هندسية لون ازرق - 8 قطع',
    ]
)
# [{'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

Unnamed Dataset
  • —Size: 334,256 training samples
  • —Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>label</code>
  • —Approximate statistics based on the first 100 samples: | | sentence1 | sentence2 | label | |:---------|:---------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------| | type | string | string | float | | modality | text | text | | | details | <ul><li>min: 3 tokens</li><li>mean: 7.34 tokens</li><li>max: 13 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 12.17 tokens</li><li>max: 21 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.68</li><li>max: 1.0</li></ul> |
  • —Samples: | sentence1 | sentence2 | label | |:---------------------------|:------------------------------------------------------|:-----------------| | <code>أواني طبخ</code> | <code>شنقال ستيل لفاف</code> | <code>0.0</code> | | <code>ساعات نسائية</code> | <code>خاتم شي ان - DB032</code> | <code>0.0</code> | | <code>لوشن البابايا</code> | <code>لوشن البابايا لتبييض اليدين والجسم - RDL</code> | <code>1.0</code> |
  • —Loss: <code>BinaryCrossEntropyLoss</code> with these parameters:
json
  {
      "activation_fn": "torch.nn.modules.linear.Identity",
      "pos_weight": null
  }

Evaluation Dataset

Unnamed Dataset
  • —Size: 6,822 evaluation samples
  • —Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>label</code>
  • —Approximate statistics based on the first 100 samples: | | sentence1 | sentence2 | label | |:---------|:--------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------| | type | string | string | float | | modality | text | text | | | details | <ul><li>min: 4 tokens</li><li>mean: 8.0 tokens</li><li>max: 14 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 12.86 tokens</li><li>max: 29 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.59</li><li>max: 1.0</li></ul> |
  • —Samples: | sentence1 | sentence2 | label | |:--------------------------|:-------------------------------------------------------|:-----------------| | <code>اطعمة معلبة</code> | <code>درب شتورة حمص طحينة بالفلفل الحار - 400 غ</code> | <code>1.0</code> | | <code>عطر بيبي روج</code> | <code>زيت للأطفال ‏- Babirose</code> | <code>0.0</code> | | <code>قرص فنش</code> | <code>سياقة كونتيسا - 40 سم</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
  • —num_train_epochs: 2
  • —learning_rate: 2e-05
  • —warmup_steps: 0.1
  • —fp16: True
  • —per_device_eval_batch_size: 32
All Hyperparameters

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

  • —per_device_train_batch_size: 32
  • —num_train_epochs: 2
  • —max_steps: -1
  • —learning_rate: 2e-05
  • —lr_scheduler_type: linear
  • —lr_scheduler_kwargs: None
  • —warmup_steps: 0.1
  • —optim: adamwtorchfused
  • —optim_args: None
  • —weight_decay: 0.0
  • —adam_beta1: 0.9
  • —adam_beta2: 0.999
  • —adam_epsilon: 1e-08
  • —optim_target_modules: None
  • —gradient_accumulation_steps: 1
  • —average_tokens_across_devices: True
  • —max_grad_norm: 1.0
  • —label_smoothing_factor: 0.0
  • —bf16: False
  • —fp16: True
  • —bf16_full_eval: False
  • —fp16_full_eval: False
  • —tf32: None
  • —gradient_checkpointing: False
  • —gradient_checkpointing_kwargs: None
  • —torch_compile: False
  • —torch_compile_backend: None
  • —torch_compile_mode: None
  • —use_liger_kernel: False
  • —liger_kernel_config: None
  • —use_cache: False
  • —neftune_noise_alpha: None
  • —torch_empty_cache_steps: None
  • —auto_find_batch_size: False
  • —log_on_each_node: True
  • —logging_nan_inf_filter: True
  • —include_num_input_tokens_seen: no
  • —log_level: passive
  • —log_level_replica: warning
  • —disable_tqdm: False
  • —project: huggingface
  • —trackio_space_id: None
  • —trackio_bucket_id: None
  • —trackio_static_space_id: None
  • —per_device_eval_batch_size: 32
  • —prediction_loss_only: True
  • —eval_on_start: False
  • —eval_do_concat_batches: True
  • —eval_use_gather_object: False
  • —eval_accumulation_steps: None
  • —include_for_metrics: []
  • —batch_eval_metrics: False
  • —save_only_model: False
  • —save_on_each_node: False
  • —enable_jit_checkpoint: False
  • —push_to_hub: False
  • —hub_private_repo: None
  • —hub_model_id: None
  • —hub_strategy: every_save
  • —hub_always_push: False
  • —hub_revision: None
  • —load_best_model_at_end: False
  • —ignore_data_skip: False
  • —restore_callback_states_from_checkpoint: False
  • —full_determinism: False
  • —seed: 42
  • —data_seed: None
  • —use_cpu: False
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • —parallelism_config: None
  • —dataloader_drop_last: False
  • —dataloader_num_workers: 0
  • —dataloader_pin_memory: True
  • —dataloader_persistent_workers: False
  • —dataloader_prefetch_factor: None
  • —remove_unused_columns: True
  • —label_names: None
  • —train_sampling_strategy: random
  • —length_column_name: length
  • —ddp_find_unused_parameters: None
  • —ddp_bucket_cap_mb: None
  • —ddp_broadcast_buffers: False
  • —ddp_static_graph: None
  • —ddp_backend: None
  • —ddp_timeout: 1800
  • —fsdp: None
  • —fsdp_config: None
  • —deepspeed: None
  • —debug: []
  • —skip_memory_metrics: True
  • —do_predict: False
  • —resume_from_checkpoint: None
  • —warmup_ratio: None
  • —local_rank: -1
  • —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.00961001.1056-
0.01912000.7532-
0.02873000.5562-
0.03834000.5104-
0.04795000.50140.4591
0.05746000.4661-
0.06707000.4614-
0.07668000.4586-
0.08629000.4455-
0.095710000.43970.4195
0.105311000.4370-
0.114912000.4237-
0.124413000.4051-
0.134014000.4173-
0.143615000.41000.3880
0.153216000.4113-
0.162717000.4137-
0.172318000.4103-
0.181919000.4167-
0.191520000.43280.3777
0.201021000.4072-
0.210622000.3826-
0.220223000.3917-
0.229824000.3978-
0.239325000.38680.3674
0.248926000.3779-
0.258527000.3852-
0.268028000.3606-
0.277629000.3736-
0.287230000.37620.3627
0.296831000.3692-
0.306332000.3753-
0.315933000.3725-
0.325534000.3934-
0.335135000.38170.3552
0.344636000.3568-
0.354237000.3808-
0.363838000.3763-
0.373339000.3458-
0.382940000.35360.3619
0.392541000.3800-
0.402142000.3521-
0.411643000.3568-
0.421244000.3533-
0.430845000.35820.3429
0.440446000.3586-
0.449947000.3471-
0.459548000.3600-
0.469149000.3482-
0.478750000.35540.3330
0.488251000.3541-
0.497852000.3472-
0.507453000.3580-
0.516954000.3601-
0.526555000.35940.3341
0.536156000.3542-
0.545757000.3409-
0.555258000.3464-
0.564859000.3501-
0.574460000.34030.3263
0.584061000.3497-
0.593562000.3458-
0.603163000.3415-
0.612764000.3442-
0.622265000.33010.3318
0.631866000.3388-
0.641467000.3389-
0.651068000.3382-
0.660569000.3356-
0.670170000.34710.3166
0.679771000.3468-
0.689372000.3370-
0.698873000.3554-
0.708474000.3381-
0.718075000.32580.3166
0.727676000.3244-
0.737177000.3218-
0.746778000.3097-
0.756379000.3304-
0.765880000.32250.3088
0.775481000.3331-
0.785082000.3336-
0.794683000.3270-
0.804184000.3221-
0.813785000.32040.3058
0.823386000.3263-
0.832987000.3294-
0.842488000.3071-
0.852089000.3206-
0.861690000.33160.3056
0.871191000.3247-
0.880792000.3268-
0.890393000.3248-
0.899994000.3104-
0.909495000.32470.3058
0.919096000.3022-
0.928697000.3212-
0.938298000.3299-
0.947799000.2949-
0.9573100000.33260.3072
0.9669101000.3204-
0.9765102000.3134-
0.9860103000.3285-
0.9956104000.3210-
1.0052105000.30030.3092
1.0147106000.3074-
1.0243107000.3215-
1.0339108000.2885-
1.0435109000.3026-
1.0530110000.30390.3018
1.0626111000.3062-
1.0722112000.3135-
1.0818113000.2951-
1.0913114000.3010-
1.1009115000.32160.3035
1.1105116000.2951-
1.1200117000.2906-
1.1296118000.2871-
1.1392119000.3026-
1.1488120000.29250.3031
1.1583121000.2942-
1.1679122000.3143-
1.1775123000.2847-
1.1871124000.3014-
1.1966125000.30340.2938
1.2062126000.2999-
1.2158127000.2999-
1.2253128000.3005-
1.2349129000.2814-
1.2445130000.29850.2937
1.2541131000.2902-
1.2636132000.2854-
1.2732133000.2981-
1.2828134000.3013-
1.2924135000.29160.2944
1.3019136000.2913-
1.3115137000.2827-
1.3211138000.2929-
1.3307139000.2970-
1.3402140000.30060.2945
1.3498141000.2926-
1.3594142000.2973-
1.3689143000.3117-
1.3785144000.2893-
1.3881145000.30940.2870
1.3977146000.2750-
1.4072147000.2939-
1.4168148000.3100-
1.4264149000.2953-
1.4360150000.26800.2962
1.4455151000.2977-
1.4551152000.2831-
1.4647153000.3071-
1.4742154000.2907-
1.4838155000.30530.2918
1.4934156000.2787-
1.5030157000.2826-
1.5125158000.3129-
1.5221159000.2966-
1.5317160000.29030.2904
1.5413161000.2952-
1.5508162000.2903-
1.5604163000.2817-
1.5700164000.2660-
1.5796165000.28080.2916
1.5891166000.2886-
1.5987167000.3088-
1.6083168000.3114-
1.6178169000.2828-
1.6274170000.29240.2904
1.6370171000.2903-
1.6466172000.2818-
1.6561173000.2726-
1.6657174000.2804-
1.6753175000.29990.2824
1.6849176000.2765-
1.6944177000.2908-
1.7040178000.2959-
1.7136179000.2776-
1.7231180000.30670.2854
1.7327181000.2707-
1.7423182000.2841-
1.7519183000.2832-
1.7614184000.3070-
1.7710185000.29760.2817
1.7806186000.2844-
1.7902187000.2952-
1.7997188000.2806-
1.8093189000.2801-
1.8189190000.26790.2827
1.8285191000.2926-
1.8380192000.3035-
1.8476193000.2689-
1.8572194000.2837-
1.8667195000.29020.2825
1.8763196000.2723-
1.8859197000.2683-
1.8955198000.2814-
1.9050199000.2814-
1.9146200000.28690.2828
1.9242201000.2822-
1.9338202000.2896-
1.9433203000.2876-
1.9529204000.2960-
1.9625205000.29890.2819
1.9720206000.2739-
1.9816207000.2920-
1.9912208000.2700-
2.020892-0.2821

</details>

Training Time

  • —Training: 27.5 minutes

Framework Versions

  • —Python: 3.12.13
  • —Sentence Transformers: 5.6.0
  • —Transformers: 5.13.1
  • —PyTorch: 2.11.0+cu128
  • —Accelerate: 1.14.0
  • —Datasets: 4.0.0
  • —Tokenizers: 0.22.2

Additional Resources

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. -->