langchain.js
    Preparing search index...

    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.

    const retriever = new HydeRetriever({
    vectorStore: new MemoryVectorStore(new OpenAIEmbeddings()),
    llm: new ChatOpenAI({ model: "gpt-4o-mini" }),
    k: 1,
    });
    await vectorStore.addDocuments(
    [
    "My name is John.",
    "My name is Bob.",
    "My favourite food is pizza.",
    "My favourite food is pasta.",
    ].map((pageContent) => new Document({ pageContent })),
    );
    const results = await retriever.getRelevantDocuments(
    "What is my favourite food?",
    );

    Type Parameters

    Hierarchy (View Summary)

    Index

    Constructors

    • Type Parameters

      • V extends VectorStore = VectorStore

      Parameters

      • fields: any

      Returns HydeRetriever<V>

    Properties

    llm: BaseLanguageModelInterface
    promptTemplate?: any

    Accessors

    • get lc_namespace(): string[]

      Returns string[]

    Methods

    • Parameters

      • query: string
      • OptionalrunManager: any

      Returns Promise<Document[]>

    • Returns string