VOOZH about

URL: https://thenewstack.io/freshen-up-llms-with-retrieval-augmented-generation/

⇱ Freshen up LLMs' 'Retrieval Augmented Generation' - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2023-07-14 03:00:16
Freshen up LLMs' 'Retrieval Augmented Generation'
sponsor-singlestore,sponsored-topic,
AI / Large Language Models

Freshen up LLMs’ ‘Retrieval Augmented Generation’

Large language models like GPT are trained offline on large corpus data. This makes models ignorant of any data generated after they are trained. Here's how to update them.
Jul 14th, 2023 3:00am by Janakiram MSV
👁 Featued image for: Freshen up LLMs’ ‘Retrieval Augmented Generation’
Feature image by Image by Penny from Pixabay.  

The foundation models, including large language models (LLMs) like GPT, are typically trained offline on large corpus data. This makes models ignorant of any data generated after they are trained.

Furthermore, because foundation models are trained on publicly available, general corpus data, they are less effective for domain-specific tasks. Retrieval Augmented Generation (RAG) is a technique to retrieve data from outside a foundation model to augment the prompts by injecting the relevant retrieved data into the context.

RAG is more cost-effective and efficient than pre-training or fine-tuning foundation models. It is one of the techniques used for “grounding” the LLMs with information that is use-case specific and relevant to ensure the quality and accuracy of the responses. This is critical to reducing the hallucinations in LLMs.

In this article, we will take a closer look at implementing RAG with LLMs to bring domain-specific knowledge.

Designed for intelligent applications, SingleStore is the world’s only real-time data platform that can read, write and reason on petabyte-scale data in a few milliseconds. Insight Partners is an investor in SingleStore and TNS.
Learn More
The latest from SingleStore

Why Implement RAG?

Let’s consider a simple scenario where you ask ChatGPT a question about the 95th Academy Awards. Since the announcements were made in March 2023 and the training cutoff date for ChatGPT was September 2021, you get a typical apologetic response.

👁 Image

However, if you give ChatGPT some context before asking the same question, it will be able to respond with a meaningful answer.

Let’s copy and paste the blurb from the Good Morning America website related to the 95th Academy Awards, which “injects” additional context into the prompt.

👁 Image

Our prompt now reads as follows:

👁 Image

As we can see, that simple blurb made a significant difference in the LLM’s response to the question. Depending on the supported context length, we can feed additional information to the LLM to make it knowledgeable about a specific topic.

Despite the fact that we manually copied and pasted, we essentially implemented a rudimentary RAG mechanism to get what we wanted from ChatGPT.

In an enterprise environment, LLMs may require information to be retrieved from various unstructured and structured data sources. As a result, copying and pasting context to supplement a prompt is not a viable option. This is where RAG provides a framework and a blueprint to build domain-specific, production-grade LLM applications.

The RAG Framework

External data used to augment the prompts in RAG can come from diverse sources, including document repositories, databases, and APIs.

👁 Image

Step 1: The Prompt
The user is providing the prompt for the chatbot for the first time in this interaction. The prompt may contain a brief description of what the user expects in the output.

Step 2: Contextual Search
This is the most crucial step, where the prompt is augmented with the help of an external program responsible for searching and retrieving contextual information from external data sources. This may include querying a relational database, searching a set of indexed documents based on a keyword, or invoking an API to retrieve data from remote or external data sources.

Step 3: Prompt Augmentation
Once the context is generated, it gets injected into the original prompt to augment it. There is now additional information that contains factual data added to the user’s query.

Step 4: Inference
The LLM receives a rich prompt with the additional context and the original query sent by the user. This significantly increases the model’s accuracy because it can access factual data.

Step 5: Response
The LLM sends the response back to the chatbot with factually correct information.

The Role of Word Embeddings and Vector Databases in RAG

While the above framework explains the high-level approach to implementing RAG, it doesn’t discuss the implementation details.

One of the crucial steps in performing search and retrieval is performing a semantic search based on the input query to filter words and sentences with similar meanings. To do this, we must leverage a word embedding model, which converts text into a set of vectors. When the source data and the prompt are vectorized based on the same word embedding model, we can perform a semantic search to match sentences and phrases with similar meanings.

Since converting a large corpus of data into vectors based on word embedding for each query is expensive, generating them once and storing them in a database is a good idea. Vector databases are a new database category that stores vectors and performs similarity searches. As new documents and databases are added to the pipeline, they can be converted into vectors and stored in the vector database.

In the next part of this series, we will implement RAG to augment prompts sent to OpenAI. Stay tuned.

Designed for intelligent applications, SingleStore is the world’s only real-time data platform that can read, write and reason on petabyte-scale data in a few milliseconds. Insight Partners is an investor in SingleStore and TNS.
Learn More
The latest from SingleStore
TRENDING STORIES
Janakiram MSV (Jani) is a practicing architect, research analyst, and advisor to Silicon Valley startups. He focuses on the convergence of modern infrastructure powered by cloud-native technology and machine intelligence driven by generative AI. Before becoming an entrepreneur, he spent...
Read more from Janakiram MSV
SHARE THIS STORY
TRENDING STORIES
TNS owner Insight Partners is an investor in: Pragma, SingleStore, OpenAI.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.