Problem Statement
Reviewing lease agreements is a time-consuming, error-prone process that demands both attention to detail and deep knowledge of local legal norms. Polish umowa dzierżawy contracts, in particular, are lengthy and full of complex clauses that may include ambiguous language, missing legal provisions, or terms that unfairly favor one party. Lawyers and compliance officers often spend hours combing through each document line by line to identify problematic sections—work that is not only slow but also prone to oversight, especially under time pressure. This bottleneck slows down business transactions and increases the risk of signing agreements that may later result in disputes or regulatory issues.
The result: faster, more accurate reviews of legally binding documents—without manual line-by-line reading.
Objective
To identify:
- Missing clauses (e.g., termination terms, tenant/landlord responsibilities)
- Illegal or ambiguous language
- Unclear financial terms
- Favoring of given side
… and place comments directly in the document at the relevant section.

Architecture diagram

Process and logic behind the scenes

Once the document is uploaded, it goes through a quick validation phase—basic checks like file size and file type. After passing those, it's handed off to our cutter service.
This service breaks the document down into manageable chunks—specifically, by paragraphs. For documents like lease agreements, which follow a fairly predictable structure, we use custom regular expression rules to slice the content cleanly.
Each extracted paragraph is then sent—along with a carefully crafted prompt—to a LLM
Next up, we pass both the original document and the LLM-generated JSON to our doc marker service. This service attempts to find the exact location of the extracted text in the original file and insert the corresponding comment.
However, there’s a catch. Sometimes, the LLM "helpfully" corrects typos in the text it returns, which means the doc marker can’t find a perfect match. To handle this, we’ve integrated a fuzzy matching algorithm that helps us locate the correct spot in the document even when the text isn’t identical.
This setup allows us to semi-automate legal document analysis in a structured, explainable way—while leaving room for human review and overrides when needed.

Future improvements
Retrieval-Augmented Generation (RAG): Making the AI Legally Aware
One natural extension of this system is to add Retrieval-Augmented Generation (RAG). This would allow the model to pull in real, jurisdiction-specific legal context—like the Polish civil code or tax law—at query time. The system could:
- Analyze each paragraph to extract key concepts.
- Search a vectorized database of up-to-date legal texts (laws, precedents, policies).
- Inject the most relevant excerpts into the LLM prompt.
With this just-in-time grounding, the model could produce more precise, legally compliant comments—like having access to a private law library.
Multi-Agent Parsing
Another possible improvement is adopting a multi-agent parsing architecture, where specialized agents focus on different aspects of the document in parallel. For example:
- One agent examines financial terms.
- Another evaluates statutory compliance.
- A third checks for balance and fairness between tenant and landlord.
Their findings would then be combined into a single, coherent review. This approach allows deeper domain-specific expertise and more efficient processing.
Research Feature: Interactive Legal Exploration
Adding an interactive research feature could enhance the tool’s usefulness for human reviewers. Clicking on a flagged issue could display the underlying legal basis or precedent, helping users understand why a particular clause is problematic and explore the relevant law in context—effectively turning the tool into a junior legal researcher.
Law Firm–Style Commenting
Finally, refining the commenting style to match the tone, phrasing, and formatting of professional law firms would improve the readability and trustworthiness of the output. Comments would be clear, formal, and aligned with legal industry expectations, making it easier to integrate the analysis into existing workflows.