Why is the claim 'you need LangChain to do RAG' wrong, and when does LangChain earn its keep in a RAG pipeline?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
An engineer insists you need LangChain to do RAG. Refute that claim concretely. Describe the minimum viable RAG pipeline and then say when LangChain (or LlamaIndex) does actually earn its keep on top of it.
Minimal RAG is four steps (embed, retrieve, format, complete) in 80 lines with no framework.
Picture a kid claiming you need a kitchen to make a sandwich. You point out that bread, peanut butter, and a knife do the job. They are right that the kitchen helps once you want to make ten different sandwiches with toasted bread and a side soup. But the kitchen is not the sandwich. RAG is the same. The 'kitchen' is the framework. The 'sandwich' is the four steps. Confusing the two leads teams to import five megabytes of code to do something the standard library could do in a screen of code.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 minutes: state the four-step minimal pipeline, name a vector store concretely, list the complexity classes that flip the framework calculus, and frame the production answer as 'piecemeal adoption when buying something with the tax'.
# Minimum viable RAG: no framework, ~30 lines
from openai import OpenAI
import pinecone
client = OpenAI()
index = pinecone.Index('my-index')
def rag(question: str, k: int = 5) -> str:
# 1. Embed
q_vec = client.embeddings.create(
model='text-embedding-3-small', input=question
).data[0].embedding
# 2. Retrieve
matches = index.query(vector=q_vec, top_k=k, include_metadata=True).matches
chunks = [m.metadata['text'] for m in matches]
# 3. Format
context = '\n\n'.join(f'[{i+1}] {c}' for i, c in enumerate(chunks))
prompt = f'Answer using ONLY the context. If unsure, say so.\n\nContext:\n{context}\n\nQuestion: {question}'
# 4. Complete
resp = client.chat.completions.create(
model='gpt-4o-mini',
messages=[{'role': 'user', 'content': prompt}],
)
return resp.choices[0].message.content
print(rag('What is the company refund policy?'))Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Mistaking framework popularity for framework requirement. The framework being widely used does not mean the underlying technique depends on it.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.