🤖 The Modern AI Developer · Context Engineering: Feed the AI Exactly the Right Info

What Is RAG? Retrieval-Augmented Generation in Plain English

Let it look things up before answering, instead of guessing from memory

一句话先懂 · TL;DR

RAG explained in three steps: retrieve, stuff into context, answer. Learn why letting the model look things up beats guessing and cuts made-up answers.

Answering from Memory vs. Open-Book

The AI holds a huge amount of knowledge, but its memory is fuzzy and can be out of date—especially your company's internal docs and the latest data, which it never learned at all. Force it to answer and it can only make things up from a vague impression.

🔆It's like hitting a question you don't know on a closed-book exam—you can only guess. RAG turns it into an open-book exam: first pull out the few relevant pages and put them on the desk, then let it answer from those.

RAG in Three Steps: Find → Stuff → Answer

RAG (retrieval-augmented generation) sounds fancy, but it's just three steps:

1. Find: based on your question, search the knowledge base for the few most relevant passages.
2. Stuff: put those passages into the context (onto the AI's desk).
3. Answer: have the AI answer based on those passages.

def answer_with_rag(question):
    docs = search(question)        # 1. 找:搜出相关资料
    context = "\n".join(docs)      # 2. 塞:拼进上下文
    prompt = f"参考资料:\n{context}\n\n问题:{question}"
    return llm(prompt)             # 3. 答:基于资料回答

Why RAG Reduces Made-Up Answers

AI making things up (the technical term is hallucination) often happens because the answer isn't on its desk and it's forced to say something anyway.

💡The beauty of RAG: put real material in front of it and it has something to go on, no need to invent (provided retrieval is accurate and the model actually answers from the material; if retrieval is wrong or it ignores the material, it can still get things wrong). You can even have it note "this line comes from passage N" so you can check.

In one line: RAG doesn't make the AI smarter—it lets it see the answer before it speaks.

自测 · 学完检查一下

想真正动手做题、记进度、攒连胜?到互动课里练。

RAG turns the AI's answering from "closed-book" into what?

答案:An open-book exam: look things up before answering

The core of RAG is retrieving the relevant material first, putting it in context, then having the AI answer from it—just like an open-book exam.

Remember RAG's three steps as: find → ___ → answer (put the retrieved material into the context).

答案:stuff

The middle step is "stuff": put the retrieved relevant material into the context, onto the AI's desk, so it can see it.

Judge: a question like "what exactly is our company's return policy?"—which depends on internal material—is well suited to RAG (look up first, then answer).

答案:True

Internal rules and the latest data are things the model never learned; you must retrieve real material and feed it in, otherwise it can only make things up.

Which question least needs RAG (the model's own general knowledge answers it well)?

答案:Translate this passage from Chinese to English

Translation relies on the model's general ability, not on the latest external material; the others all depend on internal/up-to-date info you'd only know by looking it up.

When the AI has nothing to go on and fabricates a plausible-looking answer, this phenomenon is technically called "___."

答案:hallucination

"Hallucination" is the model fabricating content with a straight face. RAG reduces it by providing real material first so it has something to go on.

Judge: the essence of RAG is making the model smarter, not providing it with material.

答案:False

RAG doesn't change the model itself—it just "lets the AI see the answer before speaking," reducing made-up answers by providing real material.

想边练边学,而不只是读?

到互动课里答题、记进度、攒连胜——游客即可试学,无需注册。

进入互动课程 →

Learn something new — don't miss updates

New courses, features and learning tips. Occasional emails, unsubscribe anytime.