AI Hints
Home›RAG Tutorial›First Steps
RAG · Lesson 6 of 120

RAG by Hand

Paste the facts in.

⏱ 2 min read▶ Video at 5:06🎓 Free
Watch this lesson in the RAG courseWatch on YouTube ↗Full RAG course

Before we automate anything, let's do RAG by hand. We copy the right paragraph from the shop's shipping page, paste it into the prompt, and ask our question. That's all RAG really is.

RAG by Hand
From the video: RAG by Hand
  • Copy the facts
  • Paste into the prompt
  • Ask the question

Facts in the prompt

The facts variable holds a paragraph from the shipping page. The prompt tells the model to answer using only these facts. Then it asks about next day delivery. Run it. Now the model gives the shop's real price, because we gave it the facts.

rag_by_hand.pypython
from langchain.chat_models import init_chat_model

llm = init_chat_model("google_genai:gemini-flash-lite-latest", temperature=0)

facts = """Next-day delivery is available for parts and accessories ordered
before 1pm, for £7.99. It is not available for bikes."""

prompt = f"""Answer using only these facts.
Facts: {facts}
Question: How much does next-day delivery cost? One sentence."""
print(llm.invoke(prompt).text.strip())
Output
Next-day delivery costs £7.99.

What we did by hand

We did three things by hand. We chose the right paragraph. We built a prompt with it. And we asked the model. The rest of this course is about doing the first step automatically, and doing it well.

keyvalue
Retrievewe picked the paragraph
Augmentwe built the prompt
Generatethe model answered
Nextautomate retrieval

Summary

RAG by hand means pasting the right facts into the prompt. The hard part is finding the right facts automatically. Next, meet our knowledge base.

Key takeaways
  • Pick the facts
  • Build the prompt
  • Model answers
Next up: Meet the Knowledge Base — Northwind Bikes