VLM-Guard
A composable rule-based verification layer that catches physically impossible, biologically inconsistent, or logically contradictory LLM outputs before they reach the end user.
The Clinical Problem
"Multimodal LLMs hallucinate confidently. In medical AI, a hallucination isn't a bug report — it's a patient safety incident."
How It Works
1. Image Enhancement
- →Domain-specific preprocessing (Giemsa contrast, X-ray normalization)
- →Quality checks: blur, exposure, grayscale validation
- →Configurable enhancement strategies (HIGH_CONTRAST, etc.)
2. Multimodal LLM Inference
- →Model-agnostic: works with any Callable[[Image, str], str]
- →HuggingFace, OpenAI, Anthropic, Google, local GGUF, or mock
- →Structured JSON prompt with reasoning_steps + answer schema
3. Structured Output Parsing
- →parse_reasoning_steps() extracts typed claim objects
- →Each claim has: type, observation, confidence, location
- →Pydantic-based Analysis schema with validation
4. Guardrail Engine
- →Composable rule engine: register any number of rules
- →BaseRule: per-claim validation (condition + action)
- →CrossClaimRule: multi-claim consistency checks
5. Audit Trail & Result
- →Every rule firing recorded with before/after snapshots
- →AuditTrail.to_dict() for compliance/regulatory review
- →Final result: structured Analysis with validation status
Safety & Trust
Every output passes through deterministic, auditable guardrails before reaching the user. No black boxes. No unseen failures.
Catches physically or biologically impossible claims (e.g., 'malaria in tissue biopsy') and blocks them, replacing with an appropriate uncertainty response.
Automatically corrects known misidentification patterns (e.g., flagellate in macrophage → promote to Leishmaniasis diagnosis).
When strong diagnostic signals are present but the LLM is uncertain, promotes the finding to increase confidence and ensure it reaches the clinician.
Lowers confidence and appends a recommendation for human review when the system detects borderline or ambiguous findings.
About This Project
VLM-Guard was built from the ground up to solve a fundamental problem: LLMs in medicine are probabilistic, but patient safety cannot be. Rather than trying to make models hallucinate less (fine-tuning, prompting tricks), VLM-Guard adds a deterministic post-generation verification layer. Every output is parsed into structured claims, validated against rule-based guardrails, and either accepted, corrected, or blocked — with a full audit trail of every decision. This is the safety substrate powering HeartSafe RAG, NTD-Assist, and MedVision Assist.
Key Features
- Composable rule engine with 4 action types (Block / Correct / Promote / Flag)
- Two rule classes: BaseRule (per-claim) and CrossClaimRule (multi-claim consistency)
- Full audit trail serializable via AuditTrail.to_dict()
- Built-in ImageEnhancer with domain-specific strategies
- Image quality checks: blur, exposure, grayscale validation
- Plugin system for domain-specific rule packs (NTD microscopy, cardiology, radiology)
- Model-agnostic: any multimodal LLM or text-only LLM
- Pydantic-based Analysis schema with typed validation
Impact
- →Powers safety for 3 production clinical AI applications
- →Published to PyPI: pip install vlm-guard
- →Deterministic safety layer — not probabilistic, not fine-tuning dependent
- →Full audit trail enables regulatory compliance and post-hoc review
- →Plugin architecture enables community-contributed domain rule packs
Technology Stack
Related articles
Building a clinical AI system of your own?
The Clinical AI Reliability Audit applies the same kind of evaluation and safety engineering to your system: architecture and risk discovery, evaluation and root cause analysis, and targeted engineering improvements. For a working healthcare app built with AI coding tools, the Clinical Prototype Readiness Review is the smaller starting point.
Related Projects
This project is part of a connected ecosystem. Each piece reinforces the same mission: safe, trustworthy clinical AI.
JevGuard
A real-time safety check for medical chatbot answers: a fast System One model (TypeSafe's Jev) score...
HeartSafe RAG
A retrieve-or-refuse Retrieval-Augmented Generation system for heart failure clinical decision suppo...
NTD-Assist
An offline multimodal AI prototype for microscopy-based NTD screening, with 12 rule-based biological...
Telehealth Distress Analyzer
An automated acoustic analysis pipeline that detects vocal biomarkers of distress from telehealth re...
MedVision Assist
A Clinical Decision Support System for radiologists that drafts 90%-complete preliminary imaging rep...
Prescription Validator Agent
A hybrid neuro-symbolic AI agent that validates pharmacy insurance claims by extracting structured d...