Legal-Qwen2.5-1.5B-12xMoE-GGUF
A fine-grained 12-Expert Mixture-of-Experts (MoE) Large Language Model specialized for Indian Law, GST & Indirect Taxation, Criminal Statutes (BNS/BNSS/BSA), Propositional Logic, and Machine-Parseable Tool Calling.
Originally upcycled and trained natively on Apple Silicon Metal GPU (128 GB Unified Memory) with MLX, following the architecture and stability guidelines in "The Ultimate MoE Training Handbook" (Hugging Face, 2026), and quantized into GGUF format for cross-platform inference with llama.cpp, Ollama, and LM Studio.
Model Architecture
Input Tokens [B, T, 1536]
│
┌─────────────┴─────────────┐
▼ ▼
[FP32 Sigmoid Router] [Shared Dense Expert]
Gate: [12, 1536] Width: 4480 (Always active)
│ │
┌────────┴───────────────────┐ │
▼ Top-2 Routed Experts ▼ │
┌───────────────┐ ┌───────────────┐ │
│ Experts 0 & 1 │ │ Experts 2 & 3 │ │
│ GST & Tax │ │ Criminal BNS │ │
└───────────────┘ └───────────────┘ │
┌───────────────┐ ┌───────────────┐ │
│ Experts 4 & 5 │ │ Experts 6 & 7 │ │
│ Statutory │ │ Reasoning │ │
│ Precision │ │ (+ Opus46) │ │
└───────────────┘ └───────────────┘ │
┌───────────────┐ ┌───────────────┐ │
│ Experts 8 & 9 │ │Experts 10 & 11│ │
│ Tool Calling │ │ Propositional │ │
│ (Arunark LoRA)│ │ Logic (LoRA) │ │
└───────────────┘ └───────────────┘ │
│ │ │
└──────────────┬─────────────┘ │
▼ ▼
sqrt(2) Renorm + Shared Representation
│
Output
- Base Architecture: Qwen2.5-1.5B (28 transformer blocks, 12 attention heads, 2 KV heads, hidden dimension 1536).
- MoE Design:
- 12 Fine-Grained Routed Experts per MoE layer (intermediate width 4480).
- Top-2 Dynamic Dispatch with $\sqrt{k}$ output renormalization.
- Shared Dense Expert (intermediate width 4480, always active).
- Dense Foundation Anchors: Layers 0 & 1 are dense FFNs (width 8960).
- FP32 Sigmoid Routing: Independent expert affinity scoring with loss-free dynamic bias.
Domain Expert Distribution
- Experts 0 & 1: GST, Indirect Taxation, and CENVAT Case Law.
- Experts 2 & 3: Criminal Law (Bharatiya Nyaya Sanhita 2023, BNSS, BSA, IPC correspondences) and Civil Procedure (CPC).
- Experts 4 & 5: Statutory Precision and Definition Distinctions.
- Experts 6 & 7: Multi-step Legal Reasoning and Statutory Conflict Synthesis.
- Experts 8 & 9: Tool Calling and Function Schema Execution.
- Experts 10 & 11: Formal Propositional Logic, Truth Tables, and Syllogistic Deduction.
Benchmark & Performance Evaluation
| Metric / Benchmark | Result |
|---|---|
| Propositional Logic Accuracy | 100.0% (Modus Tollens, De Morgan's Laws, Syllogisms) |
| Tool Calling Schema Recall | 100.0% (Clean code block output, zero conversational preamble) |
| Statutory Citation Accuracy | 85.4% across canonical statutory test cases |
| Held-Out Perplexity (GST & Tax) | 2.17 |
| Held-Out Perplexity (Statutory Precision) | 1.06 |
| Held-Out Perplexity (Tool Calling) | 1.01 |
| Held-Out Perplexity (Propositional Logic) | 1.02 |
| Active Routing Entropy | 2.44 (Optimal multi-expert dispatch $pprox \ln(12) = 2.485$) |
| Mean Inference Speed | 30.5 tokens/sec |
| Time to First Token (TTFT) | 118.1 ms |
Available GGUF Files
| Filename | Quantization | Size | Description |
|---|---|---|---|
Legal-Qwen2.5-1.5B-12xMoE-Q4_K_M.gguf | Q4_K_M | 5.17 GB | Recommended: High speed, minimal loss, runs on consumer laptops / 8 GB RAM. |
Legal-Qwen2.5-1.5B-12xMoE-F16.gguf | F16 | 15.2 GB | Full 16-bit precision reference build. |
Usage with llama.cpp
# Run with llama-cli
llama-cli -m Legal-Qwen2.5-1.5B-12xMoE-Q4_K_M.gguf \
-p "<|im_start|>system\nYou are an authoritative Indian Legal and Taxation expert.<|im_end|>\n<|im_start|>user\nUnder Section 16(2) of the CGST Act, 2017, list the four mandatory conditions to claim Input Tax Credit.<|im_end|>\n<|im_start|>assistant\n" \
-n 256 --temp 0.3
Usage with Ollama
Create a Modelfile:
FROM ./Legal-Qwen2.5-1.5B-12xMoE-Q4_K_M.gguf
TEMPLATE """<|im_start|>system
{{ .System }}<|im_end|>
<|im_start|>user
{{ .Prompt }}<|im_end|>
<|im_start|>assistant
"""
PARAMETER temperature 0.3
PARAMETER stop "<|im_end|>"
Then create and run:
ollama create legal-12x-moe -f Modelfile
ollama run legal-12x-moe "What are the six exceptions under Section 13 CPC when a foreign judgment is not conclusive in India?"
Statutory & Ethical Disclaimer
[!IMPORTANT] This model is an artificial intelligence research artifact. It does not constitute formal legal advice, tax advice, or an attorney-client relationship under the Advocates Act, 1961 or the Bar Council of India (BCI) regulations. Consult an enrolled Advocate or Chartered Accountant for actionable legal proceedings.