30 Days of AIDay 13 of 30 · Week 2: Applied AI & APIs
Course outline▾

Week 3 · Infrastructure & Hosting

  1. Day 15Introduction to AI Infrastructure: Hardware, Runtimes, and ComputeComing soon · 2026-10-15 · 7 PM IST
  2. Day 16Local Model Execution: Running Open-Weight LLMs Securely (Ollama, vLLM)Coming soon · 2026-10-16 · 7 PM IST
  3. Day 17Containerizing AI Workloads: Writing Production Dockerfiles for Python APIsComing soon · 2026-10-17 · 7 PM IST
  4. Day 18Docker Compose for Multi-Container AI Stacks (Web UI, Vector DB, LLM Engine)Coming soon · 2026-10-18 · 7 PM IST
  5. Day 19Kubernetes for AI 101: Pods, Deployments, and Services for Model ServingComing soon · 2026-10-19 · 7 PM IST
  6. Day 20Persistent Storage in Kubernetes: Managing State, Weights, and Vector IndicesComing soon · 2026-10-20 · 7 PM IST
  7. Day 21High-Performance Networking: Configuring Ingress and Egress for AI ClustersComing soon · 2026-10-21 · 7 PM IST

Week 4 · Enterprise Workflows

  1. Day 22Autonomous Agents: From Passive LLMs to Goal-Driven ExecutionComing soon · 2026-10-22 · 7 PM IST
  2. Day 23Tool Use & Function Calling: Connecting LLMs to APIs, Databases, and ShellsComing soon · 2026-10-23 · 7 PM IST
  3. Day 24Multi-Agent Orchestration: Supervisor, Worker, and Evaluator PatternsComing soon · 2026-10-24 · 7 PM IST
  4. Day 25Automated CI/CD: Automating the Software Lifecycle for AI ModelsComing soon · 2026-10-25 · 7 PM IST
  5. Day 26Zero-Trust Security for AI: Sandboxing Ephemeral Execution & Model EgressComing soon · 2026-10-26 · 7 PM IST
  6. Day 27Observability & Tracing for Agentic Systems (Telemetry, Logs, and Metrics)Coming soon · 2026-10-27 · 7 PM IST
  7. Day 28Human-in-the-Loop Architecture: Machine Second, Human First in PracticeComing soon · 2026-10-28 · 7 PM IST
  8. Day 29Managing Technical Debt, Drift, and Model Governance in Enterprise ITComing soon · 2026-10-29 · 7 PM IST
  9. Day 30The 10-Year Horizon: Architecting IT Strategy for the AI-Native EnterpriseComing soon · 2026-10-30 · 7 PM IST
Open the course page →

Day 13: Retrieval-Augmented Generation (RAG) — Chatting with Proprietary Documents

2026-10-13 · 7 min read

A language model only knows what it was trained on, and that stopped at a fixed date. It has never read your internal wiki, your tickets or this morning's incident report. Retrieval-Augmented Generation (RAG) is the architecture that lets it answer questions about your own, up-to-date documents, without retraining the model.

In plain terms: An open-book exam. Instead of making the student memorise the whole library, you let them look up the right pages first, then write the answer from those pages.

An LLM only knows what it was trained on LLM aloneTrained months agoNever saw your documentsGuesses or says noLLM + RAGLooks up your documentsat question timeAnswers from the factsNo retraining. Update a document and the answers update.RAG means Retrieval-Augmented Generation.
A language model is frozen at its training date and has never seen your private documents. RAG looks them up when a question arrives and gives them to the model, so no retraining is needed and updated documents change the answers.

RAG chains together the two previous lessons: embeddings give every paragraph a position by meaning, and a vector database finds the closest ones fast. Then the LLM does what it is best at, which is writing a clear answer.

RAG in three steps 1. Ingestchunk, embed, store2. Retrievefind the top 3 paragraphs3. Generateanswer from that context Step 1 happens ahead of time. Steps 2 and 3 happen on every question.
RAG has three steps: ingest your documents by chunking, embedding and storing them, retrieve the most relevant paragraphs for each question, then generate an answer from that retrieved context.

Step 1: Ingestion

Ahead of time, your private documents are split into chunks (paragraph-sized pieces), each chunk is converted into an embedding, and the vectors are stored in a vector database. Chunk size is a real design decision. Chunks that are too big blur the meaning, and chunks that are too small lose the surrounding context.

Step 1: Ingestion Documents PDFs, wikis, tickets Chunks short paragraphs Embeddings a vector per chunk Vector DB stored and indexed Chunk size matters: too big blurs meaning, too small loses context.
Ingestion splits your documents into chunks, converts each chunk into an embedding, and stores the vectors in a vector database. Chunk size is a trade-off: large chunks blur meaning and tiny chunks lose context.

Step 2: Retrieval

When a user asks a question, that question is embedded as well. The vector database runs a similarity search and returns the top few most relevant paragraphs. Three is a common starting point, and you tune it for your documents.

Step 3: Augmented generation

The retrieved paragraphs are injected into the LLM's prompt, together with an instruction: "Answer the user's question using ONLY the following retrieved context." The model writes its answer from the supplied facts instead of from memory.

Step 3: the augmented prompt Instruction: answer using ONLY the context below.Context (retrieved)1. Latency rose after the 14:05 deploy.2. Rollback restored normal latency.3. The web tier autoscales at 70% CPU.Question: Why did the site slow down yesterday?Answer: a deploy at 14:05 raised latency;a rollback restored it.
The retrieved paragraphs are injected into the prompt with an instruction to answer using only that context. The model then writes its answer from the supplied facts instead of from memory. The example text is illustrative.

Here is the whole loop in Python. The embed, search and llm functions stand in for your embedding model, your vector database and your LLM API, so you can plug in the ones you use.

def answer(question: str) -> str:
    # 2. Retrieval: embed the question and fetch the 3 closest chunks
    query_vector = embed(question)
    chunks = search(query_vector, top_k=3)

    # 3. Augmented generation: put the chunks in the prompt
    context = "\n".join(f"- {c}" for c in chunks)
    prompt = (
        "Answer the question using ONLY the context below. "
        "If the context does not contain the answer, say you don't know.\n\n"
        f"Context:\n{context}\n\nQuestion: {question}"
    )
    return llm(prompt)

# 1. Ingestion (run ahead of time, and again whenever documents change)
for chunk in split_into_chunks(load_documents()):
    store(embed(chunk), chunk)

Notice the "say you don't know" rule. It gives the model a safe way out when retrieval finds nothing useful. Tomorrow's lesson covers what happens when retrieval goes wrong, and how to measure it.

Coming Up Next

Day 14: RAG evaluation and hallucination guardrails.

#RAG #GenerativeAI #EnterpriseAI #SoftwareEngineering #AIImplementation