Downloads · 30 days
8
8% of all-time downloads
81melody/algerian-law-reranker-v1
algerian-law-reranker-v1 is a text ranking model from 81melody. Use it for the text ranking task on the model card, and read the license before you ship it in a product. It is set up for sentence-transformers. The card lists the license as apache-2.0.
A sentence-transformers CrossEncoder reranker for Algerian family-law retrieval — pairwise relevance scorer for (user question, law article) pairs, used as the second stage of a legal retrieval pipeline.
Downloads · 30 days
8
8% of all-time downloads
All-time downloads
95
Public
Parameters
163M
651 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors651 MB · 100%
From the Hugging Face model README
A sentence-transformers CrossEncoder reranker for Algerian family-law retrieval — pairwise relevance scorer for (user question, law article) pairs, used as the second stage of a legal retrieval pipeline.
Fine-tuned from UBC-NLP/MARBERTv2 with BinaryCrossEntropyLoss on 9,123 (query, article, label) pairs derived from real Algerian Facebook legal-advice groups. Queries are in Darja, Arabizi, and MSA; documents are Algerian Family Code articles with structured chapter prefixes. Achieves accuracy 0.909 and F1 0.915 on the held-out dev set. Designed to rerank the candidate pool produced by algerian-law-biencoder-v2.
| Architecture | MARBERTv2 CrossEncoder (BertForSequenceClassification) |
| Task | Pairwise relevance scoring — (query, article) → score |
| Languages | Darja · Arabizi · MSA · French · Code-switched |
| Domain | Algerian family law (Droit de la famille, Law 84-11) |
| Training data | 9,123 pairs (1,014-sample eval set) |
| Accuracy | 0.909 |
| F1 | 0.915 |
| Average Precision | 0.897 |
| License | Apache 2.0 |
CrossEncoder(
(0): Transformer({'transformer_task': 'sequence-classification', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'logits'}}, 'module_output_name': 'scores', 'architecture': 'BertForSequenceClassification'})
)
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import CrossEncoder
# Download from the 🤗 Hub
model = CrossEncoder("cross_encoder_model_id")
# Get scores for pairs of inputs
pairs = [
['سلام عليكم عندي سؤال المحكمة حكمتلي نلقى بنتي 8000 و بدل الإيجار 15000 و انا شهريتي قليلة يقدرو ينقصولي شوي', '[الموضوع: ولاية] [الباب: الكتاب الثاني: النيابة الشرعية] يجب عرض الوصاية على القاضي بمجرد وفاة الأب لتثبيتها أو رفضها.'],
['السلام عليكم عندي سؤال اذا ممكن تجاوبوني عليه عندى الاب تاعي توفي ربي يرحمو ومكانش خدام عند دولة وعندو سكن اجتماعي ضك سكن هذا يتحول للام ولا يعتبر ميراث للعلم مكانش وريث طفل غير بنات وشنهي هوما الاجراءات باش يتخول للام واذا ممكن تفهموني فالفريضة وشنهي هوما لورق لي نخرج وكيفاش نديرها وشكرا مسبقا', '[الموضوع: نفقة] [الباب: الباب الثاني: انحلال الزواج] تشمل النفقة : الغذاء والكسوة والعلاج، والسكن أو أجرته، وما يعتبر من الضروريات في العرف والعادة.'],
['في قضايا الأسرة ضرب الزوجة و قامت بشهادة 18 يوم عجز ..شكات بيه عند الوكيل و دارها قضية استعجالية باش يسمعوها الدرك في نفس اليوم المحظر كتبو فيه بلي ضرب و جرح عمدي مع إستعمال سلاح ابيض + ضرب على الرأس يعني محاولة قتل ..الظابط هو لي قال مدام ضربة على الرأس محاولة قتل ..مع العلم الملف تاعها فيه ضرب من قبل و سمحتلو فيه شهادة داروها من قبل و شكات و سمحتلو مما يعني العود ..من فضلكم واش راح يكون الحكم تقديرييا ..و واشي هي المراحل القادمة و قداه من جلسة', '[الموضوع: ولاية] [الباب: الكتاب الثاني: النيابة الشرعية] من بلغ سن الرشد وهو مجنون، أو معتوه، أو سفيه، أو طرأت عليه إحدى الحالات المذآورة بعد رشده يحجر عليه.'],
['السلام عليكم .زوجي رفع طلاق تعسفي ولم يحظر في جلسات الصلح والمحامية اخبرتني بانه سيحكم بالطلاق لان لديه محامي ويرد علي العرايض وان عدم حضوره يعتبر تعسف فقط', '[الموضوع: طلاق] [الباب: الباب الثاني: انحلال الزواج] إذا اشتد الخصام بين الزوجين ولم يثبت الضرر وجب تعيين حكمين للتوفيق بينهما. يعين القاضي الحكمين، حكما من أهل الزوج وحكما من أهل الزوجة، وعلى هذين الحكمين أن يقدما تقريرا عن مهمتهما في أجل شهرين.'],
['السلام عليكم سمعت الحكم في خمسة افريل غدوة قلت نخرجه أسكو نروح للمحكمة لي في ولايتي نخرج الحكم ولا الولاية لي شرعت فيها بعيدة عليا', '[الموضوع: ميراث] [الباب: الوقف)] الهبة في مرض الموت، والأمراض والحالات المخيفة، تعتبر وصية.'],
]
scores = model.predict(pairs)
print(scores)
# [0.0041 0.004 0.0038 0.004 0.004 ]
# Or rank different texts based on similarity to a single text
ranks = model.rank(
'سلام عليكم عندي سؤال المحكمة حكمتلي نلقى بنتي 8000 و بدل الإيجار 15000 و انا شهريتي قليلة يقدرو ينقصولي شوي',
[
'[الموضوع: ولاية] [الباب: الكتاب الثاني: النيابة الشرعية] يجب عرض الوصاية على القاضي بمجرد وفاة الأب لتثبيتها أو رفضها.',
'[الموضوع: نفقة] [الباب: الباب الثاني: انحلال الزواج] تشمل النفقة : الغذاء والكسوة والعلاج، والسكن أو أجرته، وما يعتبر من الضروريات في العرف والعادة.',
'[الموضوع: ولاية] [الباب: الكتاب الثاني: النيابة الشرعية] من بلغ سن الرشد وهو مجنون، أو معتوه، أو سفيه، أو طرأت عليه إحدى الحالات المذآورة بعد رشده يحجر عليه.',
'[الموضوع: طلاق] [الباب: الباب الثاني: انحلال الزواج] إذا اشتد الخصام بين الزوجين ولم يثبت الضرر وجب تعيين حكمين للتوفيق بينهما. يعين القاضي الحكمين، حكما من أهل الزوج وحكما من أهل الزوجة، وعلى هذين الحكمين أن يقدما تقريرا عن مهمتهما في أجل شهرين.',
'[الموضوع: ميراث] [الباب: الوقف)] الهبة في مرض الموت، والأمراض والحالات المخيفة، تعتبر وصية.',
]
)
# [{'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.*
-->
dev| Metric | Value |
|---|---|
| accuracy | 0.9091 |
| accuracy_threshold | 0.0242 |
| f1 | 0.9149 |
| f1_threshold | 0.0077 |
| precision | 0.86 |
| recall | 0.9773 |
| average_precision | 0.8968 |
| sentence_0 | sentence_1 | label | |
|---|---|---|---|
| type | string | string | float |
| details | <ul><li>min: 12 tokens</li><li>mean: 56.24 tokens</li><li>max: 450 tokens</li></ul> | <ul><li>min: 22 tokens</li><li>mean: 65.61 tokens</li><li>max: 222 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.08</li><li>max: 1.0</li></ul> |
| sentence_0 | sentence_1 | label |
|---|---|---|
| <code>سلام عليكم عندي سؤال المحكمة حكمتلي نلقى بنتي 8000 و بدل الإيجار 15000 و انا شهريتي قليلة يقدرو ينقصولي شوي</code> | <code>[الموضوع: ولاية] [الباب: الكتاب الثاني: النيابة الشرعية] يجب عرض الوصاية على القاضي بمجرد وفاة الأب لتثبيتها أو رفضها.</code> | <code>0.0</code> |
| <code>السلام عليكم عندي سؤال اذا ممكن تجاوبوني عليه عندى الاب تاعي توفي ربي يرحمو ومكانش خدام عند دولة وعندو سكن اجتماعي ضك سكن هذا يتحول للام ولا يعتبر ميراث للعلم مكانش وريث طفل غير بنات وشنهي هوما الاجراءات باش يتخول للام واذا ممكن تفهموني فالفريضة وشنهي هوما لورق لي نخرج وكيفاش نديرها وشكرا مسبقا</code> | <code>[الموضوع: نفقة] [الباب: الباب الثاني: انحلال الزواج] تشمل النفقة : الغذاء والكسوة والعلاج، والسكن أو أجرته، وما يعتبر من الضروريات في العرف والعادة.</code> | <code>0.0</code> |
| <code>في قضايا الأسرة ضرب الزوجة و قامت بشهادة 18 يوم عجز ..شكات بيه عند الوكيل و دارها قضية استعجالية باش يسمعوها الدرك في نفس اليوم المحظر كتبو فيه بلي ضرب و جرح عمدي مع إستعمال سلاح ابيض + ضرب على الرأس يعني محاولة قتل ..الظابط هو لي قال مدام ضربة على الرأس محاولة قتل ..مع العلم الملف تاعها فيه ضرب من قبل و سمحتلو فيه شهادة داروها من قبل و شكات و سمحتلو مما يعني العود ..من فضلكم واش راح يكون الحكم تقديرييا ..و واشي هي المراحل القادمة و قداه من جلسة</code> | <code>[الموضوع: ولاية] [الباب: الكتاب الثاني: النيابة الشرعية] من بلغ سن الرشد وهو مجنون، أو معتوه، أو سفيه، أو طرأت عليه إحدى الحالات المذآورة بعد رشده يحجر عليه.</code> | <code>0.0</code> |
{
"activation_fn": "torch.nn.modules.linear.Identity",
"pos_weight": null
}
per_device_train_batch_size: 16per_device_eval_batch_size: 16do_predict: Falseprediction_loss_only: Trueper_device_train_batch_size: 16per_device_eval_batch_size: 16gradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 5e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1num_train_epochs: 3max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_ratio: Nonewarmup_steps: 0log_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: Falsebf16_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: Falseignore_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 | dev_average_precision |
|---|---|---|---|
| 0.7496 | 428 | - | 0.8416 |
| 0.8757 | 500 | 0.2713 | - |
| 1.0 | 571 | - | 0.8492 |
| 1.4991 | 856 | - | 0.8439 |
| 1.7513 | 1000 | 0.1966 | - |
| 2.0 | 1142 | - | 0.9303 |
| 2.2487 | 1284 | - | 0.8840 |
| 2.6270 | 1500 | 0.1868 | - |
| 2.9982 | 1712 | - | 0.8968 |
@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.*
-->