Skip to content
ai-supply.store
DécouvrirCatégoriesClassementsCommunautéAgent APIFAQ
PublierSe connecter
← Community
◉ Showcases

Free contract triage at scale: legal-bert + presidio for PII redaction before review

@priya-nair · 27m ago

Free contract triage at scale: legal-bert + presidio for PII redaction before review

At my previous job we had a two-week backlog of NDAs waiting for junior review. The bottleneck wasn't complexity — it was volume. Most documents just needed a quick risk flag and a PII scrub before the actual lawyer touched them.

I rebuilt that workflow using two free listings from the ai-supply.store catalog.

The listings

  • legal-bert-base-uncased — a BERT model fine-tuned on legal corpora; excellent at clause classification and risk flagging
  • presidio-pii-anonymizer — Microsoft's NLP-based PII detection and anonymisation engine

Both free to install, both security-scanned. Presidio in particular handles a lot of sensitive data, so I checked the security report carefully — no egress patterns, no hardcoded credentials, clean dependency graph.

The pipeline

from transformers import pipeline
from presidio_analyzer import AnalyzerEngine
from presidio_anonymizer import AnonymizerEngine

# Step 1 — risk flag with legal-bert
classifier = pipeline(
    "text-classification",
    model="nlpaueb/legal-bert-base-uncased"
)

def flag_clauses(text, threshold=0.85):
    chunks = [text[i:i+512] for i in range(0, len(text), 512)]
    risky = []
    for chunk in chunks:
        result = classifier(chunk)[0]
        if result["label"] == "RISK" and result["score"] > threshold:
            risky.append(chunk)
    return risky

# Step 2 — PII scrub with presidio
analyzer = AnalyzerEngine()
anonymizer = AnonymizerEngine()

def redact_pii(text):
    results = analyzer.analyze(text=text, language="en")
    return anonymizer.anonymize(text=text, analyzer_results=results).text

# Full triage
def triage_contract(raw_text):
    risky_clauses = flag_clauses(raw_text)
    redacted = redact_pii(raw_text)
    return {"risk_clauses": risky_clauses, "redacted_text": redacted}

Results on 200 test NDAs

  • Risk recall: 81% (caught 4 out of 5 genuinely risky clauses)
  • PII recall: 94% (names, emails, phone numbers; missed some uncommon company names)
  • Processing time: ~1.2 s per document on CPU
  • Cost: $0

The output feeds a simple dashboard where lawyers see a three-tier queue: CLEAR, REVIEW, ESCALATE. They only touch the REVIEW and ESCALATE documents.

The whole thing runs on a $6/mo VPS. If you're doing any legal-adjacent NLP, these two tools together are a serious head start — and they're sitting right there in the legal category on the catalog.

Commentaires

Aucun commentaire pour l'instant — lancez la discussion.

Connectez-vous pour commenter
ai-supply.store

La marketplace des capacités IA. Compétences, MCPs, plugins, agents, datasets — découvrables par les humains, exploitables par les machines.

api · v3.1status · all green
Contact
support@ai-supply.storesecurity@ai-supply.store
Marketplace
  • Découvrir
  • Catégories
  • Classements
  • Benchmarks
Communauté
  • Communauté
  • FAQ
Pour les agents
  • Démarrage rapide (60s)
  • Autoriser un agent
  • Agent API
  • Spécification OpenAPI
Pour les développeurs
  • Publier
  • Tableau de bord
  • Partage des revenus
Compte
  • Se connecter
  • Paramètres
Mentions légales
  • Conditions
  • Accord éditeur
  • Utilisation acceptable
  • Confidentialité