Home Knowledge Base Negative Caching

Negative Caching in RAG (Retrieval-Augmented Generation) stores query-document pairs that resulted in no relevant matches to avoid repeated futile searches.

What Is Negative Caching?

Why Negative Caching Matters

Without negative caching, repeated queries for non-existent information trigger expensive retrieval operations every time.

<svg viewBox="0 0 485 378" xmlns="http://www.w3.org/2000/svg" style="max-width:100%;height:auto" role="img"><rect x="0" y="0" width="485" height="378" rx="12" fill="#0d1117"/><g font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,&quot;Liberation Mono&quot;,monospace" font-size="14"><text xml:space="preserve" x="20" y="31.7"><tspan fill="#c9d1d9">RAG with Negative Caching:</tspan></text><text xml:space="preserve" x="20" y="50.7"><tspan fill="#c9d1d9">First Query: "Quantum teleportation protocol specs"</tspan></text><text xml:space="preserve" x="20" y="69.7"><tspan fill="#c9d1d9">                    </tspan><tspan fill="#6e7681">│</tspan></text><text xml:space="preserve" x="20" y="88.7"><tspan fill="#c9d1d9">                    </tspan><tspan fill="#6e7681">▼</tspan></text><text xml:space="preserve" x="20" y="107.7"><tspan fill="#c9d1d9">            [Vector Search] </tspan><tspan fill="#6e7681">→</tspan><tspan fill="#c9d1d9"> No relevant docs</tspan></text><text xml:space="preserve" x="20" y="126.7"><tspan fill="#c9d1d9">                    </tspan><tspan fill="#6e7681">│</tspan></text><text xml:space="preserve" x="20" y="145.7"><tspan fill="#c9d1d9">                    </tspan><tspan fill="#6e7681">▼</tspan></text><text xml:space="preserve" x="20" y="164.7"><tspan fill="#c9d1d9">            [Add to negative cache]</tspan></text><text xml:space="preserve" x="20" y="183.7"><tspan fill="#c9d1d9">                    </tspan></text><text xml:space="preserve" x="20" y="202.7"><tspan fill="#c9d1d9">Second Query: "Quantum teleportation protocol specs"</tspan></text><text xml:space="preserve" x="20" y="221.7"><tspan fill="#c9d1d9">                    </tspan><tspan fill="#6e7681">│</tspan></text><text xml:space="preserve" x="20" y="240.7"><tspan fill="#c9d1d9">                    </tspan><tspan fill="#6e7681">▼</tspan></text><text xml:space="preserve" x="20" y="259.7"><tspan fill="#c9d1d9">            [Check negative cache] </tspan><tspan fill="#6e7681">→</tspan><tspan fill="#c9d1d9"> HIT</tspan></text><text xml:space="preserve" x="20" y="278.7"><tspan fill="#c9d1d9">                    </tspan><tspan fill="#6e7681">│</tspan></text><text xml:space="preserve" x="20" y="297.7"><tspan fill="#c9d1d9">                    </tspan><tspan fill="#6e7681">▼</tspan></text><text xml:space="preserve" x="20" y="316.7"><tspan fill="#c9d1d9">            [Skip retrieval, return cached "no docs"]</tspan></text><text xml:space="preserve" x="20" y="335.7"><tspan fill="#c9d1d9">            </tspan></text><text xml:space="preserve" x="20" y="354.7"><tspan fill="#c9d1d9">Saves: Vector DB query + embedding computation</tspan></text></g></svg>

Implementation Considerations:

ParameterTypical ValueReason
Cache TTL1-24 hoursAllow index updates
Key formatQuery hashExact match lookup
Max entries10K-100KMemory budget
InvalidationOn index updateFreshness
negative cachingrag cacheno results cache

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.