
AI Lawyer
A multilingual AI legal assistant that makes Bangladeshi law easier to understand in Bangla, English, and Banglish.
Timeline
Academic capstone
Role
Solo Developer & Researcher
Team
Solo project
Status
CompletedTechnology Stack
Key Challenges
- Collecting and normalizing bilingual legal text from official sources
- Creating useful Bangla, English, and Banglish question-answer data
- Fine-tuning an 8B-parameter model within limited GPU resources
- Designing clear guardrails for a high-stakes legal information product
Key Learnings
- Parameter-efficient fine-tuning with LoRA and 4-bit quantization
- Building multilingual datasets from unstructured public documents
- Serving production-ready LLM inference with Ollama and vLLM
- Designing transparent AI experiences for high-stakes information
AI Lawyer: Accessible Guidance for Bangladeshi Law
Overview
AI Lawyer is a multilingual legal information assistant designed to make Bangladeshi law easier to understand. Users can ask questions in Bangla, English, or Banglish and receive a streamed conversational response grounded in a model fine-tuned on official legal material.
The project addresses a practical access problem: legal information can be costly, difficult to interpret, and less available outside major cities. AI Lawyer provides an approachable first step for basic legal questions while clearly remaining an informational tool—not a replacement for a qualified lawyer.
What I Built
I independently developed AI Lawyer as a solo capstone project, owning the complete product lifecycle:
- Building the legal-document scraper and data pipeline
- Cleaning, structuring, and enriching bilingual training data
- Selecting, fine-tuning, and evaluating language models
- Developing the frontend, backend, authentication, and administration tools
- Testing multilingual and edge-case prompts
- Preparing the technical research and project documentation
Product Capabilities
- Multilingual chat: Supports questions and answers across Bangla, English, and Banglish
- Streaming responses: Delivers generated guidance progressively in the chat interface
- Persistent conversations: Provides authenticated accounts and saved chat history
- Model controls: Lets administrators enable models and configure generation parameters and system prompts
- Operational tooling: Includes user and role management, telemetry, and database inspection
- Production inference: Runs models through Ollama and vLLM for reliable, high-performance serving
Building the Legal Dataset
I built a custom Python scraper with Beautiful Soup and Requests to collect official legal content from bdlaws.minlaw.gov.bd. The source material spans English and Bangla volumes and is organized around acts, sections, notes, and legal scenarios.
The preprocessing pipeline used regular-expression cleaning, Pandas and NumPy for structuring, SentencePiece tokenization, and Hugging Face Datasets. I enriched the material with bilingual question-answer pairs and scenario-style prompts so the model could learn to explain legal concepts conversationally instead of simply reproducing source text.
Model Training
The core model is LLaMA 3.1 8B, adapted using parameter-efficient fine-tuning:
- LoRA/PEFT for targeted model adaptation
- 4-bit quantization with bitsandbytes
- Hugging Face Transformers and TRL
SFTTrainer - Unsloth, PyTorch, xFormers, and Triton for training efficiency
- Five training epochs across Colab T4/V100 and A6000 GPU environments
- GGUF export for Ollama and llama.cpp-compatible local inference
Evaluation included training and validation loss, accuracy and F1 tracking, multilingual and edge-case prompts, comparison with an untuned base model, and qualitative feedback that included a legal professional. The report documents stable training behavior and qualitative improvement, but does not claim unsupported benchmark percentages.
Application Architecture
The application follows a layered data, model, and product architecture:
- Interface: Next.js 15, React 18, TypeScript, Tailwind CSS, and Radix UI
- API: Node.js REST services with the Vercel AI SDK
- Data: PostgreSQL with authenticated, persistent chat history
- Security: JWT authentication, bcrypt password hashing, and Zod validation
- Inference: Ollama and vLLM for local and high-performance model serving
- Deployment: Ubuntu, Traefik, and Let's Encrypt
Responsible Scope
AI Lawyer is intentionally positioned as a basic legal information assistant. It does not prepare legal documents, represent users, or replace professional advice. Its quality also depends on the completeness and currency of the underlying legal material, and mixed-language spelling or dialect variations remain challenging.
These constraints shaped the product design: make the system useful and accessible, while communicating uncertainty and encouraging users to consult a qualified professional for complex or consequential matters.
What I Learned
This project connected applied machine learning with end-to-end product engineering. The most valuable lesson was that a useful AI system requires much more than model training: trustworthy data, clear product boundaries, resilient infrastructure, careful evaluation, and an interface that communicates what the system can—and cannot—do.