postprocessors

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package postprocessors is basically the same as package transformers, but used at a different stage of the RAG pipeline

Index

Constants

This section is empty.

Variables

View Source
var PostprocessorMap = map[string]Postprocessor{
	"extra_metadata":                  NewTransformerWrapper(&transformers.ExtraMetadata{}),
	"keywords":                        NewTransformerWrapper(&transformers.KeywordExtractor{}),
	"filter_markdown_docs_no_content": NewTransformerWrapper(&transformers.FilterMarkdownDocsNoContent{}),
	"similarity":                      &SimilarityPostprocessor{},
	"content_substring_filter":        &ContentSubstringFilterPostprocessor{},
	"content_filter":                  &ContentFilterPostprocessor{},
	"cohere_rerank":                   &CohereRerankPostprocessor{},
}

Functions

This section is empty.

Types

type CohereRerankPostprocessor added in v0.1.7

type CohereRerankPostprocessor struct {
	ApiKey string `json:"apiKey" yaml:"apiKey"`
	Model  string
	TopN   int
}

func (*CohereRerankPostprocessor) Transform added in v0.1.7

func (c *CohereRerankPostprocessor) Transform(ctx context.Context, query string, docs []vs.Document) ([]vs.Document, 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) Transform added in v0.1.7

func (c *ContentFilterPostprocessor) Transform(ctx context.Context, _ string, docs []vs.Document) ([]vs.Document, error)

type ContentSubstringFilterPostprocessor added in v0.1.7

type ContentSubstringFilterPostprocessor struct {
	Contains    []string
	NotContains []string
}

func (*ContentSubstringFilterPostprocessor) Transform added in v0.1.7

type Postprocessor

type Postprocessor interface {
	Transform(ctx context.Context, query string, docs []vs.Document) ([]vs.Document, error)
}

Postprocessor is similar to types.DocumentTransformer, but can take into account the retrieval query

func GetPostprocessor

func GetPostprocessor(name string) (Postprocessor, error)

type SimilarityPostprocessor added in v0.1.7

type SimilarityPostprocessor struct {
	Threshold float32
}

func (*SimilarityPostprocessor) Transform added in v0.1.7

func (s *SimilarityPostprocessor) Transform(_ context.Context, query string, docs []vs.Document) ([]vs.Document, error)

type TransformerWrapper added in v0.1.7

type TransformerWrapper struct {
	types.DocumentTransformer
}

func NewTransformerWrapper added in v0.1.7

func NewTransformerWrapper(transformer types.DocumentTransformer) *TransformerWrapper

func (*TransformerWrapper) Transform added in v0.1.7

func (t *TransformerWrapper) Transform(ctx context.Context, query string, docs []vs.Document) ([]vs.Document, error)

Jump to

Keyboard shortcuts

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