Coding Now – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 9667708830
Back to Generative AI Notes
Topic #1102

RAG Architecture

RAG architecture splits cleanly into two phases: an offline ingestion phase (done once, or whenever content changes) and an online query phase (done for every user question) — understanding this split clarifies what needs to be fast/cheap versus what can be done ahead of time.

Two Distinct Phases

OFFLINE — INGESTION (runs once per document, or on content updates)
  Document → extract text → chunk → embed → store in vector DB

ONLINE — QUERY (runs on every single user question)
  User question → embed → search vector DB → retrieve top-k chunks
  → build prompt with retrieved context → LLM generates answer

The expensive, batch-friendly work (processing potentially thousands of documents) happens offline, ahead of time. The query-time path only needs to embed one short question and search an already-built index — this is why RAG can feel fast to users even though document processing itself takes real time.

Components Involved

ComponentRole
Document loader / parserExtracts raw text from source documents (PDFs, web pages, etc.) — see Document Processing
ChunkerSplits text into retrieval-sized pieces — see Document Chunking
Embedding modelConverts chunks (and queries) into vectors — see Embedding Models
Vector databaseStores vectors and serves similarity search — see Vector Database
RetrieverThe logic that queries the vector DB and returns relevant chunks — see Vector Retrieval
LLMGenerates the final answer using retrieved context — see RAG Prompt

Practical Use Case

Understanding the offline/online split matters for real system design: content update frequency (how often ingestion needs to re-run), and query latency budget (what has to happen fast, within a user's request) are two separate engineering concerns that this architecture split makes explicit.

Common Mistakes

  • Re-processing (parsing, chunking, embedding) documents on every query instead of once during ingestion — a serious, avoidable latency and cost problem
  • Not planning for how content updates propagate — if a source document changes, stale chunks need to be identified and re-ingested, not just silently left outdated

Interview Relevance

"Why doesn't RAG re-process the entire document collection on every user query?" — because ingestion (parsing, chunking, embedding, storing) happens offline, ahead of time; only the query itself is embedded and searched at request time.

Practice Question

Sketch which parts of a RAG system need to run in real time (within a user's request) versus which can run as a background/batch process.

Related Notes

Want to go beyond the notes?

Join CodingNow's Generative AI course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →