license: apache-2.0 base_model: microsoft/Phi-3-mini-4k-instruct tags: - law - pakistan - lora - gguf - ollama - legal-assistant language: - en

πŸ‡΅πŸ‡° Pakistan Legal Adapter (Phi-3 Mini LoRA)

Developed by: Muzammil Khan
Base Model: Microsoft Phi-3 Mini 4k Instruct

This is a parameter-efficient LoRA adapter fine-tuned on Pakistani Legal Statutes, including the Pakistan Penal Code (PPC), PECA ACT,Constitution of Pakistan and others.

It is designed to be lightweight enough to run on consumer hardware (e.g., 8GB RAM laptops) via Ollama, while providing domain-specific knowledge that the base Phi-3 model lacks.

⚠️ Important Usage Instructions

** This model is part of our local AI legal document analyzer you can use the whole project by cloning the repo: https://github.com/Muzammilkhan785/legal-document-analyzer

This is not a general-purpose chatbot. Because this model was trained on raw legal texts, it behaves best as a Legal Document Completer or a Strict Assistant.

To prevent the model from generating preambles (e.g., "WHEREAS it is expedient...") or page numbers, you MUST use the custom Modelfile configuration below.

πŸš€ Quick Start with Ollama

  1. Download the adapter_model.gguf file from this repository.
  2. Create a file named Modelfile in the same folder and paste the configuration below.

The Required Modelfile

# 1. Base Model (Ensure you have pulled phi3:mini)
FROM phi3

# 2. Your Adapter Path
ADAPTER ./adapter_model.gguf

# 3. System Prompt (Directs the model to be factual)
SYSTEM "You are a specialized legal assistant for Pakistani law. Complete the user's request directly and concisely. Do not generate headers, page numbers, or preambles."

# 4. Strict Stop Tokens (Prevents hallucinations/looping)
PARAMETER stop "Page No"
PARAMETER stop "ACT NO"
PARAMETER stop "WHEREAS"
PARAMETER stop "[1"
PARAMETER stop "[Page"
PARAMETER stop "User:"
PARAMETER stop "<|end|>"

# 5. Inference Parameters (Reduces repetition)
PARAMETER temperature 0.1
PARAMETER repeat_penalty 1.2
PARAMETER num_predict 256

# 6. Chat Template
TEMPLATE """{{ if .System }}<|system|>
{{ .System }}<|end|>
{{ end }}{{ if .Prompt }}<|user|>
{{ .Prompt }}<|end|>
{{ end }}<|assistant|>
{{ .Response }}<|end|>"""
Downloads last month
4
GGUF
Model size
8.91M params
Architecture
phi3
Hardware compatibility
Log In to add your hardware

We're not able to determine the quantization variants.

Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for KHAN8816/PakistaniLawPhi-3

Quantized
(176)
this model

Dataset used to train KHAN8816/PakistaniLawPhi-3