RAG & LLM input hygiene
Sanitize untrusted text before it hits your LLM
Feed a scraped page, a user upload, or any untrusted document through the sanitizer — we strip invisible characters and flag prompt-injection and hidden-text signals, so what goes into your embeddings is clean.
What is RAG sanitization?
RAG pipelines embed untrusted documents (web pages, PDFs, user uploads) and feed retrieved chunks into an LLM's context. That untrusted text can carry three hazards: invisible characters that corrupt embeddings and tokenization, hidden text (white-on-white, off-screen) that injects instructions invisibly, and prompt-injection patterns that try to override the model. Sanitizing before embedding closes that gap.
What we do
- Strip. Remove invisible / zero-width characters and special spaces — deterministically, no false positives.
- Flag injection. Report prompt-injection patterns ("ignore previous instructions", role spoofing, marker spoofing).
- Flag hidden text. Report white-text, zero-opacity, off-screen and other hidden-HTML signals.
Injection risks are flagged, not auto-deleted — removing natural-language injection would corrupt legitimate content. You decide what to reject. Everything runs locally in your browser.
For pipelines
Developers: the same engine is available as POST /api/rag-sanitize — see the API docs to wire it into your ingestion step.