Featured Project — RAG System
Ask the Constitution
A full-stack retrieval-augmented generation (RAG) application that answers questions about the Constitution of Pakistan in plain language — and shows the exact articles every answer is grounded in.
The Problem
The Constitution of Pakistan is a long legal document. Finding what it says about a specific right, office or article means paging through hundreds of provisions written in dense legal language — slow for students, journalists and citizens alike.
What I Built
- A complete question-answering pipeline: the constitutional text is split into 768 searchable chunks, embedded locally, and retrieved by semantic similarity for every question.
- Answers are generated by a large language model that is constrained to the retrieved passages, and each answer is shown with expandable source cards so the user can verify it against the actual text.
- A production deployment split across a FastAPI backend and a React frontend, with retry handling for free-tier rate limits.
Technical Approach
- Chunking: article-aware splitting of the constitutional text into 768 chunks with overlap, so no provision is cut mid-thought.
- Embeddings: all-MiniLM sentence embeddings computed with an ONNX runtime build, keeping the backend light enough for free hosting.
- Retrieval: FAISS inner-product search returns the top passages per question; the model answers only from those passages.
- Interface: React + Vite frontend with expandable citation cards, deployed on Vercel; FastAPI backend on Render.
Technologies & Stack
Results
The app is live and public. Questions about fundamental rights, the presidency, the judiciary and more return grounded answers with the source articles attached — no hallucinated article numbers, because the model only sees retrieved text.
Limitations
Free-tier hosting means the backend can cold-start, and the free LLM tier occasionally rate-limits (the UI retries once automatically). Coverage is limited to the constitutional text itself — it explains what the document says, not case law built on top of it.