fuse

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 1 Imported by: 0

README

fuse

Score fusion for combining ranked result lists — the combining step of hybrid (vector + BM25) search.

Fusions

Fusion Constructor Behavior
WeightedFusion NewWeightedFusion(alpha) alpha * vectorScore + (1-alpha) * keywordScore on normalized scores.
RRFFusion NewRRFFusion(k) Reciprocal Rank Fusion: rank-based, scale-free, robust when the two score distributions differ.

Both implement the Fusion interface, which index.SearchOptions.Fusion accepts so callers can swap strategies per query.

Used by

index (hybrid search) and store.SearchHybrid (default: weighted at 0.5/0.5, overridable with index.SearchOptions.Fusion).

Documentation

Overview

Package fuse implements score fusion methods to combine rankings from multiple retrieval methods (e.g., vector similarity + BM25).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fusion

type Fusion interface {
	Fuse(scores ...map[string]float64) map[string]float64
}

Fusion defines the interface for combining scores from multiple ranking methods.

type RRFFusion

type RRFFusion struct {
	K int
}

RRFFusion implements Reciprocal Rank Fusion. Score = Σ 1 / (k + rank_i) where rank starts at 1.

func NewRRFFusion

func NewRRFFusion(k int) *RRFFusion

NewRRFFusion creates a new RRFFusion with the given constant k (default 60).

func (*RRFFusion) Fuse

func (f *RRFFusion) Fuse(scores ...map[string]float64) map[string]float64

Fuse combines scores using Reciprocal Rank Fusion.

type WeightedFusion

type WeightedFusion struct {
	Alpha float64
}

WeightedFusion combines scores using a weighted sum. Alpha is the weight for the first score set; (1-alpha) is the combined weight of the remaining score sets, split evenly across them.

func NewWeightedFusion

func NewWeightedFusion(alpha float64) *WeightedFusion

NewWeightedFusion creates a new WeightedFusion. Alpha should be in [0, 1].

func (*WeightedFusion) Fuse

func (f *WeightedFusion) Fuse(scores ...map[string]float64) map[string]float64

Fuse combines scores using a weighted sum. With two score maps the result is alpha*s1 + (1-alpha)*s2. With N > 2 maps, alpha is the weight of the first map and (1-alpha) is split evenly across the remaining N-1 maps, so the per-map weights always sum to 1.

Jump to

Keyboard shortcuts

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