Hyde Retrieval
HyDERetrieval Class Documentation
Overview
The HyDERetrieval
class is inspired by the paper "Precise Zero-shot Dense Retrieval without Relevance Labels". It uses a language model to generate a hypothetical passage for a given query and then retrieves passages using this hypothetical passage as the query.
Usage
Initialize
First, prepare the retrieval instance you want to use and set up your system prompt. In this example, we are using BM25Retrieval
as the base retrieval method and setting up a custom system prompt.
Ingest
Ingest a list of Passage
s into the retrieval in the HyDE retrieval.
Retrieve
Retrieve top-k passages for a given query. You can also specify model kwargs such as max tokens for hypothetical passage generation model. modle kwargs reference is in openai api docs.
Retrieve with filter
You can also filter the retrieved passages. Use the retrieve_with_filter
method and provide the query, top-k value, and a list of content, filepath, or metadata values to filter by.
In this method uses DB.search
method. Please refer here for further information.
Here's an example:
Last updated