Downloads · 30 days
71
18% of all-time downloads
81melody/algerian-law-marbert
algerian-law-marbert 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 MARBERTv2 encoder domain-adapted on Algerian family-law text (Darja + MSA + Facebook legal Q&A), producing 768-dimensional embeddings for Algerian legal information retrieval.
Downloads · 30 days
71
18% of all-time downloads
All-time downloads
405
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 MARBERTv2 encoder domain-adapted on Algerian family-law text (Darja + MSA + Facebook legal Q&A), producing 768-dimensional embeddings for Algerian legal information retrieval.
Fine-tuned from UBC-NLP/MARBERTv2 with CachedMultipleNegativesRankingLoss on 1,000 (question → article) triplet pairs sourced from real Algerian Facebook legal-advice groups, aligned to the Algerian Family Code (Law No. 84-11). Queries are written in Darja (Algerian dialect) and Arabizi; documents are law articles in Modern Standard Arabic. This model is the shared backbone for the two-stage legal retrieval system:
81melody/algerian-law-biencoder-v281melody/algerian-law-reranker-v1| Architecture | MARBERTv2 (BERT-base, 768 dim, 12 layers) |
| Task | Semantic similarity / dense retrieval |
| Languages | Darja · Arabizi · MSA · Code-switched |
| Domain | Algerian family law (Droit de la famille algérien) |
| Training data | 1,000 triplets from Facebook legal-advice groups |
| Best eval metric | cosine_accuracy = 0.741 (TripletEvaluator, 112-sample eval set) |
| 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 = [
'عندي اب تاعي ما عايش معانا ما يصرف عليها هرب وخلانا ويجي مشهر لشهر يسبنا ويسب الام تاعي ويروح مرضها رجعها تشرب دوا وتروح لطبيب تع اعصاب ومحبش يطلقها يقلها نخليها هكاك معلقة تتعذبي وزيد دورو ميمدهولناش انا وختي نقراو انا نخدم نصرف على روحي وختي وماما يصرف غليهم خويا مسكيت صغير عليا عمرو 20 سنة غير يبريكولي ولي يجيبها يحطهالنا حبيت نطلقها باش تتهنا منوا باسكو كرهلنا حياتنا هكا ميزيد يجي لينا ما يزيد يسبنا انا عندي سوتنونس عاذ لعام كرهلي حياتي مخااني نقرى ما هناني يضلي يعيطلي ويسب فيا ويرخس فيا نديرو روجوتي يزيد يعيطلي بنوامر وحدوخرين اعطوني حل كيفاه نرفد عليه طلاق لضرر',
'المادة 53',
'المادة 54',
]
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.2787, 0.1867],
# [0.2787, 1.0000, 0.4629],
# [0.1867, 0.4629, 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.*
-->
marbert_algerian_law_eval| Metric | Value |
|---|---|
| cosine_accuracy | 0.7411 |
| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| details | <ul><li>min: 9 tokens</li><li>mean: 57.4 tokens</li><li>max: 512 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 4.81 tokens</li><li>max: 8 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 4.0 tokens</li><li>max: 5 tokens</li></ul> |
| anchor | positive | negative |
|---|---|---|
| <code>سلام عليكم حبا ندير باش يزيدوني في بدل الاجار كفاش ندير انا 600 مراهش تكفي لاكراء ولكراء راه غالي</code> | <code>المادة 79</code> | <code>المادة 80</code> |
| <code>سؤالي لأهل الاختصاص فقط...عندي عامين طلاق وطليقي لحد الآن ماعطانيش التعويض نتاع الطلاق وحق العدة....كيفاش نطالب بيهم...أعطوني جواب قانوني من فضلكم؟؟؟؟</code> | <code>المادة 61</code> | <code>المادة 79</code> |
| <code>عند زواج الأم هل القاضي يستدعي الاطفال لتخييرهم عند من يريدون البقاء عند امهم او ابيهم بإعتبار سن التميز 12 سنة وهل التنازل عن الحضانة للجدة ام الأم أثناء زواج الأم يمنع الأب من اخذ الحضانة</code> | <code>المادة 79</code> | <code>المادة 80</code> |
{
"scale": 20.0,
"similarity_fct": "cos_sim",
"mini_batch_size": 32,
"gather_across_devices": false,
"directions": [
"query_to_doc"
],
"partition_mode": "joint",
"hardness_mode": null,
"hardness_strength": 0.0
}
| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| details | <ul><li>min: 13 tokens</li><li>mean: 67.54 tokens</li><li>max: 418 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 4.9 tokens</li><li>max: 8 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 4.01 tokens</li><li>max: 5 tokens</li></ul> |
| anchor | positive | negative |
|---|---|---|
| <code>سلام في طلاق تعسفي نقدر نقلو منطلقش لازم تديرلي داري وحدي نقدر نحكلو على مشاكل و بلي مش نحوس نتطلق</code> | <code>المادة 49</code> | <code>المادة 52</code> |
| <code>سلام وعليكم خاوتي بغيتكم ترشدوني نا قدمت طلب رجوع لبيت الزوجية للزوج وهو مبغاش رفع عليا زود خطرات قضية طلاق وميحضرش الجلسات ونا رحت شكيت بيه بشكوى الاهمال العائلي 10 ماي جلسة لاولى واليوم بلغني بلي رفع قضية طلاق جديده وضرك نقدر نشارعو بلاشي مندير محامي ونجيب حقي</code> | <code>المادة 48</code> | <code>المادة 55</code> |
| <code>فهموني فطلاق بالنشوز من فضلكم واسكو لمرا تسقط عليها الحضانة في هاذ لحالة ولا لا</code> | <code>المادة 67</code> | <code>المادة 66</code> |
{
"scale": 20.0,
"similarity_fct": "cos_sim",
"mini_batch_size": 32,
"gather_across_devices": false,
"directions": [
"query_to_doc"
],
"partition_mode": "joint",
"hardness_mode": null,
"hardness_strength": 0.0
}
per_device_train_batch_size: 16per_device_eval_batch_size: 16learning_rate: 2e-05num_train_epochs: 15warmup_steps: 0.1fp16: Truedo_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: 2e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 15max_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: 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: {}@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{gao2021scaling,
title={Scaling Deep Contrastive Learning Batch Size under Memory Limited Setup},
author={Luyu Gao and Yunyi Zhang and Jiawei Han and Jamie Callan},
year={2021},
eprint={2101.06983},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
<!--
## 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.*
-->