hybrid

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package hybrid provides hybrid retrieval combining vector and graph strategies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Policy

type Policy string

Policy defines how to combine vector and graph retrieval.

const (
	// PolicyParallel runs vector and graph retrieval in parallel and merges results.
	PolicyParallel Policy = "parallel"
	// PolicyVectorThenGraph runs vector search first, then expands via graph.
	PolicyVectorThenGraph Policy = "vector_then_graph"
	// PolicyGraphThenVector runs graph traversal first, then grounds via vector.
	PolicyGraphThenVector Policy = "graph_then_vector"
)

type Retriever

type Retriever struct {
	// contains filtered or unexported fields
}

Retriever implements hybrid vector+graph retrieval.

func NewRetriever

func NewRetriever(cfg RetrieverConfig) *Retriever

NewRetriever creates a new hybrid retriever.

func (*Retriever) Retrieve

func (r *Retriever) Retrieve(ctx context.Context, q retrieve.Query) (*retrieve.Result, error)

Retrieve performs hybrid retrieval based on the configured policy.

type RetrieverConfig

type RetrieverConfig struct {
	// Vector is the vector retriever.
	Vector retrieve.Retriever
	// Graph is the graph retriever.
	Graph retrieve.Retriever
	// Policy defines how to combine results.
	Policy Policy
	// Weights for combining scores.
	Weights Weights
	// Reranker to apply after merging (optional).
	Reranker retrieve.Reranker
	// DedupByID removes duplicate items by ID.
	DedupByID bool
	// Observer for tracing and metrics.
	Observer retrieve.Observer
}

RetrieverConfig configures the hybrid retriever.

type Weights

type Weights struct {
	// Vector weight (0.0-1.0).
	Vector float64
	// Graph weight (0.0-1.0).
	Graph float64
}

Weights configures the relative importance of vector vs graph results.

func DefaultWeights

func DefaultWeights() Weights

DefaultWeights returns balanced weights.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL