Question-Answering Pipelines with ChatGPT and Redis
Large Language Models are the evolutionary path to resolving many problems with a new approach while permitting the development and rise of new use cases. We all have seen how easy it is to get answers from ChatGPT, and this lays the path to many new services in the area of content retrieval. Question answering is an especially hot problem that can be resolved efficiently, so when we would like to provide answers to a question (an automated bot, a search form in a knowledge base) we can recur to generative AI to provide the answer.
Feeding ChatGPT with the right context
However, ChatGPT is not updated with the latest content available. As an example, if you ask ChatGPT:
❓ What is the newest data ChatGPT is trained on?
You’ll get the following:
❗My training is based on the GPT-3.5 architecture, and my knowledge is current up until September 2021. Therefore, any events, information, or developments that have occurred after that date are outside my training data, and I may not have the most up-to-date information on them.
In addition to that, if you would like to create a context based on custom content, content that can’t be available on the internet, or content that is very specific, this is where you can use Redis as a Vector Database to store and index your data and make it available to ChatGPT to create a context based on it.
As you will read in this post, it’s all a matter of asking the right question to get a great answer. In short, this is the question we’ll ask ChatGPT:
Based on <MY CONTEXT> only, answer this <QUESTION>.
Where <MY CONTEXT> is your content, the information you have available and indexed (as vector embeddings) in your Redis database, and that was first retrieved using the <QUESTION> itself (we create an embedding for the question, and do a Vector Similarity Search), and <QUESTION> is the actual question from a user. Let’s see some examples to implement such enriched question/answering applications.
Integration with Relevance AI
The post will show how to sew everything together and build an LLM chain using Relevance AI.
Integration with langchain
In this post you will learn how to create an LLM pipeline using langchain, OpenAI and Azure’s OpenAI service for vector embedding generation
The ChatGPT Retrieval Plugin
In the OpenAI ChatGPT retrieval plugin repository, you can perform “semantic search and retrieval of personal or organizational documents. It allows users to obtain the most relevant document snippets from their data sources, such as files, notes, or emails, by asking questions or expressing needs in natural language.“. The list of supported Vector Databases includes Redis.
Learn more about Vector Similarity Search for Redis
If you are looking for more training opportunity on this topic, I have posted several proof-concept applications in this blog that use Redis Vector Similarity Search.