LexiGuard:自由工作者願意付費使用的隔離式法律合約篩查工具
LexiGuard: The Air-Gapped Legal Contract Screener Freelancers Would Actually Pay For
LexiGuard 是一款在本機運行的法律合約篩查智能體,協助自由工作者識別合約風險並查看原文依據。它透過 Ollama 在本機使用 Google Gemma 2 (2B),支援 PDF、DOCX、TXT 和純文字,並以頁碼及段落原文引文佐證每項發現。完整原始碼以 Apache 2.0 License 開源,合約資料不會離開用戶的筆電。
This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle
What I Built
Every freelancer, independent contractor, and boutique agency owner dreads the same moment: a new client sends over an 8-to-15 page Master Services Agreement (MSA) or Non-Disclosure Agreement (NDA) packed with dense legalese.
Most freelancers face a frustrating dilemma:
Hiring a contract lawyer costs $300 to $500 an hour—often more than the initial deposit of the project itself.
Pasting the contract into cloud LLMs like ChatGPT or Claude violates non-disclosure provisions and client data confidentiality before the project even kicks off.
Skimming and signing blindly exposes them to predatory non-compete clauses, unlimited liability indemnification, or unreasonable payment milestones.
I built LexiGuard, an air-gapped, on-device legal contract screener and triage copilot.
LexiGuard runs entirely on the user's local machine. It ingests contracts across multiple formats (PDF, DOCX, TXT, or raw text), extracts core obligations and payment terms, flags asymmetric liabilities or missing standard protections, and grounds every single finding with exact page-and-paragraph substring citations—with zero data ever leaving the laptop.
Demo
After following the guide on my README.md, just type >> python -m lexiguard demo on your suitable terminal.
Code
The complete source code, test suites, and reproduction guide are open source under the Apache 2.0 License:
LexiGuard — Private On-Device Legal Document Triage Agent
Track: Problem Statement 2 (PS2) — Agentic AI: Private Legal Document Triage Agent
Event: ZeroDay OSS Hacktoberfest 2026, IIIT Dharwad
Repository: https://github.com/abhisheksingh1729/lexiguard
Author: Abhishek Singh
📌 Executive Summary & Problem Statement
Legal agreements—such as residential tenancy leases, software employment contracts, unilateral non-disclosure agreements (NDAs), and cloud terms of service—are dense with archaic terminology, hidden liabilities, and asymmetric risk allocations. For ordinary individuals, tenants, and small business operators, seeking prompt legal review is cost-prohibitive and slow.
However, sending confidential agreements to cloud-hosted proprietary LLMs introduces severe confidentiality and data privacy violations (GDPR, HIPAA, attorney-client privilege breaches).
The Solution: LexiGuard
LexiGuard is an air-gapped, privacy-first legal triage agent running 100% locally on consumer hardware. Powered by Google Gemma 2 (2B) via localhost Ollama, LexiGuard translates complex legalese into clear risk breakdowns, programmatically verifies all citations against raw source text, detects omitted statutory safeguards ("silent…
Who Would Pay for This?
Freelancers & Solopreneurs: Software engineers, graphic designers, copywriters, and consultants who need instant contract clarity without burning money on preliminary legal reviews.
Micro-Agencies & Small Businesses: Teams dealing with high-volume client onboarding that cannot afford an in-house legal counsel.
How I Built It
LexiGuard was engineered from the ground up around open-source AI and local runtime execution:
Open-Weight Core: Google’s Gemma 2 2B (gemma2:2b), selected for its low memory footprint (~1.6 GB) and high reasoning capabilities on structured extraction tasks.
Local Inference Engine: Ollama running locally on localhost:11434, ensuring complete privacy and isolation from cloud endpoints.
Multi-Format Ingestion Engine: PyMuPDF (PDF parsing with page and bounding metadata) and python-docx (Word documents), along with support for plain text and raw copy-pasted clauses.
Dynamic Few-Shot Exemplar Memory: An on-device SQLite database (lexiguard_vault.db) that handles document hashing, active caching to eliminate redundant re-computation on identical files, and in-context adaptation using verified user feedback.
Deterministic Guardrails & Verifier: A post-processing pipeline that performs programmatic substring checks to eliminate hallucinated quotes, enforces schema validity via Pydantic, and intercepts adversarial prompt injections.
User Interface: A minimalist, typography-focused dashboard built in Streamlit.
Why Does Open Innovation Matter?
For a legal triage tool, open innovation isn't just an implementation choice—it is the only architecture that makes the product viable.
Client Confidentiality is Non-Negotiable: Commercial cloud LLM terms often reserve rights to log, inspect, or train on user prompts. Uploading a client's proprietary software contract or confidential patent clause to a closed API is an immediate breach of contract. An open-weight model running locally guarantees zero telemetry and zero leakage.
Zero Marginal Inference Cost: Running a business on closed APIs subjects a solopreneur to unpredictable token fees, rate limits, and pricing shifts. With open-weight models like Gemma 2, processing a 30-page agreement costs the same as processing a single paragraph: $0.00.
Auditable Trust: In legal tech, black-box closed models that hallucinate answers or hide system prompts pose severe liability risks. Open-source models paired with open parsers allow complete transparency into how text is extracted, chunked, and verified.
My Agent Session
LexiGuard was developed and scaffolded using Antigravity IDE alongside coding agents. Agent rules were configured locally (.agents/rules/hackathon.md) to enforce strict air-gapped development: rejecting external API calls, mandating Pydantic schemas, and automating SQLite persistence layers.
My First User
To validate the commercial viability of LexiGuard, I shared the working prototype with a peer who frequently works on independent client web development contracts:
"I usually skim through client NDAs because reading 12 pages of legalese gives me a headache, but I know I'm risking signing something bad. Having a tool that runs on my laptop with Wi-Fi off and instantly flags that there is 'No liability cap' and 'Immediate termination without notice' is wild. I would easily pay $25 to $35 one-time just to have this sitting in my dock."
— Himanshu L., Freelance Web Developer
Prize Categories
Best Use of Gemma
來源:DEV Community · dev.to
