BabelexAI
A proof-of-concept .NET solution for extracting and simplifying UK lease and tenancy agreements into plain English using Azure Document Intelligence and Azure OpenAI.
Brief
UK lease and tenancy agreements are often dense, highly technical legal documents that can be difficult for non-lawyers to interpret. As a result, clients may not fully understand the implications of the clauses they are being asked to sign.
Approach
This three-stage .NET proof of concept assesses the suitability of AI for automating this process. It comprises:
- Document ingestion
Azure Document Intelligence performs OCR on scanned PDFs to extract text and spatial bounding boxes, preserving full traceability to the original content in the source document.
- Structural parsing
A lexical parser identifies document sections and legal clauses, maps their hierarchies and numbering schemes, and reconstructs fragmented text into a coherent logical structure while maintaining lineage to the original source.
- Semantic analysis
Azure OpenAI is used in a multi-step workflow that evaluates sections holistically for context, such as considering covenants collectively, while also analysing content clause by clause to preserve provenance.
The output transforms legacy legal drafting into modern legal constructs and clear lay summaries for clients, with each result cross‑referenced to its original source context.
This PoC also creates a knowledge base of classified results that could support future enhancements. Although these capabilities are not part of the current implementation, it lays the groundwork for a structure‑aware retrieval‑augmented generation (RAG) layer built on reviewed outputs, precedent language and curated guidance, helping to improve consistency, contextual understanding and auditability.
The same foundation could also support future model comparison informed by human feedback and, over time, generate insights into how frequently particular clauses appear, how closely they align with standard drafting, and which provisions present elevated risk or are unusual enough to warrant closer scrutiny. That could be valuable not only for lawyers, but also for more junior legal assistants.
My Role
Tech Lead- OCR Pipeline: Azure Document Intelligence configuration, model selection, and bounding box data extraction.
- Lexical Parser: Custom .NET clause extraction engine handling nested hierarchies and text snippets reconstruction.
- AI Integration: Azure OpenAI prompt engineering and multi-step workflow design.
- Knowledge Base: Results store design for human feedback loops and future model refinement.
- Cost Modelling: Token usage tracking and end-to-end cost estimation across OCR, AI, hosting, and storage.
Technology Stack
Notable Highlights
- Full source traceability - every AI output cross‑referenceable to its original clause and page
- Hierarchical clause extraction with nested subclause and numbering scheme support
- Multi‑step AI workflow combining holistic section context with clause‑level provenance
- Converts legacy legalese into modern legal constructs and plain‑English client summaries
- Knowledge base foundation for future human feedback, RAG integration, or model fine‑tuning
- Cost‑effective end‑to‑end pipeline with built‑in token usage and cost tracking
- Modular architecture - each stage independently extensible and automatable