Skip to content

Tarkash-Labs/FinePrint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FinePrint

Open-weights multimodal AI that decodes predatory contracts into plain English risk scores, powered by Gemma 4.

FinePrint is an open-source AI contract protection tool. Upload a photo, PDF, or paste any contract text. FinePrint reads it, finds every trap, and tells you exactly what's dangerous, what to negotiate, and what to never sign.

Why FinePrint

Every year, thousands of students sign employment bonds, internship agreements, and rental leases without understanding what they are agreeing to. The penalties are buried in dense clauses and most people do not have legal support. FinePrint bridges that legal literacy gap with personalized, clause-level guidance.

What You Get

  • Risk Score (0-100) for objective danger
  • Compatibility Score that reflects the user's requirements
  • Final Verdict: ACCEPT, NEGOTIATE, or REJECT with direct reasoning
  • Plain-English explanation of every red flag
  • Safer suggested rewrite for each dangerous clause
  • Actionable negotiation tips per clause
  • Personalized negotiation email draft
  • Shareable report link and downloadable PDF
  • Contract comparison between v1 and v2

Live Demo

Try it yourself: open the live app, click "Campus Bond" under "Try an example", fill in requirements, and hit Analyze.

Screenshots

Images live in docs/screenshots. Use the filenames below.

FinePrint homepage Caption: The FinePrint homepage, upload a contract or try a built-in example.

Results overview Caption: FinePrint analysis of a predatory internship contract (Risk 98, Compatibility 5, Verdict REJECT).

Red flag card Caption: Every red flag ships with explanation, negotiation tip, and a safer clause rewrite.

Negotiation email Caption: Gemma 4 Dense 31B drafts a personalized negotiation email ready to send.

Version comparison Caption: Version comparison showing risk reduced after negotiation.

Version comparison details Caption: Clause-level comparison showing resolved, new, and remaining flags.

How It Works

The model routing is deliberate and based on testing, not a default choice.

flowchart TD
  A[User uploads photo, PDF, or text] --> B[Gemma 4 MoE - gemma-4-26b-a4b-it\nMultimodal OCR]
  B --> C[Raw contract text]
  C --> D[Gemma 4 Dense 31B - gemma-4-31b-it\nLegal reasoning pipeline]
  D --> E[Streaming results via SSE\nRisk, Compatibility, Verdict\nRed Flags, Tips, Email, PDF]
Loading

Step 1: Gemma 4 MoE for Multimodal OCR

When a user uploads a photo or PDF, the MoE model reads the document image and extracts raw contract text. This step needs fast, accurate image reading, not legal reasoning.

Step 2: Gemma 4 Dense 31B for Legal Reasoning

All legal reasoning runs on the Dense 31B model: clause classification, risk scoring, compatibility analysis, plain-English explanations, suggested rewrites, negotiation tips, and the personalized negotiation email.

The Prompt That Makes It Personal

FinePrint sends the contract and the user's goals together, so compatibility is personal, not generic.

def _build_analysis_prompt(contract_label: str, focus_areas: str, requirements: str) -> str:
  requirements_text = requirements.strip() or "None provided."
  return f"""
You are a ruthless, detail-oriented legal expert specializing in {contract_label} contracts. Your job is to protect the user.
Analyze this contract and return a JSON with exactly these fields:
{{
  "risk_score": <integer 0-100>,
  "compatibility_score": <integer 0-100>,
  "verdict": "ACCEPT" | "NEGOTIATE" | "REJECT",
  "verdict_reason": "<1-2 sentence explanation referencing requirements and clauses>",
  "requirement_breakdown": [
    {{"requirement": "<specific user requirement>", "met": true/false, "explanation": "<why it was or wasn't met>"}}
  ],
  "red_flags": [
    {{
      "clause_title": "...",
      "clause_text": "<EXACT text from the contract>",
      "plain_english_explanation": "<Briefly state the risk>",
      "negotiation_tip": "<Actionable advice on what the user should ask to change>",
      "suggested_rewrite": "<Provide a safer, alternative 1-2 sentence rewrite for this clause that the user can propose>",
      "severity": "high|medium|low"
    }}
  ],
  "safe_clauses": [{{"clause_title": "...", "plain_english_explanation": "..."}}]
}}

CRITICAL RULES:
1. Return ONLY valid JSON. No preamble. No markdown blocks.
2. DETECT ALL RED FLAGS. Do not summarize them into one. If there are 5 bad clauses, list 5 red flags.
3. You MUST extract the exact original text for "clause_text".
4. The "risk_score" is objective based on standard legal risks. Focus heavily on: {focus_areas}.
5. The "compatibility_score" MUST directly reflect the User Requirements below. If a requirement is completely violated, score drops.

User Requirements to evaluate against:
{requirements_text}

Verdict guidance:
- ACCEPT when risk <= 30 and compatibility >= 70.
- REJECT when risk >= 61 or compatibility <= 30.
- Otherwise NEGOTIATE.
""".strip()

Tech Stack

  • Frontend: React, Vite, Tailwind CSS
  • Backend: Python, FastAPI, async SSE streaming
  • AI: Gemma 4 via Google AI Studio
  • Deploy: Vercel (frontend) + Render (backend)
  • License:

Notes on Architecture

  • Results stream clause by clause, so red flags appear in real time.
  • Shareable reports are stateless and stored inside the URL using gzip compression, no database required.
  • FinePrint is an assistant, not legal advice. A disclaimer is included in every report.

Getting Started

Follow these instructions to set up the project. Once set up, you can run the provided start.ps1 script to launch both servers without manual copy-pasting.

1. Backend Setup

Open a terminal in the backend folder and run the environment setup:

cd backend
python -m venv ../.venv
..\.venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env

Important: open backend/.env and add your GEMMA_API_KEY.

2. Frontend Setup

Open a terminal in the frontend folder and install the dependencies:

cd frontend
npm install

3. Running the App

To run the app automatically without copying and pasting commands every time, run the startup script from the root of the project:

.\start.ps1

This opens two new terminal windows, one running the FastAPI backend and the other running the Vite frontend.

Alternatively, run them manually:

  • Backend: cd backend then python -m uvicorn main:app --reload
  • Frontend: cd frontend then npm run dev

What's Next

FinePrint already supports multiple contract types, including campus bonds, NDAs, and rental agreements. Next up: a browser extension that flags red flags in any document, and a public API for integrations.

Contributing

Issues and pull requests are welcome. If you are adding a new contract type or model routing experiment, include a short evaluation note in the PR.

Built with ❤️ in India by Tarkash Labs.

About

Open-weights multimodal AI that decodes predatory contracts into plain English risk scores — powered by Gemma 4.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors