Grounded research over a controlled public corpus
Legal Document RAG
How can legal research return an evidence-linked answer without wandering beyond an approved public corpus?
Register and checksum sources, preserve document structure, retrieve from a promoted index, and require citations or refusal.
Turns public legal documents into a searchable corpus with evidence-linked answers and an explicit refusal path.
AI engineer / Data engineer
Built and deployed an Azure RAG workspace using Document Intelligence, AI Search, Azure OpenAI, managed identity, and citation-required generation over a 3,055-chunk public legal corpus.A legal-technology reviewer or AI engineering hiring manager evaluating trustworthy document retrieval and deployment practices.
Context and stakes
The decision context behind the system.
An Azure-hosted, evidence-first RAG workspace that makes every supported answer traceable to a registered public legal source.
Legal teams need answers that stay attached to the source, especially when documents are long and high stakes. This project demonstrates an evidence-first research workflow over public M&A litigation and transaction documents: a reviewer asks a question, receives a grounded answer, and can inspect the cited document, section, and page rather than trusting an unsupported response.
Approach
A bounded approach shaped by the published constraints.
Register and checksum the source boundary, preserve document structure, retrieve only from the promoted index, and require citations or an explicit refusal.
Design constraints
- The public endpoint is anonymous and does not have the controls required for confidential legal matters.
- The evaluation does not establish legal-answer correctness or legal advice quality.
- Some source-specific reuse terms may differ even though the documents are available from official public sources.
- HTTP reachability does not establish an availability, confidentiality, security, or production SLO.
Decision journey
The system moves through an inspectable sequence.
Each stage below comes from the published project manifest.
- Stage
Public source registration and
Public court opinions and SEC transaction documents
- Stage
Azure Document Intelligence and
Versioned extraction adapters and document records
- Stage
Structure-aware chunking and embeddings
Structure-aware public corpus chunks
- Stage
Azure AI Search retrieval
Azure AI Search retrieval index
- Stage
Citation-required grounded generation and
Azure OpenAI grounded answer service
- Stage
Read-only Flask research workspace
Flask evidence workspace with source links
Interactive architecture
The published architecture, made interactive.
Versioned adapters ingest public PDFs through Azure Document Intelligence and public SEC HTML through a native parser, normalize them into stable records, and build structure-aware chunks. Azure AI Search retrieves the promoted public corpus; Azure OpenAI generates only from that evidence, while the Flask workspace exposes research, corpus, evaluation, and health views. Managed identity separates deployed resources from local credentials, and the corpus index is promoted independently from application deployment.
Drag to pan / use controls to zoom / select any stageRead the architecture as text
- Public court opinions andStage 1 / Python
Public court opinions and SEC transaction documents
- Versioned extraction adapters andStage 2 / Flask
Versioned extraction adapters and document records
- Structure-aware public corpus chunksStage 3 / Azure Document Intelligence
Structure-aware public corpus chunks
- Azure AI Search retrievalStage 4 / Azure OpenAI
Azure AI Search retrieval index
- Azure OpenAI grounded answerStage 5 / Azure AI Search
Azure OpenAI grounded answer service
- Flask evidence workspace withStage 6 / Azure Blob Storage
Flask evidence workspace with source links
Pivotal decisions
Technology choices recorded with their trade-offs.
These choices are derived from the project's published decision record.
Use Azure AI Search with Azure OpenAI within the published boundary
Managed retrieval, identity, and model services support a deployable Azure reference architecture.
- Constraints
- Serverless Search removes fixed idle retrieval compute, but the preview has no SLA and future usage and storage charges require monitoring
- The public endpoint is anonymous and read-only; it is not a confidential eDiscovery workspace or production legal service
- The current evaluation proves retrieval and provenance, not attorney-reviewed answer accuracy
- Alternatives
- Local Chroma and API-key based model access
- Criteria
- Fit for the stated scope / Inspectable evidence / Explicit operating boundary
- Selected
- Azure AI Search with Azure OpenAI
- Why
- Managed retrieval, identity, and model services support a deployable Azure reference architecture.
- Trade-off
- Serverless Search removes fixed idle compute cost, but the preview has no SLA and future usage and storage charges require monitoring.
- What supported it
- 1.0 retrieval hit rate@8: 45-question versioned release benchmark.
- Revisit when
- Add attorney-reviewed answer and citation-correctness evaluation beyond retrieval and provenance checks
Use Vendor-neutral extraction records within the published boundary
Azure SDK objects terminate at the adapter so parsing, chunking, evaluation, and storage remain testable.
- Constraints
- Serverless Search removes fixed idle retrieval compute, but the preview has no SLA and future usage and storage charges require monitoring
- The public endpoint is anonymous and read-only; it is not a confidential eDiscovery workspace or production legal service
- The current evaluation proves retrieval and provenance, not attorney-reviewed answer accuracy
- Alternatives
- Propagate Azure SDK types through the pipeline
- Criteria
- Fit for the stated scope / Inspectable evidence / Explicit operating boundary
- Selected
- Vendor-neutral extraction records
- Why
- Azure SDK objects terminate at the adapter so parsing, chunking, evaluation, and storage remain testable.
- Trade-off
- The stable boundary adds mapping code but reduces provider coupling and keeps tests deterministic.
- What supported it
- 3,055 public retrieval chunks: Promoted r3 Azure AI Search corpus on the Serverless Developer preview.
- Revisit when
- Replace the residual style-based legal-outline parser heuristics with a branch-aware outline state machine
Results and evaluation
Measured results within the disclosed evaluation boundary.
- Method
- Committed release evaluation against the promoted index.
- Meaning
- 45-question versioned release benchmark.
- Limitation
- The public endpoint is anonymous and does not have the controls required for confidential legal matters.
Limitations and next steps
Useful evidence, bounded claims.
What this does not prove
- The public endpoint is anonymous and does not have the controls required for confidential legal matters.
- The evaluation does not establish legal-answer correctness or legal advice quality.
- Some source-specific reuse terms may differ even though the documents are available from official public sources.
- HTTP reachability does not establish an availability, confidentiality, security, or production SLO.
- Serverless Developer is a preview with no SLA and is not recommended for production workloads.
What I would do next
- Add attorney-reviewed answer and citation-correctness evaluation beyond retrieval and provenance checks
- Replace the residual style-based legal-outline parser heuristics with a branch-aware outline state machine
- Add authenticated matter isolation, encrypted private storage, malware scanning, retention, and audit controls before any user uploads
- Move ingestion and index construction to durable background workflows with reviewed index promotion
- Add quota, cost, abuse, availability, and security monitoring appropriate to an owner-approved production service
Uses public court opinions and public SEC transaction documents. The application provides legal information for engineering demonstration and is not legal advice.
Explore the rest of the work