How do you make any LLM go beyond its training? How do we expand context with relevant knowledge for our use case? Let's go over it in this article.

By Alejandro Aboy

Published: 2025-08-16

URL: https://thepipeandtheline.substack.com/p/rag-intro-for-data-professionals


Hi there! Alejandro here 😊

Suscribe if you like to read about technical data & AI learnings, deep dives!

Enjoy the reading and let me know in the comments what you think about it 👨🏻‍💻

Subscribe now

It’s been some years since ChatGPT saw the light.

One day, without even knowing it, we had the whole internet at our disposal, and the only barrier was just one chat message.

LLMs are really powerful, but at the end of the day, they achieve everything mostly by paying attention to how they were trained to accomplish certain tasks or requests.

At some point, users started needing more than a static Google wrapper that has a cutoff date and doesn’t work when you ask who won the elections yesterday.

Let’s see how the AI space found a way not only to compensate for LLM handicaps, but also to enable multiple use cases nowadays, allowing you to adapt certain LLMs to your needs without the requirement for expensive and lengthy training processes.

Table of contents

-

❌ Limitations on LLMs

-

🔎 What is RAG (Retrieval Augmented Generation)?

-

🙋🏻‍♂️ Do I really need RAG?

-

👁️‍🗨️ Try before RAG: API Calls and LLM Tools

-

👀 How do use RAG to make all this external knowledge available to the LLMs?

Image generated by ChatGPT.


❌ Limitations on LLMs

Usually, most use cases can be covered by good prompts on any OpenAI, Anthropic, or similar LLM providers.

Based on their extensive training datasets, they are able to generate responses that can fulfill a great number of requests.

But there’s a limit:

-

Outdated data / training: can’t go beyond its training date.

-

Missing domain-specific knowledge: can’t answer complex legal topics that were not present during training.

-

Not able to interact with external resources such as Google Drive or HubSpot CRM.

Asking about the previous points usually forces LLMs to hallucinate or guess the response.

This last claim started changing some months ago with ChatGPT integrating with Google Drive, HubSpot CRM, GitHub, and adding web search, as many other LLM providers such as Anthropic or Gemini did.

Still, you may ask: “Fine, but how can I do it? How can I enable a system to pass extra context to an LLM for my use cases?”

Of course, that’s when RAG comes in.


Thanks for reading The Pipe & The Line! Subscribe for free to receive new posts and support my work.


🔎 What is RAG (Retrieval Augmented Generation)?

The definition is in the name itself: retrieve knowledge to augment prompts for response generation.

In other words: we are providing extra information to process the request with extended knowledge from external sources.

These could be PDFs, CSVs, JSONs, databases, Slack chats, etc. For example, OpenAI or Anthropic Google Drive integrations are a form of RAG.

-

RAG is not fine-tuning: it doesn’t change the model itself.

-

RAG is not a prompt technique: it doesn’t define behaviors to influence how the model acts.

-

RAG is not a tool: it’s not simply delegating tasks, such as getting values from an API.

RAG adds external context that the LLM cannot access otherwise.

A typical, most common RAG setup has these components:

-

LLM

-

Prompt

-

Embedding Model

-

Vector Database (embedded and chunked documents)

All these component details will be covered in upcoming articles in this series, but for now, keep this in mind:

-

The LLM receives a user query (e.g., claude-4).

-

There’s an embedding model (e.g., text-embedding-3-small) that transforms the query into embeddings (e.g., [0.012345; -0.003210; ...]).

-

These vectors are used to find the closest ones in terms of geometric distance in a vector database, using what’s known as cosine similarity.

-

This allows finding semantically meaningful distances and not just keyword matches, which helps the embedding model understand that “car” is close to “vehicle” even though they don’t look the same.

-

When the search process is done, the top N closest documents are fetched and added to the prompt that you send back to the LLM.

-

The LLM can now respond with that extra context that wouldn’t have existed if it weren’t for RAG combined with similarity search.

To keep it visual:RAG BaseSource: https://weaviate.io/blog/introduction-to-rag

If it sounds like a lot right now, breathe and keep reading—things will start making sense as you progress through the series. 😎

In case you are interested in what Fine Tuning does in detail, I have a basic setup in this article:


🙋🏻‍♂️ Do I really need RAG?

I would have liked someone to tell me this before I jumped into reading papers and frameworks to do RAG.

