sharugesanr/aramAI-legal
AramAI Legal — Fine-Tuned TinyLlama for Indian Legal Q&A
AramAI is a LoRA-fine-tuned adapter on TinyLlama 1.1B Chat, trained on 21,948 Indian Supreme Court case pairs to answer legal questions in the context of Indian law. It is the AI backbone of the AramAI platform — a free multilingual legal assistant built for marginalized communities in India.
"Aram" means justice in Tamil.
Model Details
- Developed by: Sharugesan R., Rithik P., Keerthi Vasagan S.
- Institution: PSNA College of Engineering and Technology (PSNACET), AI & Data Science Department
- Guide: Dr. T. Hemalatha, Professor & HOD, AI&DS, PSNACET
- Model type: LoRA Adapter (PEFT) on TinyLlama 1.1B Chat
- Language(s): English, Tamil
- License: MIT
- Base model: TinyLlama/TinyLlama-1.1B-Chat-v1.0
- GitHub: https://github.com/sharugesanr/AramAI
What This Model Does
This adapter fine-tunes TinyLlama to understand Indian legal terminology, Supreme Court case patterns, IPC sections, and provide structured legal guidance. When given a legal question, it responds with:
- Applicable law and IPC sections
- What courts typically decide in similar cases
- Practical next steps for the user
- Evidence to collect
Training Details
Training Data
- Source: Kaggle — Indian Supreme Court case records
- Raw dataset: 53,446 Supreme Court case records (casefilestotal.csv)
- After cleaning: 21,948 structured question-answer pairs
- Format: Instruction-Input-Output (SFT format)
- Case types covered: Civil appeals, writ petitions, special leave petitions, contempt petitions, election petitions, review petitions, transfer petitions
Each training pair contains:
- Instruction: AramAI's role definition
- Input: A user legal question mapped to a real case type + case background
- Output: Verdict outcome + court reasoning + practical guidance
Training Procedure
- Base model: TinyLlama/TinyLlama-1.1B-Chat-v1.0
- Fine-tuning method: LoRA (Low-Rank Adaptation) via PEFT
- Training framework: SFTTrainer (TRL)
- Quantization: 4-bit NF4 via BitsAndBytes
- Hardware: Google Colab free tier — NVIDIA Tesla T4 (14.6GB VRAM)
- Training samples: 3,000 (reduced from 20,850 to fit Colab session)
- Evaluation samples: 150
- Epochs: 2
- Batch size: 16
- Gradient accumulation steps: 2
- Learning rate: 2e-4
- Warmup steps: 20
- Max sequence length: 128 tokens
- Precision: BFloat16
LoRA Configuration
- Rank: 8
- Alpha: 16
- Dropout: 0.05
- Target modules: qproj, kproj, vproj, oproj
- Trainable parameters: 2.25M out of 617.86M (0.36%)
- Adapter size: 4.5MB
Training Results
Decreasing loss with training and validation loss staying close together confirms the model learned legal patterns and generalised rather than memorised.
How to Get Started
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
base_model_id = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
adapter_id = "sharugesanr/aramAI-legal"
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
torch_dtype=torch.float16,
device_map="auto"
)
model = PeftModel.from_pretrained(base_model, adapter_id)
prompt = "I was arrested without a warrant. What are my legal rights in India?"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=200)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))Note: This model requires minimum 8GB RAM. For production use, the AramAI platform uses Groq API (LLaMA 3.3 70B) for faster, higher-quality responses. This adapter demonstrates the domain-specific fine-tuning contribution.
Limitations
- Trained on only 3,000 samples due to Colab free tier time constraints
- Training data sourced from Kaggle — not verified against original court records
- Some training examples contain court header noise (petitioner names, citation numbers)
- Running on CPU (Intel i3, 8GB RAM) produces ~17 minute response times
- May hallucinate law firm names or signatures due to noisy training data
- Not a substitute for professional legal advice
Bias and Risks
- Training data covers only Supreme Court cases — may not reflect lower court or state-specific legal situations accurately
- Tamil language support is limited in this adapter; Tamil responses in the full AramAI platform are handled via the system prompt to Groq API
- Legal information provided should always be verified with a qualified lawyer
Full Project
The complete AramAI platform includes:
- React.js frontend with Tamil voice input/output
- FastAPI backend with conversation memory
- Complaint letter drafting and PDF generation
- Sarvam AI integration for Indian language TTS/STT
GitHub: https://github.com/sharugesanr/AramAI
Framework Versions
- PEFT 0.18.1
- TRL 0.29.1
- Transformers 5.0.0
- BitsAndBytes (latest)
- Python 3.12
