retrievers

package
v0.4.14-rc.24 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const BasicRetrieverName = "basic"
View Source
const MergingRetrieverName = "merge"
View Source
const RoutingRetrieverName = "routing"
View Source
const SubqueryRetrieverName = "subquery"

Variables

This section is empty.

Functions

func DefaultConfigDecoder added in v0.4.11

func DefaultConfigDecoder(ret Retriever, cfg map[string]any) error

func ExtractQuotedSubstrings added in v0.4.7

func ExtractQuotedSubstrings(input string) []string

Extract double-quoted substrings from a string

Types

type BM25Retriever added in v0.4.11

type BM25Retriever struct {
	TopN int

	K1 float64 // K1 should be between 1.2 and 2 - controls term frequency saturation
	B  float64 // B should be around 0.75 - controls the influence of document length normalization

	CleanStopWords []string // list of stopwords to remove from the documents - if empty, no stopwords are removed, if only "auto" is present, the language is detected automatically
}

func (*BM25Retriever) DecodeConfig added in v0.4.11

func (r *BM25Retriever) DecodeConfig(cfg map[string]any) error

func (*BM25Retriever) Name added in v0.4.11

func (r *BM25Retriever) Name() string

func (*BM25Retriever) NormalizedScores added in v0.4.13

func (r *BM25Retriever) NormalizedScores() bool

func (*BM25Retriever) Retrieve added in v0.4.11

func (r *BM25Retriever) Retrieve(ctx context.Context, store store.Store, query string, datasetIDs []string, where map[string]string, whereDocument []chromem.WhereDocument) ([]vs.Document, error)

type BasicRetriever

type BasicRetriever struct {
	TopK int
}

func (*BasicRetriever) DecodeConfig added in v0.4.11

func (r *BasicRetriever) DecodeConfig(cfg map[string]any) error

func (*BasicRetriever) Name added in v0.1.9

func (r *BasicRetriever) Name() string

func (*BasicRetriever) NormalizedScores added in v0.4.13

func (r *BasicRetriever) NormalizedScores() bool

func (*BasicRetriever) Retrieve

func (r *BasicRetriever) Retrieve(ctx context.Context, store store.Store, query string, datasetIDs []string, where map[string]string, whereDocument []chromem.WhereDocument) ([]vs.Document, error)

type MergingRetriever added in v0.4.11

type MergingRetriever struct {
	TopK       int
	Retrievers []RetrieverToMerge `json:"retrievers" mapstructure:"retrievers" yaml:"retrievers"`
	// contains filtered or unexported fields
}

func (*MergingRetriever) DecodeConfig added in v0.4.11

func (r *MergingRetriever) DecodeConfig(cfg map[string]any) error

func (*MergingRetriever) Name added in v0.4.11

func (r *MergingRetriever) Name() string

func (*MergingRetriever) NormalizedScores added in v0.4.13

func (r *MergingRetriever) NormalizedScores() bool

func (*MergingRetriever) Retrieve added in v0.4.11

func (r *MergingRetriever) Retrieve(ctx context.Context, store store.Store, query string, datasetIDs []string, where map[string]string, whereDocument []chromem.WhereDocument) ([]vs.Document, error)

type Retriever

type Retriever interface {
	Retrieve(ctx context.Context, store store.Store, query string, datasetIDs []string, where map[string]string, whereDocument []chromem.WhereDocument) ([]vs.Document, error)
	Name() string
	DecodeConfig(cfg map[string]any) error
	NormalizedScores() bool // whether the retriever returns normalized scores
}

func GetDefaultRetriever

func GetDefaultRetriever() Retriever

func GetRetriever

func GetRetriever(name string) (Retriever, error)

type RetrieverToMerge added in v0.4.11

type RetrieverToMerge struct {
	Name    string         `json:"name,omitempty" mapstructure:"name" yaml:"name"`
	Weight  *float32       `json:"weight,omitempty" mapstructure:"weight" yaml:"weight"`
	Options map[string]any `json:"options,omitempty" mapstructure:"options" yaml:"options"`
}

type RoutingRetriever added in v0.1.8

type RoutingRetriever struct {
	Model             llm.LLMConfig
	AvailableDatasets []string
	TopK              int
}

func (*RoutingRetriever) DecodeConfig added in v0.4.11

func (r *RoutingRetriever) DecodeConfig(cfg map[string]any) error

func (*RoutingRetriever) Name added in v0.1.9

func (r *RoutingRetriever) Name() string

func (*RoutingRetriever) NormalizedScores added in v0.4.13

func (r *RoutingRetriever) NormalizedScores() bool

func (*RoutingRetriever) Retrieve added in v0.1.8

func (r *RoutingRetriever) Retrieve(ctx context.Context, store store.Store, query string, datasetIDs []string, where map[string]string, whereDocument []chromem.WhereDocument) ([]vs.Document, error)

type SubqueryRetriever added in v0.1.8

type SubqueryRetriever struct {
	Model llm.LLMConfig
	Limit int
	TopK  int
}

func (*SubqueryRetriever) DecodeConfig added in v0.4.11

func (s *SubqueryRetriever) DecodeConfig(cfg map[string]any) error

func (*SubqueryRetriever) Name added in v0.1.9

func (s *SubqueryRetriever) Name() string

func (*SubqueryRetriever) NormalizedScores added in v0.4.13

func (s *SubqueryRetriever) NormalizedScores() bool

func (*SubqueryRetriever) Retrieve added in v0.1.8

func (s *SubqueryRetriever) Retrieve(ctx context.Context, store store.Store, query string, datasetIDs []string, where map[string]string, whereDocument []chromem.WhereDocument) ([]vs.Document, error)

Jump to

Keyboard shortcuts

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