Documentation ¶
Overview ¶
Package postprocessors is basically the same as package transformers, but used at a different stage of the RAG pipeline
Index ¶
Constants ¶
View Source
const BM25PostprocessorName = "bm25"
View Source
const CohereRerankPostprocessorName = "cohere_rerank"
View Source
const ContentFilterPostprocessorName = "content_filter"
View Source
const ContentSubstringFilterPostprocessorName = "content_substring_filter"
View Source
const ReducePostprocessorName = "reduce"
View Source
const SimilarityPostprocessorName = "similarity"
Variables ¶
View Source
var PostprocessorMap = map[string]Postprocessor{ transformers.ExtraMetadataName: NewTransformerWrapper(&transformers.ExtraMetadata{}), transformers.KeywordExtractorName: NewTransformerWrapper(&transformers.KeywordExtractor{}), transformers.FilterMarkdownDocsNoContentName: NewTransformerWrapper(&transformers.FilterMarkdownDocsNoContent{}), transformers.MetadataManipulatorName: NewTransformerWrapper(&transformers.MetadataManipulator{}), SimilarityPostprocessorName: &SimilarityPostprocessor{}, ContentSubstringFilterPostprocessorName: &ContentSubstringFilterPostprocessor{}, ContentFilterPostprocessorName: &ContentFilterPostprocessor{}, CohereRerankPostprocessorName: &CohereRerankPostprocessor{}, ReducePostprocessorName: &ReducePostprocessor{}, BM25PostprocessorName: &BM25Postprocessor{}, }
Functions ¶
This section is empty.
Types ¶
type BM25Postprocessor ¶ added in v0.4.11
type BM25Postprocessor struct { TopN int SparseWeight float64 // How to weight the BM25 scores against the similarity scores from dense vector search 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 (*BM25Postprocessor) Name ¶ added in v0.4.11
func (c *BM25Postprocessor) Name() string
func (*BM25Postprocessor) Transform ¶ added in v0.4.11
func (c *BM25Postprocessor) Transform(ctx context.Context, response *types.RetrievalResponse) error
type CohereRerankPostprocessor ¶ added in v0.1.7
type CohereRerankPostprocessor struct { ApiKey string `json:"apiKey" yaml:"apiKey"` Model string TopN int }
func (*CohereRerankPostprocessor) Name ¶ added in v0.1.9
func (c *CohereRerankPostprocessor) Name() string
func (*CohereRerankPostprocessor) Transform ¶ added in v0.1.7
func (c *CohereRerankPostprocessor) Transform(ctx context.Context, response *types.RetrievalResponse) error
type ContentFilterPostprocessor ¶ added in v0.1.7
type ContentFilterPostprocessor struct { Question string // Question about the content, that can be answered with yes or no Include bool // Whether to include or exclude the documents for which the answer is yes LLM llm.LLM }
func (*ContentFilterPostprocessor) Name ¶ added in v0.1.9
func (c *ContentFilterPostprocessor) Name() string
func (*ContentFilterPostprocessor) Transform ¶ added in v0.1.7
func (c *ContentFilterPostprocessor) Transform(ctx context.Context, response *types.RetrievalResponse) error
type ContentSubstringFilterPostprocessor ¶ added in v0.1.7
func (*ContentSubstringFilterPostprocessor) Name ¶ added in v0.1.9
func (c *ContentSubstringFilterPostprocessor) Name() string
func (*ContentSubstringFilterPostprocessor) Transform ¶ added in v0.1.7
func (c *ContentSubstringFilterPostprocessor) Transform(ctx context.Context, response *types.RetrievalResponse) error
type Postprocessor ¶
type Postprocessor interface { Transform(ctx context.Context, response *types.RetrievalResponse) error Name() string }
Postprocessor is similar to types.DocumentTransformer, but can take into account the retrieval query
func GetPostprocessor ¶
func GetPostprocessor(name string) (Postprocessor, error)
type ReducePostprocessor ¶ added in v0.4.8
type ReducePostprocessor struct {
TopK int
}
func (*ReducePostprocessor) Name ¶ added in v0.4.8
func (s *ReducePostprocessor) Name() string
func (*ReducePostprocessor) Transform ¶ added in v0.4.8
func (s *ReducePostprocessor) Transform(ctx context.Context, response *types.RetrievalResponse) error
type SimilarityPostprocessor ¶ added in v0.1.7
type SimilarityPostprocessor struct { Threshold float32 KeepMin int // KeepMin the top n documents, regardless of the threshold }
func (*SimilarityPostprocessor) Name ¶ added in v0.1.9
func (s *SimilarityPostprocessor) Name() string
func (*SimilarityPostprocessor) Transform ¶ added in v0.1.7
func (s *SimilarityPostprocessor) Transform(ctx context.Context, response *types.RetrievalResponse) error
type TransformerWrapper ¶ added in v0.1.7
type TransformerWrapper struct {
DocumentTransformer types.DocumentTransformer
}
func NewTransformerWrapper ¶ added in v0.1.7
func NewTransformerWrapper(transformer types.DocumentTransformer) *TransformerWrapper
func (*TransformerWrapper) Decode ¶ added in v0.4.12
func (t *TransformerWrapper) Decode(cfg map[string]any) error
func (*TransformerWrapper) Name ¶ added in v0.1.9
func (t *TransformerWrapper) Name() string
func (*TransformerWrapper) Transform ¶ added in v0.1.7
func (t *TransformerWrapper) Transform(ctx context.Context, response *types.RetrievalResponse) error
Click to show internal directories.
Click to hide internal directories.