agents.rag.hyde.agent_v2

HyDE (Hypothetical Document Embeddings) RAG Agent V2.

Bridges query-document semantic gap by generating hypothetical documents. This version properly embeds the hypothetical document for retrieval.

Classes

HyDERAGAgentV2

HyDE RAG using hypothetical document generation for better retrieval.

HyDERetrieverAgent

Custom retriever that uses hypothetical document for enhanced retrieval.

Functions

build_graph()

Build custom graph for HyDE workflows.

transform_to_query(hypothesis)

Transform hypothesis to query format.

Module Contents

class agents.rag.hyde.agent_v2.HyDERAGAgentV2

Bases: haive.agents.multi.enhanced_sequential_agent.SequentialAgent

HyDE RAG using hypothetical document generation for better retrieval.

This version properly uses the hypothetical document as the basis for retrieval.

classmethod from_documents(documents, llm_config=None, embedding_model=None, **kwargs)

Create HyDE RAG from documents.

Parameters:
  • documents (list[langchain_core.documents.Document]) – Documents to index

  • llm_config (haive.core.models.llm.base.LLMConfig | None) – Optional LLM configuration

  • embedding_model (str | None) – Optional embedding model for vector store

  • **kwargs – Additional arguments

Returns:

HyDERAGAgentV2 instance

class agents.rag.hyde.agent_v2.HyDERetrieverAgent

Bases: haive.agents.base.agent.Agent

Custom retriever that uses hypothetical document for enhanced retrieval.

build_graph()

Build graph that passes hypothetical doc as query.

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

agents.rag.hyde.agent_v2.build_graph()

Build custom graph for HyDE workflows.

Returns:

Graph configuration or None for default behavior

Return type:

Any

agents.rag.hyde.agent_v2.transform_to_query(hypothesis)

Transform hypothesis to query format.

Parameters:

hypothesis (str) – Generated hypothesis text

Returns:

Formatted query string

Return type:

str