Help us shape the future of Go! Take the 2026 Go Developer Survey

fusion

package
v1.112.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Strategy string             // "rrf", "weighted", "max"
	K        int                // RRF parameter
	Weights  map[string]float64 // Strategy weights
}

Config holds configuration for fusion strategies

type Fusion

type Fusion interface {
	// Fuse combines results from multiple strategies into a single ranked list
	// strategyResults maps strategy name to its results
	Fuse(strategyResults map[string][]database.SearchResult) ([]database.SearchResult, error)
}

Fusion defines the interface for combining results from multiple retrieval strategies

func New

func New(config Config) (Fusion, error)

New creates a fusion strategy based on configuration

type MaxScoreFusion

type MaxScoreFusion struct{}

MaxScoreFusion combines results by taking the maximum score for each document Useful when strategies use the same scoring scale

func NewMaxScoreFusion

func NewMaxScoreFusion() *MaxScoreFusion

NewMaxScoreFusion creates a new max score fusion strategy

func (*MaxScoreFusion) Fuse

func (mf *MaxScoreFusion) Fuse(strategyResults map[string][]database.SearchResult) ([]database.SearchResult, error)

Fuse combines results using maximum score

type ReciprocalRankFusion

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

ReciprocalRankFusion implements the RRF (Reciprocal Rank Fusion) algorithm RRF is strategy-agnostic and works well for combining results from different retrieval methods

Formula: score(d) = Σ(1 / (k + rank(d))) where k is typically 60, and rank starts at 1 for the top result

Reference: "Reciprocal Rank Fusion outperforms Condorcet and individual Rank Learning Methods" by Cormack, Clarke, and Buettcher (SIGIR 2009)

func NewReciprocalRankFusion

func NewReciprocalRankFusion(k int) *ReciprocalRankFusion

NewReciprocalRankFusion creates a new RRF fusion strategy

func (*ReciprocalRankFusion) Fuse

func (rrf *ReciprocalRankFusion) Fuse(strategyResults map[string][]database.SearchResult) ([]database.SearchResult, error)

Fuse combines results from multiple strategies using RRF

type WeightedFusion

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

WeightedFusion combines results using weighted sum of strategy scores Each strategy's score is multiplied by its weight

func NewWeightedFusion

func NewWeightedFusion(weights map[string]float64) *WeightedFusion

NewWeightedFusion creates a new weighted fusion strategy

func (*WeightedFusion) Fuse

func (wf *WeightedFusion) Fuse(strategyResults map[string][]database.SearchResult) ([]database.SearchResult, error)

Fuse combines results using weighted scores

Jump to

Keyboard shortcuts

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