Skip to main content
Back to blogsOriginal post
RAGs — Retrieval Augmented Generation Simplified For Us
RAGAgentic AIAfrican context

RAGs — Retrieval Augmented Generation Simplified For Us

By Ezra Muinde on May 29, 2026 - 9 min read

Ubuntu Analytiq insight
The models were trained on the world. We are here to teach them Africa.

This topic reminds me of my entry into Agentic AI. It reminds me of the 80 students I have been able to train.

It reminds me of the Hackathon we did last year. It reminds me of why I started the Agentic AI Masterclass.

And it takes me back to my first article on Agentic AI; because this topic right here builds directly to the reason I started Ubuntu Analytiq ; for our context, our markets, and our opportunities.

Okay. Allow me to cook.

First, what is an LLM?

You have used an LLM. In fact, you are probably using one right now. Claude, ChatGPT, Gemini; that thing you chat with.

Not Claude Code, not Codex, not the design tools. That which you chat with. We call them LLMs; Large Language Models.

They are called Large Language Models because, well, they are large; and they deal in language💀.

You see those Sama jobs where Kenyans have been proudly saying they trained AI? Basically, they were labelling data.

Telling the model: every time a Kenyan says onetum, they mean Ruto Must Go. Every time they say tutam, they mean Ruto goes for another term.

Everything AI knows has been trained; trained from data. But because it has access to so much of that data, it reaches a point where it can do something remarkable: it can generate.

That is the G in ChatGPT.

Here is how to think about it.

Imagine your teacher explained why the Agrarian Revolution thrived; good roads, fertile land, new tools. Then in your exam, you write: “It is because of better transportation infrastructure and improved farming methods.”

You did not memorise the exact words. You understood the concept and expressed it in your own way.

And you got full marks. That is exactly what Claude, ChatGPT, and Gemini are doing; every single time you send a message; they Generate!

The Science Behind It (Simplified, I Promise)

Under the hood, these models run on something called a Transformer; a neural network architecture that changed everything when it was introduced in 2017 in a paper titled, rather brilliantly, “Attention Is All You Need.”

The Transformer works by paying attention; and not the polite kind. When you type a sentence, the model does not read it word by word like a human.

It looks at the entire sentence at once, weighing every word against every other word to understand relationships and meaning.

The word bank means something very different in “I went to the river bank” versus “I went to the bank to withdraw money.” The Transformer figures that out from context — automatically, at scale, across billions of words.

This attention mechanism is why these models feel almost human. They are not just matching keywords. They are understanding meaning, tone, and relationship; and then generating a response that fits.

Billions of parameters, trained on more text than any human being could read in a thousand lifetimes.

That is your LLM. Brilliant. But limited.

What the LLM Does Not Know

Here is the problem. ChatGPT does not know your company’s refund policy.

It does not know your product catalogue as of last Monday.

It does not know why you broke up with your girlfriend; and frankly, it should not. It does not know:

  • What was said in your last board meeting
  • Your organisation’s internal HR procedures
  • The specific terms of your client contracts
  • Your customer FAQs or product specs
  • Anything that happened after its training cutoff date

The model was trained on the internet; and the internet does not know your business. It does not know your community. It does not know us.

So when you ask it something too specific, it does one of two things: it says “I don’t know” — which is the honest answer — or it confidently makes something up.

That second thing has a name. We call it hallucination. And it is a real problem.

The solution? Context. And that is exactly what RAG is about.

Context — The Thing That Changes Everything

When you walk into a therapist’s office for the first time, they do not already know your story. You have to tell them.

Your childhood, your relationships, your triggers, your patterns. Without that background, any advice they give will be generic at best, harmful at worst. The context is what makes their guidance specific to you.

Remember when Njugush and Wakavinye had that public relationship drama? Everyone had an opinion.

But the only side of the story making the rounds was Wakavinye’s. And all the men kept saying, “we want to hear both sides.” My guy; that is context.

Without full context, even a reasonable person becomes biased.

With full context, you get a much more balanced, truthful picture. Same situation. Different outcome depending on what you know.

That is exactly how AI works. Feed it your context, and it answers from your world. Without it, it answers from Sama’s labelling sessions and Reddit threads. With it, it becomes your expert.

And that context — that is RAG.

So What Exactly is a RAG?

RAG stands for Retrieval Augmented Generation. Let us break that down; but first, let me give you the plain version.

When you upload a PDF to ChatGPT and ask it questions based on that document; that is a RAG.

Instead of answering from what it was trained on, the AI refers to the new knowledge you gave it.

You gave it context. It retrieved from that context. It generated an answer. Retrieval. Augmented. Generation. Done.

Simple example: You upload a 50-page company policy document and ask, “What is the leave policy for new employees?”

ChatGPT has never seen your policy. But you just gave it that PDF. It goes into the document, finds the section about leave, pulls it out, and generates a clear, accurate answer.

That is RAG in its most basic form.

R — Retrieval

This is the magic step. When you ask a question, the system does not read the entire document word by word.

Write on Medium

That would be slow and inefficient. Instead, it has already broken your document into small chunks and indexed them; think of it like building a very smart table of contents, except instead of page numbers, it maps meaning.

When you ask about Ezra Muinde, the system searches through all those chunks for anything related to Ezra Muinde;and retrieves only the relevant sections. Fast. Targeted. Efficient.

But here is where it gets interesting.

Suppose your document has this information about Ezra: he is a Data Scientist, an AI Engineer, he loves reading, his favourite series is Prison Break, he does not enjoy music, and — very importantly — he is a middle child. (All the middle children in the room know exactly why that matters.)

