A class for retrieving relevant documents based on a given query. It
extends the VectorStoreRetriever class and uses a BaseLanguageModel to
generate a hypothetical answer to the query, which is then used to
retrieve relevant documents.
Example
constretriever = newHydeRetriever({ vectorStore:newMemoryVectorStore(newOpenAIEmbeddings()), llm:newChatOpenAI(), k:1, }); awaitvectorStore.addDocuments( [ "My name is John.", "My name is Bob.", "My favourite food is pizza.", "My favourite food is pasta.", ].map((pageContent) =>newDocument({ pageContent })), ); constresults = awaitretriever.getRelevantDocuments( "What is my favourite food?", );
A class for retrieving relevant documents based on a given query. It extends the VectorStoreRetriever class and uses a BaseLanguageModel to generate a hypothetical answer to the query, which is then used to retrieve relevant documents.
Example