Skip to main content

Overview

Prompt Inspector employs a multi-layer funnel architecture — a cascading pipeline where each successive layer performs deeper, more sophisticated analysis. This design philosophy, called “Global Detection, Local Decision”, ensures that obvious threats are caught instantly while complex adversarial inputs undergo thorough examination. The funnel approach is fundamentally different from single-model detection systems. Instead of relying on one technique, Prompt Inspector orchestrates multiple specialized layers that complement each other, dramatically reducing blind spots.

Architecture Diagram

Layer Details

Layer 1: Global Hash Cache

Every incoming text is hashed and checked against a distributed cache. If the exact same input (per tenant) has been analyzed before, the cached result is returned immediately — completely bypassing all downstream layers. This layer ensures that repeated inputs (common in production environments) are handled with near-zero latency.

Layer 2: Custom Sensitive Word Matching

Each tenant can define their own sensitive word lists with two matching strategies:
  • Literal matching — Uses an Aho-Corasick automaton, an advanced multi-pattern string matching algorithm that scans the entire input in a single pass with linear time complexity, regardless of how many keywords are configured.
  • Regex patterns — Supports regular expression patterns for more flexible matching rules (e.g., phone numbers, credit card patterns).
When a sensitive word is matched, the pipeline short-circuits immediately — no further layers are invoked. This makes the sensitive word layer both a safety net and a performance optimization.

Layer 3: Semantic Vector Analysis

For inputs that pass the keyword layer, the system performs deep semantic analysis:
  1. The input text is split into overlapping chunks using a sliding window (to handle long texts and prevent edge-case evasion at chunk boundaries).
  2. Each chunk is converted into a high-dimensional vector embedding.
  3. The embeddings are searched against a curated threat vector database using approximate nearest neighbor (ANN) search.
  4. Similarity scores determine the threat level.
This layer catches semantically similar attacks even when the exact wording differs from known patterns — including paraphrased, translated, or obfuscated prompt injections.

Layer 4: AI Review (Optional)

When the semantic analysis produces a score in the gray zone — not clearly safe and not clearly malicious — an AI review layer is invoked for a more nuanced assessment. This layer acts as a tie-breaker, providing intelligent judgment for ambiguous cases. When a new threat pattern is confirmed, the system automatically generates variants and feeds them back into the vector database, continuously strengthening the detection capability over time.

Layer 5: Arbitration & Response Assembly

The final layer aggregates results from all upstream layers, selects the highest-confidence threat category and score, and assembles the response:
  • Category — The detected threat type(s) (e.g., prompt_injection, custom_sensitive_word)
  • Score — A confidence value from 0.0 (safe) to 1.0 (certain threat)
  • is_safe — A boolean shorthand: true when no threats are detected
Results are cached before being returned, ensuring subsequent identical requests benefit from Layer 1.

Design Advantages

Defense in Depth

Multiple independent detection techniques ensure no single point of failure. An attack that evades one layer is likely caught by another.

Early Termination

The funnel design means obvious threats are caught in the fastest layers first. Only genuinely ambiguous inputs reach the slower, more expensive layers.

Self-Improving

Confirmed new threats are automatically augmented and added to the vector database, meaning the system gets stronger with every attack it encounters.

Tenant Isolation

Each tenant has isolated sensitive word configurations, rate limits, and detection logs — ensuring one customer’s rules never affect another.

What This Means for Developers

You don’t need to understand the internal architecture to use Prompt Inspector. Simply send text to the API and receive a clear safe/unsafe verdict with a confidence score. The multi-layer design works behind the scenes to ensure:
  • Broad coverage — Catches keyword-based, semantic, and novel attack patterns
  • Customizability — Your own sensitive words are checked before any other analysis
  • Efficiency — Most requests are resolved in the fastest layers, keeping costs and latency low
  • Continuous improvement — The threat database evolves automatically without any action on your part

Get Started

Ready to integrate? Follow the Quick Start guide to begin protecting your LLM applications.