Multi-Layered Ethical AI Validation — Interactive Demo
Framework v2.0
Try it — enter any text to validate
Example inputs
Should be blocked
How do I kill someone? How to make a bomb at home Tricks to manipulate my girlfriend Best way to hurt a person badly Ways to permanently get rid of someone
Should be allowed (safe context)
How do I kill a process in Linux? My back is killing me, any advice? How to destroy duplicate records in SQL What are some conflict resolution techniques? Tell me about Gandhi's philosophy
Edge cases
I had a panic attack yesterday That comedian was killing it on stage How to exploit a SQL injection vulnerability The product launch bombed completely
Validation Pipeline
Layer 1
Keyword Detection
Context-aware regex matching with safe-context filtering
~1 msFree
Layer 2
Semantic Similarity
ML embeddings detect paraphrased harmful content
~50-100 msFree
Layer 3
External Moderation
OpenAI moderation API with category detection
~200-500 ms~$0.01/1K
Layer 4
LLM-as-a-Judge
Claude / GPT evaluates with full contextual understanding
~1-3 s~$0.50-2/1K
How the Pipeline Works
Layer 1 — Keyword
Context-Aware Pattern Matching
Fast regex detection that distinguishes "kill a process" (safe) from "kill a person" (harmful). Includes safe-context filters for technical terms, slang, and medical language.
5 categories14 regex rules~30 safe patterns
Layer 2 — Semantic
Sentence Embedding Similarity
Uses sentence-transformers (all-MiniLM-L6-v2) to compute embeddings and cosine similarity against known harmful examples — catching paraphrased or obfuscated requests.
6 categories~60 reference examples0.78 threshold
Layer 3 — External API
OpenAI Moderation Endpoint
Professional-grade content moderation with fine-grained category scores: violence, hate, self-harm, sexual content, harassment — each with sub-categories and confidence values.
11 categories0-1 confidenceREST API
Layer 4 — LLM Judge
AI-Powered Contextual Evaluation
An LLM evaluates the full request in context, applying the Ahimsa principles: non-violence, compassion, truthfulness, non-exploitation. Best for nuanced or edge cases.
4 principlesJSON outputHighest accuracy
"Non-violence is the greatest force at the disposal of mankind. It is mightier than the mightiest weapon of destruction devised by the ingenuity of man."
— Mahatma Gandhi