Skip to main content

RAG

System Analysis

AI & Agent SystemsPRODUCTION

Normal Behavior

Retrieves highly relevant context to ground AI outputs in factual reality.

Failure Behavior

Fetches three-year-old Slack messages about lunch to answer critical customer billing questions.

Business Consequence

The AI confidently instructs users to reset their routers instead of issuing a refund.

Visual Manifestation

"A worried fetch-dog carrying a mouth full of crumpled, irrelevant post-it notes."

Satirical Behavior

"A very complicated way to do a Google search and then have a robot paraphrase the first three links."

Known Aliases

Retrieval-Augmented GenerationVector SearchSemantic SearchContext Retrieval

Technical Terminology

vector databaseembedding modelsimilarity searchcosine similaritychunking strategycontext windowdocument retrievalknowledge basegroundinghybrid search

Failure Indicators

hallucinationcontext overflowirrelevant retrievalstale embeddingslost in the middle

System Architecture (Graph)

Click or hover to interact

Used By (Characters)

FAQ

How does it normally behave?

Retrieves highly relevant context to ground AI outputs in factual reality.

How does it fail?

Fetches three-year-old Slack messages about lunch to answer critical customer billing questions.

What is the business consequence?

The AI confidently instructs users to reset their routers instead of issuing a refund.

Why is Hybrid Search (combining dense vector search with sparse BM25 keyword search) critical for production RAG systems?

Dense vector embeddings excel at understanding conceptual semantics and natural language queries, but struggle with precise keyword matching, such as product SKUs, exact error codes, API function names, and proper nouns. Sparse BM25 lexical search provides exact keyword precision; combining both via Reciprocal Rank Fusion (RRF) ensures the pipeline retrieves both semantically relevant passages and exact keyword matches.

What is the 'Lost in the Middle' phenomenon in RAG context injection and how do modern architectures solve it?

The 'Lost in the Middle' problem occurs because transformer attention mechanisms preferentially attend to tokens located at the extreme beginning and end of long context windows. When multiple retrieved passages are concatenated, critical facts placed in the center are frequently overlooked. Modern RAG architectures solve this using cross-encoder rerankers to filter out irrelevant chunks and strategically place the highest-scoring passages at the top and bottom of the injected context.

AI Summary

RAG (Retrieval-Augmented Generation) is a AI_AND_AGENT_SYSTEMS system in TinyCTO.tv. During document ingestion, knowledge sources are parsed, chunked, and converted into dense vector embeddings stored in a vector index alongside sparse keyword indices. When a user submits a query, the RAG pipeline executes hybrid semantic and lexical search, reranks candidate passages using a cross-encoder, constructs an augmented prompt containing verified context, and instructs the LLM to synthesize an accurate, cited response.