retrievers

package
v0.4.12 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: Apache-2.0 Imports: 18 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) 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) 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) 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
}

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) 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) 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