Inspiration

Contracts are an essential part of business, but reviewing them can be slow and difficult. Important clauses are often hidden in lengthy documents, and understanding complex legal language can require significant time and expertise.

We wanted to build a system that could make the initial contract review process faster, easier to understand, and more transparent. This inspired us to create ContractOS, an AI-powered platform that combines OCR, NLP, machine learning, and large language models to turn complex contracts into clear, actionable insights.

What it does

ContractOS provides an end-to-end workflow for analyzing legal contracts.

Users can upload PDF or DOCX contracts, including scanned documents. The platform extracts the text, automatically segments the contract into individual clauses, and analyzes them for potential risks.

InLegalBERT performs clause classification and risk prediction, categorizing clauses as Low, Medium, or High risk and providing confidence information. These results are combined into a Contract Health Score and displayed through an interactive risk dashboard.

Llama 3 generates executive summaries, contract insights, business recommendations, and explanations. Users can also translate complex legal clauses into plain English and generate downloadable PDF executive reports.

ContractOS also includes SHAP-based explainability to help users understand why a clause received a particular risk classification. The Clause Simulation feature, called the "Legal Time Machine", allows users to explore the effect of modifying contractual clauses.

How we built it

ContractOS was built as a modular full-stack AI application.

The frontend uses React, TypeScript, and Tailwind CSS, while the backend is built with Python and FastAPI. PostgreSQL is used for data storage.

For document processing, PyMuPDF extracts text from digital documents and PaddleOCR processes scanned contracts. The extracted text is segmented into clauses before being passed to InLegalBERT for classification and risk prediction.

Llama 3 is used for executive report generation, summaries, insights, and explanations, while SHAP provides explainability for the machine-learning predictions.

The complete pipeline is:

Upload Contract → Text Extraction/OCR → Clause Segmentation → Risk Classification → Contract Health Score → AI Insights → Dashboard → PDF Report

This architecture allowed us to combine specialized NLP and machine-learning models with an LLM rather than relying on a single model for the entire process.

Challenges we ran into

One of our biggest challenges was processing contracts in different formats. Digital documents and scanned documents require different extraction techniques, and OCR errors can affect subsequent clause segmentation and analysis.

Another challenge was making AI-generated risk predictions understandable. Simply displaying a "High Risk" label does not tell users why a clause is considered risky. We addressed this by incorporating SHAP-based explanations and using Llama 3 to provide human-readable insights.

We also had to carefully define the responsibilities of different AI components. InLegalBERT handles structured classification and risk prediction, while Llama 3 focuses on generating summaries and explanations. Integrating these components into a single reliable workflow required careful processing between each stage.

Accomplishments that we're proud of

We are proud of building ContractOS as a complete end-to-end platform rather than a standalone AI model.

The system brings together OCR, automatic clause segmentation, machine-learning-based risk classification, contract scoring, explainable AI, LLM-powered reporting, plain-English translation, interactive visualization, and PDF report generation in one workflow.

We are particularly proud of the explainability layer using SHAP, because it helps users understand the reasoning behind risk predictions instead of treating the AI as a black box.

The "Legal Time Machine" clause simulation feature also adds an interactive dimension to contract analysis by allowing users to explore the impact of clause changes.

What we learned

Building ContractOS taught us that applying AI to legal documents requires more than generating text with an LLM. Reliability, structured processing, explainability, and user experience are equally important.

We learned how to integrate OCR, NLP models, machine learning, LLMs, explainable AI, backend APIs, databases, and frontend components into a single application.

We also learned the importance of assigning different tasks to the models based on their strengths. Using InLegalBERT for structured risk prediction and Llama 3 for language generation gave us a more organized approach than relying entirely on an LLM.

Most importantly, we learned how to turn complex AI outputs into information that can be understood and acted upon by users.

What's next for ContractOS

We plan to expand ContractOS with multilingual contract analysis, a clause recommendation engine, and an AI-powered contract negotiation assistant.

Future versions could also include real-time collaboration, cloud deployment, multi-user authentication, and a voice-based contract assistant.

Our long-term goal is to make ContractOS a comprehensive AI-assisted contract intelligence platform that helps users understand, evaluate, and work with contracts more efficiently while keeping human decision-making at the center.

Built With

Share this project:

Updates

Submission history