sosa123454321/persian-legal-kb
Persian Legal Knowledge Base — پایگاه دانش حقوقی فارسی A provenance-first Persian legal corpus built for retrieval-augmented and knowledge-graph (KAG) systems, not for fine-tuning knowledge into weights. Every record answers four questions a legal AI must never get wrong: is this law or just a bill? · is it still in force? · which article? · who said so? Why this dataset exists Iranian law moved in the two weeks before this dataset was built: قانون ملی توسعه هوش… See the full description on the dataset page: https://huggingface.co/datasets/sosa123454321/persian-legal-kb.
Persian Legal Knowledge Base — پایگاه دانش حقوقی فارسی
A provenance-first Persian legal corpus built for retrieval-augmented and knowledge-graph (KAG) systems, not for fine-tuning knowledge into weights.
Every record answers four questions a legal AI must never get wrong: is this law or just a bill? · is it still in force? · which article? · who said so?
Why this dataset exists
Iranian law moved in the two weeks before this dataset was built:
قانون ملی توسعه هوش مصنوعیwas enacted 1405-05-28 (~2 weeks beforeverified_at).لایحهٔ حفاظت از دادههای شخصیwas approved by cabinet in 1403-04 but returned to the legal commission in 1403-07 — it is not law. Most secondary sources still describe it as if it were.- The EU AI Act's high-risk deadlines were deferred by the Digital Omnibus (political agreement 2026-05-07). Any article published before May 2026 gives stale dates.
- Iran's base immigration statute is still from 1310 (1931) — 95 years old — with reform bills pending but unenacted.
A model fine-tuned on this material would confidently state all four of those wrong within months. A retrieval system with a validity gate will not.
Contents
15,691 characters of primary/secondary text across 25 distinct sources.
Domain coverage
6 of 10 planned domains are seeded. The remaining 4 (financial/banking, criminal procedure, labour, comparative international) are not yet collected.
Schema — records.jsonl
Reliability distribution: 5×12, 4×5, 3×17, 2×3, 1×0.
Schema — mcq.jsonl
26 questions: immigration 8, aigovernance 6, startupip 5, education 5, data_protection 2.
The knowledge graph (kag.json)
Nodes: Law(8) Article(31) Bill(4) Amendment(2) Authority(8) Jurisdiction(2) Domain(6) RiskTier(8) Concept(11)
Edges: has_article amends supersedes proposes_amendment_to pending_before enacted_by governed_by in_domain maps_to defines cites applies_to in_risk_tier
This is what makes multi-hop legal questions answerable. Example — «what happened to ماده ۱۵?»
art:1310-15 ←proposes_amendment_to— bill:reform-art15-16 [🟥 bill_not_enacted]
↑has_article
law:ir-entry-residence-1310 ←amends— amd:1336-band-d-art13 [✅ in_force]and the residency ladder art:bmo-24 →cites→ art:bmo-23 →cites→ art:bmo-22 (10-year requires 7-year requires 3-year).
Cross-jurisdiction mappings are deliberately marked `mapping_confidence: low`. Iran's four risk tiers (کممخاطره / مخاطره محدود / پرمخاطره / بسیار پرمخاطره) turn on religious and ethical values plus social manipulation; the EU's four tiers turn on fundamental rights plus the Annex III use-case list. They are not 1:1 and no consumer of this dataset should treat them as such.
How to use this correctly
import json
recs = [json.loads(l) for l in open("records.jsonl", encoding="utf-8")]
for r in recs:
if r["legal_status"] == "bill_not_enacted":
# MUST be labelled as a proposal, never as law
...
if r["reliability"] <= 2:
# blog/SEO source — corroborate before quoting
...Do not train a model to memorise text. Do index it and return it with legal_status + source_url attached.
Evaluation
mcq.jsonl doubles as a retrieval-and-grounding test set: a system passes a question only if it retrieves the record named in cites and propagates that record's legal_status into its answer. Reporting accuracy without checking legal_status propagation hides the single most dangerous failure mode in legal AI.
Known limitations — read before use
- 6 of 10 domains only. Financial, criminal procedure, labour and comparative international law are uncollected.
- No books, no videos. The original scope called for ~10 articles + ~10 books + ~10 videos per domain. This is the article/statute layer only.
- Iranian source domains are unreachable from the build sandbox.
adadai.ir,dadbazar.com,tehranatba.ir,chesafari.com,mashhad-lawyer.com,cartesabz.netand the officialekhtebar.irPDF all returned HTTP 000 during link verification. Text for those was extracted from search-engine cache and is marked with acaveat. Re-verify from a normal network before publishing. - `adadai.ir/landing/ai-book` was a banner ad, not an organic result. Excluded as untrustworthy.
- Statute text is abridged. Passages are the operative sentences, not full articles. Never present these as complete legal text.
- Jalali dates are given as ISO where the conversion is unambiguous;
1310-02-19style entries for very old statutes should be treated as approximate. - Volume is tiny (15.7 KB of text). This is a schema and pipeline proof, sized so that the validity-gating logic can be verified end to end. It is not yet a training corpus.
Regenerating
python3 build_dataset.py # → data/records.jsonl, data/mcq.jsonl, data/stats.json
python3 blueprints/a_retrieval_only.py --selftest
python3 blueprints/b_hybrid_rag.py --selftest
python3 blueprints/c_kag_graph.py --buildAll stdlib, no dependencies. Runs on 2 CPU cores / 1 GB RAM.
Licensing
Mixed, per record. public_domain_gov (Iranian statute text and government publications) and cc-by-4.0 (arXiv, CASRAI) records are freely reusable. all_rights_reserved records are short quoted excerpts from legal news outlets included for research and criticism; contact the publisher before redistributing commercially. Filter on the license field.
Disclaimer
این مجموعه داده اطلاعات حقوقی است، نه مشاورهٔ حقوقی. This dataset is legal information, not legal advice.
