Stage 7 · Master
RAG Over Your Ops Knowledge
Why RAG for Operations
Grounding, freshness, and citing the runbook instead of guessing.
The Problem with Bare LLMs
A vanilla LLM has no knowledge of your infrastructure. It does not know your service names, your runbook procedures, your incident history, or your deployment patterns. It generalizes from training data, which is outdated and generic.
If you ask a bare LLM how to failover your Redis cluster, it will give you a plausible-sounding answer based on common Redis patterns. That answer might reference commands that do not exist in your version, or procedures that conflict with your actual runbook.
What Is RAG?
Retrieval-Augmented Generation (RAG) connects an LLM to your actual knowledge base. Instead of answering from memory, the model retrieves relevant documents from your runbooks, incident history, and documentation, then uses those documents as context for its answer.
def rag_answer(question):
# Step 1: Retrieve relevant documents
relevant_docs = vector_db.search(question, top_k=5)
# Step 2: Build context from retrieved docs
context = "\n---\n".join([doc.text for doc in relevant_docs])
# Step 3: Generate answer grounded in context
response = openai.ChatCompletion.create(
model="gpt-4",
messages=[
{"role": "system", "content": "Answer based ONLY on the provided context. Cite the source document."},
{"role": "user", "content": f"Context:\n{context}\n\nQuestion: {question}"}
]
)
return response["choices"][0]["message"]["content"]RAG is straightforward: retrieve, augment the prompt with retrieved context, and generate. The key is the quality of your retrieval step.
The RAG Pipeline
- Ingestion — Parse and chunk your runbooks, docs, and postmortems into searchable pieces.
- Embedding — Convert each chunk into a vector using an embedding model.
- Indexing — Store vectors in a vector database with metadata.
- Retrieval — Embed the user query and find the most similar chunks.
- Augmentation — Inject retrieved chunks into the LLM prompt as context.
- Generation — The LLM generates an answer grounded in the retrieved context.
Why Grounding Matters
Grounding means the model's answer is based on real, retrieved documents rather than the model's training data. This dramatically reduces hallucination because the model is working with factual, up-to-date information.
When a RAG system cites the specific runbook section or incident report it used, you can verify the answer. Always require citation in your operational RAG prompts.
Freshness Without Retraining
Retraining an LLM is expensive and slow. RAG gives you freshness by updating the knowledge base instead of the model. When you update a runbook, the next retrieval picks up the change immediately.
| Approach | Update Speed | Cost | Accuracy |
|---|---|---|---|
| Fine-tuning | Days to weeks | High | Domain-specific but static |
| RAG | Seconds to minutes | Low | Always uses latest docs |
| Prompt engineering | Immediate | Low | Limited by context window |
RAG is simpler, cheaper, and more maintainable than fine-tuning for most operational use cases. Only consider fine-tuning when RAG cannot capture the behavior you need.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.