Downloads · 30 days
13
9% of all-time downloads
Sivanuja/Legal_vision_llama-3.1-8B-instruct-v1
Legal_vision_llama-3.1-8B-instruct-v1 is a text generation model from Sivanuja. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as llama3.1.
Fine-tuned Llama 3.1 8B for Sri Lankan property law with step-by-step legal reasoning, IRAC analysis, and statute citations.
Downloads · 30 days
13
9% of all-time downloads
All-time downloads
143
Public
Repo size
688 MB
Likes
0
Public
Click a slice to open those files.
.safetensors671 MB · 97%
From the Hugging Face model README
Fine-tuned Llama 3.1 8B for Sri Lankan property law with step-by-step legal reasoning, IRAC analysis, and statute citations.
| Field | Details |
|---|---|
| Project | LegalVision (ID: 25-26J-127) |
| Component | Explainable Legal Reasoning Module |
| Author | S. Sivanuja |
| Collaborator | Sharan (Knowledge Graph) |
| Supervisors | Ms. Vindhya Kalapuge, Ms. Adya Dissanayake |
| Institution | IIT Sri Lanka / University of Westminster |
| Spec | Value |
|---|---|
| Base Model | Llama-3.1-8B-Instruct |
| Method | QLoRA (4-bit) |
| LoRA Rank | 64 |
| Epochs | 3 |
| Learning Rate | 2e-4 |
Topics: Property Transfer, Bim Saviya, Prescription, Partition, Mortgage, Lease, State Land, Foreign Ownership, Inheritance
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
import torch
bnb_config = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_compute_dtype=torch.bfloat16)
base = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.1-8B-Instruct", quantization_config=bnb_config, device_map="auto")
model = PeftModel.from_pretrained(base, "YOUR_USERNAME/legalvision-srilanka-llama3.1-8b")
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.1-8B-Instruct")
messages = [
{"role": "system", "content": "You are a Sri Lankan property law expert. Provide IRAC analysis with statute citations."},
{"role": "user", "content": "What are the requirements for property transfer?"}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=1024, temperature=0.7)
print(tokenizer.decode(output[0], skip_special_tokens=True))
Includes handler.py for HuggingFace Inference Endpoints.
Request:
{
"messages": [{"role": "user", "content": "Can foreigners buy land in Sri Lanka?"}],
"parameters": {"max_new_tokens": 1024, "temperature": 0.7}
}
Response:
{
"generated_text": "**Answer:** Foreigners face restrictions under the Land (Restrictions on Alienation) Act...",
"usage": {"prompt_tokens": 156, "completion_tokens": 423, "total_tokens": 579}
}
@misc{legalvision2025,
author = {Sivanuja, S.},
title = {LegalVision: Sri Lankan Property Law Reasoning Model},
year = {2025},
publisher = {HuggingFace},
note = {Project ID: 25-26J-127, IIT Sri Lanka}
}
LegalVision | IIT Sri Lanka | University of Westminster | © 2025