Legal Document Chatbot
A document-grounded question-answering prototype for uploaded legal PDFs.
Read the uploaded legal PDF, falling back to OCR for scanned content.
SELECT A STAGE TO FOLLOW THE SYSTEM
Overview
I built this project end to end.
The problem
Legal PDFs are difficult to navigate, and some are scans rather than searchable text. The prototype needed to make both kinds of document queryable while keeping answers tied to retrieved context.
What I built
- PDF text extraction with OCR fallback for scanned pages.
- Chunking, legal-domain embeddings, retrieval, and contextual question answering.
- A Streamlit interface for uploading documents and exploring clauses and answers.
System design
Uploaded PDFs pass through extraction and OCR fallback, then chunking and legal-domain embedding. Retrieved passages become the context for a language model answer in the Streamlit interface.
Key decisions
- Use OCR only when direct text extraction fails.
- Ground generated answers in retrieved document passages rather than free-form legal advice.
Outcome
A functional research prototype with a public repository. It has no formal answer-quality benchmark, and it is not a legal advice service.
What I learned
Retrieval quality and document extraction set the ceiling for the answer. The model cannot recover text that the pipeline never captured.