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
- Download the
adapter_model.gguffile from this repository. - Create a file named
Modelfilein 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
We're not able to determine the quantization variants.
Model tree for KHAN8816/PakistaniLawPhi-3
Base model
microsoft/Phi-3-mini-4k-instruct