From the course: Advanced LLMs with Retrieval Augmented Generation (RAG): Practical Projects for AI Applications
Unlock this course with a free trial
Join today to access over 25,600 courses taught by industry experts.
Hands-on lab: Reverse HyDE
From the course: Advanced LLMs with Retrieval Augmented Generation (RAG): Practical Projects for AI Applications
Hands-on lab: Reverse HyDE
- So let's see a simple implementation of the reverse HyDE technique. We will use this notebook with the usual improvement using the rich library and the warning suppression, and we'll start with the implementation of the ReverseHyde class. We'll use OpenAI, a text embedding model, the one that we saw in one of our previous notebooks. The get_embedding logic. It's quite simple. So we called the OpenAI client asking for embedding, create, and the text that we are giving it. Then we have the function to generate the reverse HyDE, which is based on the prompt, the prompt to our LM model. Given the following chunk, generate n different question that this chunk would be a good answer to. Then we provide a chunk, and we ask for multiple questions, and we want it to be enumerated so we can easily pass them. And then we call the OpenAI client to the GPT-3.5. Again, you can choose different LLM models here. It doesn't have to be OpenAI. We're using the embedding, and the generation's OpenAI…