Downloads · 30 days
91
17% of all-time downloads
81melody/algerian-law-biencoder-v2
algerian-law-biencoder-v2 is a sentence similarity model from 81melody. Use it when you need a score for how close two texts are. It is set up for sentence-transformers. The card lists the license as apache-2.0.
A sentence-transformers dense bi-encoder for Algerian family-law retrieval — maps a user's question (in Darja, Arabizi, or MSA) to a 768-dimensional embedding that retrieves the most relevant article from the Algerian…
Downloads · 30 days
91
17% of all-time downloads
All-time downloads
542
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 dense bi-encoder for Algerian family-law retrieval — maps a user's question (in Darja, Arabizi, or MSA) to a 768-dimensional embedding that retrieves the most relevant article from the Algerian Family Code.
Fine-tuned from 81melody/algerian-law-marbert — a MARBERTv2 model already domain-adapted on Algerian legal text — with MultipleNegativesRankingLoss on 389 (query, article) pairs. Queries are real questions posted by Algerian users in Facebook legal-advice groups (Darja / Arabizi / code-switched); documents are structured Algerian Family Code articles prefixed with their chapter context. Designed as the first stage of a two-stage retrieval pipeline followed by algerian-law-reranker-v1.
| Architecture | MARBERTv2 (768 dim, mean pooling) |
| Task | Asymmetric semantic search — query → law article |
| Languages | Darja · Arabizi · MSA · French · Code-switched |
| Domain | Algerian family law (Droit de la famille, Law 84-11) |
| Training data | 389 (q, p) pairs from Algerian Facebook legal-advice groups |
| NDCG@10 | 0.736 on held-out golden dev set (88-query eval set) |
| MRR@10 | 0.778 |
| License | Apache 2.0 |
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'BertModel'})
(1): Pooling({'embedding_dimension': 768, 'pooling_mode': 'mean', 'include_prompt': True})
)
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("sentence_transformers_model_id")
# Run inference
sentences = [
'q: سلام عليكم حبيت نسقسي في حالة ما حضرش الزوج في الجلسة الاولي من الطلاق بالتراضي او غير رايو..كيفاه يكون الوضع.. والاسيلة لي يطرحوهم في اول جلسة ؟؟',
'p: الكتاب الاول: الزواج وانحلاله — الباب الثاني: انحلال الزواج — الفصل الاول: الطلاق\nالمادة 49\nلا يثبت الطلاق الا بحكم بعد عدة محاولات صلح يجريها القاضي دون ان تتجاوز مدته ثلاثة يتعين علي القاضي تحرير محضر يبين مساعي ونتايج محاولات الصلح، يوقعه مع ااتب الضبط والطرفين. تسجل احكام الطلاق وجوبا في الحالة المدنية بسعي من النيابة العامة.',
'p: الكتاب الاول: الزواج وانحلاله — الباب الثاني: انحلال الزواج — الفصل الثالث: النفقة\nالمادة 75\nتجب نفقة الولد علي الاب ما لم يكن له مال، فبالنسبة للذاور الي سن الرشد والاناث الي الدخول وتستمر في حالة ما اذا كان الولد عاجزا لافة عقلية او بدنية او مزاولا للدراسة وتسقط بالاستغناء عنها بالكسب.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.6976, 0.1856],
# [0.6976, 1.0000, 0.2471],
# [0.1856, 0.2471, 1.0000]])
<!--
### 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 |
|---|---|
| cosine_accuracy@1 | 0.7045 |
| cosine_accuracy@3 | 0.8182 |
| cosine_accuracy@5 | 0.8864 |
| cosine_accuracy@10 | 0.9318 |
| cosine_precision@1 | 0.7045 |
| cosine_precision@3 | 0.4394 |
| cosine_precision@5 | 0.3 |
| cosine_precision@10 | 0.1659 |
| cosine_recall@1 | 0.3523 |
| cosine_recall@3 | 0.6591 |
| cosine_recall@5 | 0.75 |
| cosine_recall@10 | 0.8295 |
| cosine_ndcg@10 | 0.7362 |
| cosine_mrr@10 | 0.7779 |
| cosine_map@100 | 0.6708 |
| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| details | <ul><li>min: 11 tokens</li><li>mean: 58.6 tokens</li><li>max: 256 tokens</li></ul> | <ul><li>min: 24 tokens</li><li>mean: 103.03 tokens</li><li>max: 230 tokens</li></ul> |
| sentence_0 | sentence_1 |
|---|---|
| <code>q: سلام عليكم فالخلع شحال من جلسة صلح كاين و مدة بين الجلسة و الجلسة وشكرا</code> | <code>p: الكتاب الاول: الزواج وانحلاله — الباب الثاني: انحلال الزواج — الفصل الاول: الطلاق<br>المادة 49<br>لا يثبت الطلاق الا بحكم بعد عدة محاولات صلح يجريها القاضي دون ان تتجاوز مدته ثلاثة يتعين علي القاضي تحرير محضر يبين مساعي ونتايج محاولات الصلح، يوقعه مع ااتب الضبط والطرفين. تسجل احكام الطلاق وجوبا في الحالة المدنية بسعي من النيابة العامة.</code> |
| <code>q: السلام عليكم رفعت قضية خلع حكمولي ب 15 مليون ونا عاملة متربصة وعندي دخل في جديد فقط كيفاش ندير حابة نخلص بشوي كيفاش ندير اسكو كي منخلصش يحكم علي راتب كيفاش نتقاس انا وياه. لي فاهم يفهمني. شكرا</code> | <code>p: الكتاب الاول: الزواج وانحلاله — الباب الثاني: انحلال الزواج — الفصل الاول: الطلاق<br>المادة 54<br>يجوز للزوجة دون موافقة الزوج ان تخالع نفسها بمقابل مالي. اذا لم يتفق الزوجان علي المقابل المالي للخلع، يحكم القاضي بما لا يتجاوز قيمة صداق المثل وقت صدور الحكم.</code> |
| <code>q: السلام عليكم جميعا بنسبة للمطلقة في حالة طليق رفض تسديد مبالغ طلاق تعسفي ماذا تفعل. المطلقة افيدوني شكرا</code> | <code>p: الكتاب الاول: الزواج وانحلاله — الباب الثاني: انحلال الزواج — الفصل الاول: الطلاق<br>المادة 52<br>اذا تبين للقاضي تعسف الزوج في الطلاق حكم للمطلقة بالتعويض عن الضرر اللاحق بها. الطلاق حل عقد الزواج، ويتم بارادة الزوج او بتراضي الزوجين او بطلب من الزوجة في حدود ما ورد في المادتين 53 و54 من هذا القانون. لا يثبت الطلاق الا بحكم بعد محاولة الصلح من طرف القاضي دون ان تتجاوز هذه المدة ثلاثة اشهر. اذا تبين للقاضي تعسف الزوج في الطلاق حكم للمطلقة بالتعويض عن الضرر اللاحق بها. واذا كانت حاضنة ولم يكن لها ولي يقبل ايواءها، يضمن حقها في السكن مع محضونيها حسب وسع الزوج. ويستثني من القرار بالسكن، مسكن الزوجية اذا كان وحيدا. تفقد المطلقة حقها في السكن في حالة زواجها او ثبوت انحرافها.</code> |
{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false,
"directions": [
"query_to_doc"
],
"partition_mode": "joint",
"hardness_mode": null,
"hardness_strength": 0.0
}
per_device_train_batch_size: 32per_device_eval_batch_size: 32multi_dataset_batch_sampler: round_robindo_predict: Falseprediction_loss_only: Trueper_device_train_batch_size: 32per_device_eval_batch_size: 32gradient_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: round_robinrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | dev_cosine_ndcg@10 |
|---|---|---|
| 1.0 | 13 | 0.7188 |
| 2.0 | 26 | 0.7226 |
| 3.0 | 39 | 0.7362 |
@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{oord2019representationlearningcontrastivepredictive,
title={Representation Learning with Contrastive Predictive Coding},
author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
year={2019},
eprint={1807.03748},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/1807.03748},
}
<!--
## 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.*
-->