Legal AI Prompt Guard
a local classifier for legal assistants
2 min read
Legal AI Prompt Guard is an ultra-lightweight model for initial prompt classification and filtering in legal assistants. It analyzes the query text, recent conversation history, and retrieval state to decide whether to accept a request, reject it, or send it to manual moderation. The entire tool weighs just 55.2 KB (an 8-bit linear model) and runs on the standard Python library, with BERT Tiny-based variants also available. It is built for developers of legal AI services looking to automate incoming request triage and enforce safety policies.
Key features
- Ultra-lightweight footprint: the base version is just 55.2 KB, while a compact pilot variant comes in at 24.6 KB.
- High accuracy: achieves 93.7% binary decision accuracy on the test set.
- Flexible profiles: supports a general legal mode (
general_legal) alongside a specialized profile for Indian law (india_legal). - Error safeguard: low-confidence prompts are automatically routed to review mode (
review).
What you can do
- Filter prompts: integrate it into a local legal bot AI pipeline for fast screening of incoming questions.
- Route tasks: automatically assign client inquiries to different handling workflows based on the model's output route.
- Deploy without heavy GPUs: run the classifier directly on standard Python without needing high-end graphics cards.
Example
python -m legal_gate --model /path/to/weights.json.gz <<'JSON'
{"input":"What remedies can an Indian tenant seek if the landlord withholds the security deposit?","questions":{"decision":{"type":"choice"},"route":{"type":"choice"}}}
JSONRead more
DetailsBenchmarks: 93.7% accuracy on the grouped test set (238 examples) and 87.7% on an independent challenge set (138 examples).
Training: trained on synthetic data and validated using Gemini Decision 1.
Limitations: performance depends on the selected profile and classifier confidence thresholds.










Comments