With all the hype, I kept reading things like “BREAKING: Use super-duper RAG TURBO 2.0 technique to dance with your data while you walk backwards,”

… and felt the FOMO kicking in because it looked like RAG is the only answer, when it’s not.

But let’s think about it together so you can understand how to decide if you really need it. Normally, the flow goes like this:

Can you put everything in your prompt to achieve what you want? Cool, you don’t need RAG.

Your prompt isn’t enough, and you can programmatically call an API or fetch data from somewhere else, format it, and pass it to the prompt? Cool, you still don’t need RAG.

Your API returns a lot of data, exceeds the LLM context window, or creates a lot of overhead and complexity during runtime? Go with RAG.

⚠️ Iterate a lot before asking the next question; normally 99% of use cases end up here, but there’s a tendency toward over-engineering.

Your knowledge retrieval is still missing custom behaviors that you expect from the model? Scope the project again and ask yourself if fine-tuning is a real requirement. If the answer is still yes, then cool.

We won’t talk about fine-tuning in this series, but I’ll probably publish a quick, basic demonstration on how to do it with OpenAI.

If you want to expand your thinking on this topic, check this one out:


Thanks for reading The Pipe & The Line! This post is public so feel free to share it.

Share


👁️‍🗨️ Try before RAG: API Calls and LLM Tools

For data processes, most of the time you have control over what data to fetch and when, so unless you work with large amounts of data, passing API responses is a good way to avoid a full RAG implementation.

Let’s say you have a prompt template:

And the user query:

query = "How did the channel google ads performed yesterday?"

Then, you can pick two paths:

-

Not recommended – Run the API call directly if you know for sure that you can expect consistent input for function parameters.

-

Recommended – You can configure this as a tool for the LLM.

API Call and pass response into context

As with every other time you execute an API call, you:

Pass parameters, authenticate with a token if needed, call the endpoint, and get a JSON response back.

For this use case, you need to get the actual data you want to pass, because the LLM won’t figure it out on its own.

Lastly, you inject the API response into the LLM call:

LLM with Tools

Implementing tools for LLMs can solve a lot of implementation struggles if specs are defined correctly. Here’s a config for the example using OpenAI Function Calling specs:

As you can see, I define each property (Python function parameter) and provide an explanation for each of them. With this input, the LLM knows:

  1. What tool to use and when.

-

How to translate the user’s query into tool parameters.

-

How to assume expected parameters based on documentation.

Then you can use them in the call, like this:

Recommended read: OpenAI - Function Calling

In the next section we will talk about the technical foundation of RAG and its different aspects.


Thanks for reading The Pipe & The Line! This post is public so feel free to share it.

Share


👀 How do use RAG to make all this external knowledge available to the LLMs?

LLMs are constantly transforming inputs into token sequences to try to infer the most probable next token chain; that’s why they need helpers to estimate the probability of the most relevant sequence.

These helpers are vectors, known as embeddings in the AI space. Vectors are numerical representations that are semantically close to each other.

We convert our data into embeddings so they can be searched for the closest vectors to answer a user query.

By “closest” here, we mean geometric distance, and that’s what similarity search is all about—the most common use case for RAG.

We will talk more about it in the next articles of this series.


📝 TL;DR

-

❌ Limitations on LLMs

-

LLMs can’t access the outside world, they are stuck on training datasets.

-

🔎 What is RAG (Retrieval Augmented Generation)?

-

We look for data in external sources and inject it in the context of the LLM to achieve the task.

-

🙋🏻‍♂️ Do I really need RAG?

-

Look if prompts, API calls added to prompts or LLM with Tools are enough before going to RAG.

-

👁️‍🗨️ Try before RAG: API Calls and LLM Tools

-

API Call and pass response into context

-

LLM with Tools

-

👀 How do use RAG to make all this external knowledge available to the LLMs?

-

Embeddings with distance calculation

In part 2, we will cover: Vector Databases, Embeddings Models and Chunking data


If you enjoyed the content, hit the like ❤️ button, share, comment, repost, and all those nice things people do when like stuff these days. Glad to know you made it to this part!


Hi, I am Alejandro Aboy. I am currently working as a Data Engineer. I started in digital marketing at 19. I gained experience in website tracking, advertising, and analytics. I also founded my agency. In 2021, I found my passion for data engineering. So, I shifted my career focus, despite lacking a CS degree. I'm now pursuing this path, leveraging my diverse experience and willingness to learn.

Follow me on Linkedin