Now you ask: “Based on what you know about Ezra, what kind of music does he enjoy?”

The document says he does not enjoy music. But your question assumes he does. The retrieval pulls the right chunk; the one about Ezra’s personality — but then the generation step has to work with a question that is pointing in the wrong direction.

This is where hallucination can creep in. The model might try to answer the question anyway, inventing preferences for Ezra rather than simply saying the premise is wrong.

This is why how you ask matters enormously. Which brings us to the second piece.

A — Augmented

Augmented means enhanced. The model’s base knowledge; everything it learned during training; is being augmented with your specific, private, real-world information.

Think of it like giving a brilliant doctor your medical history before the consultation. They are already knowledgeable.

Now they are knowledgeable about you. That combination; general intelligence plus specific context; is what makes the output genuinely useful.

Without augmentation, the LLM is a brilliant stranger. With augmentation, it becomes something much closer to a specialist who knows your situation.

G — Generation

This is where the LLM does what it does best.

Having retrieved the right context and combined it with its training, it now generates a response; not just a copy-paste from your document, but a synthesised, natural, readable answer.

It connects the dots. It explains. It elaborates. It speaks in full sentences that make sense to the person asking.

And this is directly connected to prompting; the way you frame your question shapes the quality of what gets generated.

A vague question gives you a vague answer. A precise question gives you a precise answer. A question built on a wrong assumption can give you a wrong answer delivered with full confidence.

The prompt is the steering wheel. The RAG is the engine. Together, they take you where you want to go; but only if you know how to drive.

RAG Pipelines in Agentic AI

Now, this is where it gets exciting. Basic RAG; upload a PDF, ask a question; is just the beginning. In Agentic AI, RAG is not a one-time lookup.

It is a living pipeline. And when it is wired into a database, it becomes something entirely different.

Here is how a RAG pipeline works at the agentic level:

  • Ingestion: Your documents, databases, websites, chat logs; all your knowledge sources; are broken into chunks and converted into numerical representations called embeddings. These embeddings capture meaning, not just words.
  • Storage: Those embeddings are stored in a special kind of database called a vector store; think Pinecone, Weaviate, or pgvector. This is not your regular SQL database. It stores meaning.
  • Retrieval: When a question comes in, the system converts that question into an embedding too, then searches the vector store for the chunks whose meaning is closest to the question. It is similarity search; finding the most relevant knowledge, not just keyword matches.
  • Augmented Prompt: The retrieved chunks are injected into the prompt alongside the user’s question. The LLM sees both: “Here is the relevant context from your knowledge base, and here is what the user is asking.”
  • Generation: The LLM generates a grounded, accurate, contextual response; sourced from your real data, not from its general training.

In agentic systems, this pipeline does not just answer questions; it acts. An AI agent can retrieve context, make a decision, call a tool, update a database, and report back; all in one flow.

Imagine a customer support agent that retrieves your company policies, checks the customer’s order history, generates a resolution, and logs the interaction; automatically.

That is RAG in an agentic pipeline.

We are talking about AI that does not just know things. AI that knows the right things, at the right moment, in the right context; and then acts on them.

Why RAGs Are the Context We Need in Africa

Here is the honest truth.

The LLMs that power ChatGPT, Claude, and Gemini were trained predominantly on Western data; Western news, Western literature, Western business practices, Western languages.

They know Nairobi as a concept, but they do not know our Nairobi. They know Africa as a geography, but they do not know our markets, our languages, our informality, our ingenuity.

RAG changes that equation. It means we do not have to wait for a foundation model to be retrained on African data; which could take years and billions of dollars we do not have.

Instead, we can inject our context right now. Our case law, in Kenyan courts. Our agricultural data, from our soils.

Our health records, from our clinics. Our financial behaviour, from our SACCOs and mobile money systems. Our local languages and dialects.

A lawyer in Kisumu can build an AI assistant that knows Kenyan land law.

A clinic in Eldoret can deploy an AI that understands local disease patterns and patient histories.

A SACCO in Mombasa can use an AI agent that understands member behaviour and lending risk in the Kenyan context.

None of this requires retraining a billion-parameter model. It requires a good RAG pipeline.

This is why I started Ubuntu Analytiq. Not to import AI solutions designed for different markets and different problems.

But to build AI that knows us; that is grounded in our context, trained on our data, answering our questions.

RAG is not just a technical pattern. In Africa, RAG is a strategy. It is how we make AI relevant before the world gets around to doing it for us.

And given how this continent moves when it decides to move — we are more than capable of doing it ourselves.

Want to Go Deeper?

We are just getting started. If this piece made you curious; if you found yourself nodding, or wanting to ask questions, or thinking about how RAG could apply to your organisation, your startup, or your industry; then the next step is clear.

Join the upcoming Agentic AI Masterclass by Ubuntu Analytiq. We go from concepts like this all the way to building real RAG pipelines; from ingestion, to vector stores, to deployment.

Hands-on. Practical. Built for the African context.

Tools to start exploring right now:

  • LangChain / LlamaIndex — The most popular frameworks for building RAG pipelines in Python
  • Pinecone / Weaviate / pgvector — Vector databases for storing your embeddings
  • Anthropic Claude API / OpenAI API — The generation layer for your RAG pipeline
  • Notion AI / ChatGPT with files — The easiest starting point if you just want to see RAG in action before building anything

Start with the concept. Then build the thing. Then scale it for your context.

AI for our context. Our markets. Our opportunities.