Input & Output Filtering
Filtering
Part of: Guardrails & Safety
You cannot trust the model to police itself, because the model is the thing being attacked. So you wrap it. Input filtering inspects what goes in before the model sees it; output filtering inspects what comes out before anyone acts on it. Together they form the two gates of a guardrail sandwich, with the model in the middle. What it is A filter (also called a guardrail) is code or a separate classifier that sits outside the model and checks text against rules. It runs before the model on inputs and after the model on outputs. Crucially, a filter is deterministic logic you control, not another prompt you hope the model respects. The structure is a sandwich: Each gate can allow , block , or sanitize (strip the bad part and pass the rest). The model never gets to override these gates because they live in your application code, not in its context. How it works Input filtering catches problems before they cost you a model call or reach the model at all: - Block known injection patterns ("ignore previous instructions"). - Reject inputs that are too long, malformed, or off-topic. - Strip or escape suspicious markup before it reaches the prompt. Output filtering is the more important gate,
Challenge: Allowlist Output Validator