hybrid

package
v1.23.4 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLimit = 100

Variables

This section is empty.

Functions

This section is empty.

Types

type Params

type Params struct {
	*searchparams.HybridSearch
	Keyword *searchparams.KeywordRanking
	Class   string
	Autocut int
}

type Result

type Result struct {
	DocID uint64
	*search.Result
}

Result facilitates the pairing of a search result with its internal doc id.

This type is key in generalising hybrid search across different use cases. Some use cases require a full search result (Get{} queries) and others need only a doc id (Aggregate{}) which the search.Result type does not contain.

func FusionRanked added in v1.20.0

func FusionRanked(weights []float64, resultSets [][]*Result, setNames []string) []*Result

func FusionRelativeScore added in v1.20.0

func FusionRelativeScore(weights []float64, resultSets [][]*Result, names []string) []*Result

FusionRelativeScore uses the relative differences in the scores from keyword and vector search to combine the results. This method retains more information than ranked fusion and should result in better results.

The scores from each result are normalized between 0 and 1, e.g. the maximum score becomes 1 and the minimum 0 and the other scores are in between, keeping their relative distance to the other scores. Example:

Input score = [1, 8, 6, 11] => [0, 0.7, 0.5, 1]

The normalized scores are then combined using their respective weight and the combined scores are sorted

type Results

type Results []*Result
func Search(ctx context.Context, params *Params, logger logrus.FieldLogger, sparseSearch sparseSearchFunc, denseSearch denseSearchFunc, postProc postProcFunc, modules modulesProvider) (Results, error)

Search executes sparse and dense searches and combines the result sets using Reciprocal Rank Fusion

func (Results) SearchResults

func (res Results) SearchResults() []search.Result

Jump to

Keyboard shortcuts

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