WPSolr logo
Search
Close this search box.

Table of contents :

What is RAG and how does it work

rag

Table of contents :

Nowadays, text generation is making a big wave thanks to LLMs (Large Language Models). Trained on large amounts of publicly (or sometimes privately) accessible data, these models can complete various language related tasks such as conversation (chatbot), question answering and even advising. They impact many sectors like writing, coding and marketing. But what about search? Well you’re at the right place because that is what RAG (Retrieval Augmented Generation) is about.

 

What does RAG do ?

 

RAG, as it’s name implies, combines both search and AI-based text generation. It has become a very trendy topic recently since it is capable of delivering the same capabilities as LLMs while remaining a more reliable source of information. This is because, when integrated into a RAG system, the LLM responds appropriately based on your own authoritive and preferably up to date data source, thus greatly minimizing hallucinations occurences.

 

RAG can be preferable to search since instead of delivering results as is, it will instead reformat the information contained in the search results in a more natural and digestable manner. It is similar to asking an informed and up to date friend about the current events or any other topic, therefore receiving a single and comprehensive answer rather than a list of sources.

 

How does RAG work ?

 

RAG is not a specific solution but instead a combination of technologies. You can combine any type of search (keyword search, AI search or personalized search) with any available LLM, but depending on how you set it up, results will vary.

 

Diagram a simplification of the inner workings of RAG (Retrieval Augmented Generation)

Simplified diagram of the inner workings of RAG

 

As you can see in the diagram above, RAG works in a few steps :

  1. User enters the query : on your website, the user will enter any query of their choice.
  2. Search engines fetches results : a search query is sent to the search engine of your choice. It can be anything : Solr, Elasticsearch, Algolia, Weaviate, etc… The only thing that matters is that it returns relevant items.
  3. LLM generates text based on a prompt : The user query and relevant items are now sent to the LLM. A predetermined prompt incorporating both of these elements will then be used to generate the text that should answer the user’s question.
  4. The generated text is displayed to the user : On the front-end, the user should see the generated text displayed.

 

This is the vey basics of how RAG works.

 

Add RAG to your WordPress website ?

 

You can add RAG to your website using WPSolr. WPSolr is a WordPress search & recommendations plugin that can integrate many search engines into your WordPress or Woocommerce website.

 

It can integrate Weaviate, an open-source vector database (AI search engine), which also includes a questions and answers module.

 

You can learn how to add questions and answers to your WordPress using WPSolr in our official documentation.

Related posts ... not powered by WPSOLR 😊