--- language: - ar - fr license: apache-2.0 task_categories: - text-retrieval - text-ranking tags: - algerian-arabic - darja - arabizi - code-switching - legal - algerian-family-law - information-retrieval - question-answering - low-resource-nlp size_categories: - 1K<10K configs: - config_name: biencoder data_files: - split: train path: biencoder_train.jsonl - config_name: reranker data_files: - split: train path: reranker_train.jsonl - config_name: golden data_files: - split: dev path: golden_dev.csv - split: test path: golden_test.csv --- # algerian-family-law-qa **A retrieval and reranking dataset for Algerian family-law question answering — real user questions scraped from Algerian Facebook legal-advice groups, paired with relevant articles from the Algerian Family Code (Law No. 84-11).** Questions are written in Algerian Darja (dialect), Arabizi (Arabic in Latin script), Modern Standard Arabic, and French code-switched text. Documents are articles from the Algerian Family Code covering divorce, custody, alimony, and related topics. This dataset was used to train the two-stage legal retrieval system: [`81melody/algerian-law-biencoder-v2`](https://huggingface.co/81melody/algerian-law-biencoder-v2) (dense retriever) and [`81melody/algerian-law-reranker-v1`](https://huggingface.co/81melody/algerian-law-reranker-v1) (cross-encoder reranker). --- ## Dataset Contents | File | Split | Examples | Format | Use | |---|---|---:|---|---| | `biencoder_train.jsonl` | Train | 389 | JSONL | Bi-encoder / dense retriever training | | `reranker_train.jsonl` | Train | 9,123 | JSONL | Cross-encoder reranker training | | `golden_dev.csv` | Dev | 67 | CSV | Human-annotated evaluation (retrieval) | | `golden_test.csv` | Test | 150 | CSV | Human-annotated test set (retrieval) | The golden dev and test sets were manually reviewed — each query has a primary article (gold label), optional secondary article, and a hard negative, with a labeler-confidence score. --- ## File Schemas ### `biencoder_train.jsonl` Each line is a JSON object with hard negatives, used for training a bi-encoder with `MultipleNegativesRankingLoss`: ```json { "query_id": "B24_6", "query": "17سنة زواج خيانات متكررة كي نواجهو يضربي...", "positive": "المادة 53", "hard_negatives": ["المادة 52", "المادة 112", "المادة 51"], "in_batch_eligible": true } ``` ### `reranker_train.jsonl` Each line is a (query, article) pair with a relevance label and confidence weight, used for training a CrossEncoder: ```json { "query": "17سنة زواج...", "article_id": "المادة 53", "article_structured": "[الموضوع: طلاق] [الباب: الباب الثاني: انحلال الزواج] يجوز للزوجة أن تطلب التطليق...", "article_text": "يجوز للزوجة أن تطلب التطليق...", "label": 1, "weight": 1.0 } ``` `label` is binary (1 = relevant, 0 = not relevant). `weight` in `[0, 1]` reflects annotator confidence (primary match = 1.0, secondary = 0.7, etc.). `article_structured` prefixes the article with its chapter and topic context. ### `golden_dev.csv` / `golden_test.csv` Columns: `query_id, query_text, article_primary, article_secondary, hard_negative, labeler_confidence, is_oos, parse_warnings, stratum` `is_oos=True` marks out-of-scope queries (the legal question cannot be answered by the Family Code corpus). `stratum` labels the legal topic (طلاق / OOS / etc.). --- ## Quick Start ```python from datasets import load_dataset import json # Load reranker training pairs with open("reranker_train.jsonl") as f: reranker_data = [json.loads(line) for line in f] # Load biencoder triplets with open("biencoder_train.jsonl") as f: biencoder_data = [json.loads(line) for line in f] # Load golden dev set import csv with open("golden_dev.csv", newline='', encoding='utf-8-sig') as f: dev = list(csv.DictReader(f)) # Filter to in-scope only in_scope = [row for row in dev if row['is_oos'] == 'False'] ``` --- ## Statistics | Metric | Value | |---|---| | Unique queries in reranker set | ~1,014 | | Positive pairs in reranker set | ~1,014 | | Negative pairs in reranker set | ~8,109 | | Unique queries in biencoder set | 389 | | Family Code articles covered | ~100 (Law 84-11 articles 1–124+) | | Golden dev queries (in-scope) | 48 | | Golden test queries (in-scope) | ~100 | | Languages | Darja, Arabizi, MSA, French | --- ## Source Questions were scraped from public Algerian Facebook groups dedicated to family-law advice. All questions are already publicly posted by users seeking legal guidance. No personally identifiable information (names, phone numbers) appears in the query text as collected — questions are framed around legal situations, not personal contact details. --- ## Associated Models | Model | HF Repo | Task | |---|---|---| | Dense bi-encoder | [81melody/algerian-law-biencoder-v2](https://huggingface.co/81melody/algerian-law-biencoder-v2) | First-stage retrieval | | CrossEncoder reranker | [81melody/algerian-law-reranker-v1](https://huggingface.co/81melody/algerian-law-reranker-v1) | Second-stage reranking | | Domain-adapted base | [81melody/algerian-law-marbert](https://huggingface.co/81melody/algerian-law-marbert) | Shared encoder backbone | --- ## Citation ```bibtex @dataset{himeur2026algerian_family_law_qa, title = {algerian-family-law-qa: Retrieval and Reranking Dataset for Algerian Family-Law Question Answering}, author = {Himeur, Ayoub}, year = {2026}, publisher = {Hugging Face}, url = {https://huggingface.co/datasets/81melody/algerian-family-law-qa}, note = {User questions from Algerian Facebook legal-advice groups paired with Algerian Family Code articles (Law 84-11)} } ``` --- ## License [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)