- AI/ML
- Backend Development
AI Legislative Analyzer
GenAI pipeline that turns dense legislation into citizen-friendly summaries.
Overview
An end-to-end GenAI application that ingests dense legislative documents and generates concise, citizen-friendly summaries using LLM-based prompt engineering through the OpenAI API.
Problem statement
Legislation is written for legal professionals — long, cross-referential and padded with boilerplate. A citizen needs the operative rules, penalties and deadlines, not a hundred pages of formal prose.
Technical implementation
- Four-step compression pipeline: boilerplate and duplicate removal, symbolic compression with 60+ abbreviation rules, structured JSON extraction (penalties, stakeholders, rules) and citizen-facing summarisation.
- NLP-based keyphrase extraction and semantic similarity surface the most relevant passages before they reach the LLM, improving summarisation relevance and reducing hallucination risk.
- LLM summarisation through the OpenAI API with prompt engineering; the pipeline degrades gracefully to rule-based NLP when no API key is configured.
- REST endpoints exposed through a FastAPI backend and consumed by a Streamlit dashboard.
- tiktoken-based token accounting measures compression and cost savings per document.
Key features
- TL;DR, bullet and risk / benefit summary cards
- Structured JSON output: rules, penalties, deadlines, benefits, risks, definitions
- Keyphrase extraction and semantic similarity ranking (spaCy, KeyBERT, sentence-transformers)
- Works fully offline with rule-based NLP — OpenAI integration is optional
- FastAPI REST backend with a Streamlit citizen dashboard
Technology stack
- Python
- FastAPI
- Streamlit
- OpenAI API
- spaCy
- KeyBERT
- sentence-transformers
- tiktoken