RAG for Beginners: Teach Your AI to Read Your Own Docs (With Simple Examples)
I'll be honest with you. I've been putting off RAG for a while. Every time I opened an article about it, I saw words like embeddings , vector databases and chunking strategies in the first paragraph, and I quietly closed the tab. 😅 This time I finally sat down and built something small. And here's

I'll be honest with you. I've been putting off RAG for a while.
Every time I opened an article about it, I saw words like embeddings, vector databases and chunking strategies in the first paragraph, and I quietly closed the tab. 😅
This time I finally sat down and built something small. And here's what I learned: the idea behind RAG is simple. The hard part is the details.
So in this article, I'll walk you through RAG the way I wish someone had explained it to me: plain English, small examples, and one tiny working demo. I'm still learning too, so we're doing this together. 🤝
Large language models (LLMs) like Claude or GPT are smart, but they have three annoying limits:
"How many paid leave days do I get at my company?"
It has no idea. So it either says "I don't know" or, worse, invents a believable number. 😬
My favorite analogy is an open-book exam. 📚
There are two phases. Think of them as "prepare the library" and "answer the question."
This was the part that confused me the most, so let me make it simple.
An embedding turns text into numbers so that similar meanings end up close together.
For example, these two sentences use totally different words:
A plain keyword search might miss the connection. But their embeddings land very close to each other, because the meaning is similar.
That's why RAG feels smarter than a normal search box. It searches by meaning, not just by matching words. 🎯
A common starting point is chunks of a few hundred words, with a small overlap between neighbors, so a sentence cut in half still makes sense. There's no magic number, though. You'll tune it based on your content.
Let's say your company has this tiny handbook:
An employee asks: "Can I work from home 4 days a week?"
1.Embeds the question. 2.Finds the closest chunk: "Work from home is allowed up to 2 days per week." 3.Builds a prompt like this:
Answer the question using ONLY the context below. If the answer isn't in the context, say you don't know. Context: Work from home is allowed up to 2 days per week. Question: Can I work from home 4 days a week? Enter fullscreen mode Exit fullscreen mode 4.The LLM replies: "No, the policy allows up to 2 work-from-home days per week." ✅
Notice the line "say you don't know." That small instruction is a powerful way to reduce made-up answers.
Let's build the smallest possible version. No vector database, no framework. Just enough to see the idea working.
pip install sentence-transformers numpy anthropic Enter fullscreen mode Exit fullscreen mode Step 1: Our "documents" and the embeddings from sentence_transformers import SentenceTransformer import numpy as np # A small, free embedding model that runs on your machine model = SentenceTransformer ( "all-MiniLM-L6-v2" ) docs = [ "Full-time employees get 24 paid leave days per year.", "Work from home is allowed up to 2 days per week.", "Laptop repairs must be requested through the IT portal.", "The office is closed on public holidays.", ] # Turn every doc into a vector (normalized, so a dot product = cosine similarity) doc_vectors = model. encode ( docs, normalize_embeddings = True ) Enter fullscreen mode Exit fullscreen mode Step 2: Retrieval (find the closest chunks) def retrieve ( question: str, top_k: int = 2 ) -> list [ str ]: question_vector = model. encode ( [ question ], normalize_embeddings = True ) [ 0 ] scores = doc_vectors @ question_vector # similarity score for each doc best_indexes = np. argsort ( scores ) [::- 1 ] [: top_k ] # highest scores first return [ docs [ i ] for i in best_indexes ] Enter fullscreen mode Exit fullscreen mode Step 3: Augment and generate import anthropic client = anthropic. Anthropic ( ) # reads ANTHROPIC_API_KEY from your environment def ask ( question: str ) -> str: context = "\n". join ( retrieve ( question ) ) prompt = f """Answer the question using ONLY the context below. If the answer isn't in the context, say you don't know.
Context: {context} Question: {question}""" response = client. messages. create ( model = "claude-sonnet-5-5", # use any current model you have access to max_tokens = 300, messages = [ { "role": "user", "content": prompt } ], ) return response. content [ 0 ]. text print ( ask ( "Can I work from home 4 days a week?" ) ) Enter fullscreen mode Exit fullscreen mode That's a complete RAG loop: embed → retrieve → augment → generate. 🎉
In real projects, you'd swap the simple list for a vector database (like Chroma, Qdrant, pgvector, or Pinecone) and load real documents. But the flow stays exactly the same.
Since I live in the WordPress world, this one got me excited.
Imagine a plugin with 60 documentation pages and a support inbox full of repeat questions like "How do I enable X?" or "Why is Y not saving?"
Fewer repeat tickets, faster answers, and the docs finally earn their keep. 😄
Like I said at the start, I'm still in the learning phase with RAG. This article is me sharing what clicked for me, and I'd love to hear what clicked (or broke) for you.
I'll read every reply, and I'll turn the best tips and challenges into a follow-up article. Let's help each other get past the confusing parts. 🚀