Enhancing a Basic RAG App

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

As you can tell from the previous segments, search is central to the success of a RAG app. The default search you’ve been using is the similarity search. Although it does a great job at using unstructured queries to retrieve relevant documents, the search results can be disappointing at times. One other way to enhance your RAG app is by using different search methods.

Several things affect how a search query performs. The first to consider is the embedding model. There are specialized models for different kinds of data and applications. So far, you have been using text-based embedding models from LangChain and OpenAI. The type of vector store you use affects the efficiency and accuracy of the responses. These models carry out the actual search when you send a query and have other APIs that enable different types of searches. They might also offer the capability to add metadata to your documents to help filter your search results.

Understanding Hybrid Search

The idea of the hybrid-search technique is simple. Vector stores are great at searching with unstructured text. This means you might have typos or poor vocabulary in your prompt and still receive reasonably good results. Because it searches using semantics, it can handle such queries. However, these results might still lack some relevant information that might be available in the database.

Exploring Citations in a RAG

Ever received an answer from ChatGPT and wondered how it came by the response? Wouldn’t it be great if it cited its sources like Bing Chat? Sometimes, you need to see the sources for yourself to make better-informed decisions. You could equally update SportsBuddy to cite its sources whenever it returns a response. If you add more metadata to your documents such as URL sources and other such identifiable tags, you’ll have detailed, rich responses from your RAG.

See forum comments
Download course materials from Github
Previous: OpenAI & LangChain Demo Next: Enhancing a Basic RAG App Demo