A native Apple MLX recurrent-depth ("looped") language model specifically fine-tuned and aligned for Indian Statutory Law, Procedure, and Judicial Reasoning with explicit Chain-of-Draft <think>...</think> scratchpad tokens.
LoopedTransformerLM)Unlike standard linear feedforward transformers, this model stores 8 physical transformer layers and loops the recurrent hidden state through them 3 times per forward pass.
[Token x] ──> Embedding ──> [Loop 1: 8 Layers] ──> Reinject Adapter ──> [Loop 2: 8 Layers] ──> Reinject Adapter ──> [Loop 3: 8 Layers] ──> lm_head
│ │ │
Shared Weights (W) Shared Weights (W) Shared Weights (W)
<think>1. ... 2. ... 3. ... 4. ...</think> scratchpads.Evaluated on the 16-point Indian Legal & Procedural Benchmark Suite (scripts/eval_legal_thinking.py):
| Test ID | Legal Domain | Subject & Statute Tested | Statute Match | Thinking Trace () | Status |
|---|---|---|---|---|---|
CONST_01 |
Constitutional Law | Basic Structure (Kesavananda Bharati, Art 368) | 100% | Opened & Closed | PASSED |
CONST_02 |
Constitutional Law | Article 21 (Maneka Gandhi, Life & Liberty) | 100% | Opened & Closed | PASSED |
CONST_03 |
Constitutional Law | Minerva Mills (1980) (Balance FRs & DPSPs) | 75% | Opened & Closed | PASSED |
CONST_04 |
Constitutional Law | Lok Sabha Minimum Age (Article 84(b) - 25 yrs) | 100% | Opened & Closed | PASSED |
CRIM_01 |
Criminal Jurisprudence | Maxim Actus non facit reum nisi mens sit rea | 100% | Opened & Closed | PASSED |
CRIM_02 |
Criminal Law (BNS 2023) | Petty Offenses Punishment: Community Service (Sec 4(f)) | 100% | Opened & Closed | PASSED |
CRIM_03 |
Criminal Law (BNS 2023) | Infancy Immunity: Child under 7 years (Sec 20 doli incapax) | 100% | Opened & Closed | PASSED |
CPC_01 |
Civil Procedure Code | Decree (Sec 2(2) substantive) vs. Order (Sec 2(14)) | 80% | Opened & Closed | PASSED |
CPC_02 |
Civil Procedure Code | Conclusiveness of Foreign Judgments (Sec 13 CPC, Satya) | 100% | Opened & Closed | PASSED |
CPC_03 |
Civil Procedure Code | Pleadings Rules under Order VI Rule 2 (Facts not law) | 50% | Opened & Closed | PASSED |
TAX_01 |
Income Tax Act, 1961 | Tax Residence (Section 6(1) - 182d / 60+365d tests) | 100% | Opened & Closed | PASSED |
TAX_02 |
Income Tax Act, 1961 | Five Heads of Income (Section 14) | 100% | Opened & Closed | PASSED |
TAX_03 |
Income Tax Act, 1961 | Professional TDS Rate & Threshold (Section 194J - 10% > ₹30k) | 100% | Opened & Closed | PASSED |
GST_01 |
Central GST Act, 2017 | Time of Supply of Goods (Section 12 forward/reverse charge) | 75% | Opened & Closed | PASSED |
COMM_01 |
Negotiable Instruments | Cheque Bouncing Criminal Penalty (Section 138 - 2 yrs / double) | 67% | Opened & Closed | PASSED |
PERS_01 |
Personal Law (Muslim) | Testamentary Succession Wasiyat (Rule of One-Third / 1/3rd) | 100% | Opened & Closed | PASSED |
<think> Trace Opened Rate: 16 / 16 (100.0%)</think> Trace Closed Rate: 16 / 16 (100.0%)pip install mlx tokenizers huggingface_hub
# Clone the repository
git clone https://huggingface.co/Suvir-Misra/Looped-Transformer-485M-Indian-Law-Thinking
cd Looped-Transformer-485M-Indian-Law-Thinking
# Run a query
python generate.py "Under Section 6(1) of the Income-tax Act, 1961, when does an individual qualify as a resident?"
import mlx.core as mx
from generate import load_model, generate
# Load model and custom BPE tokenizer
model, tok, cfg = load_model(".")
prompt = "What does the fundamental criminal law maxim 'Actus non facit reum nisi mens sit rea' mean?"
response = generate(model, tok, cfg, prompt, max_new=220, temp=0.2)
print(response)
Example Output:
<think>
1. Translate Latin maxim: an act does not make one guilty without a blameworthy mind.
2. Identify first essential element: Actus Reus (wrongful physical act/omission).
3. Identify second essential element: Mens Rea (culpable mental state/guilty mind).
4. State fundamental principle of criminal liability.
</think>
The fundamental legal maxim **'Actus non facit reum nisi mens sit rea'** translates to: **'An act does not make one guilty unless the mind is also blameworthy'**.
It establishes the cardinal principle of criminal jurisprudence that criminal liability requires two concurrent elements:
1. **Actus Reus**: The commission of a prohibited physical wrongful act or omission.
2. **Mens Rea**: A culpable, blameworthy mental state (intent, knowledge, or criminal recklessness).[EOS]
@misc{misra2026loopedtransformer,
author = {Suvir Misra},
title = {Looped Transformer SLM: Recurrent-Depth Indian Legal Reasoning with Chain-of-Draft Thinking},
year = {2026},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/Suvir-Misra/Looped-Transformer-485M-Indian-Law-Thinking}}
}