rerank

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CrossEncoder

type CrossEncoder struct {
	// contains filtered or unexported fields
}

CrossEncoder uses a CrossEncoder model to rerank results.

func NewCrossEncoder

func NewCrossEncoder(llm chat.Client, opts ...CrossEncoderOption) *CrossEncoder

NewCrossEncoder creates a new cross-encoder reranker.

func (*CrossEncoder) Enhance

func (r *CrossEncoder) Enhance(ctx context.Context, query *core.Query, chunks []*core.Chunk) ([]*core.Chunk, error)

Enhance implements core.ResultEnhancer.

type CrossEncoderOption

type CrossEncoderOption func(*CrossEncoder)

CrossEncoderOption configures a CrossEncoder instance.

func WithRerankCollector

func WithRerankCollector(collector observability.Collector) CrossEncoderOption

WithRerankCollector sets the collector.

func WithRerankLogger

func WithRerankLogger(logger logging.Logger) CrossEncoderOption

WithRerankLogger sets the logger.

func WithRerankTopK

func WithRerankTopK(k int) CrossEncoderOption

WithRerankTopK sets the number of results to keep.

type Reranker

type Reranker interface {
	// Rerank re-scores a list of chunks against the query and returns the topK most relevant chunks.
	Rerank(ctx context.Context, query string, chunks []*core.Chunk, topK int) ([]*core.Chunk, []float32, error)
}

Reranker defines the interface for Cross-Encoder re-ranking models (e.g., bge-reranker). It performs a deep semantic interaction between the query and the retrieved chunks.

Jump to

Keyboard shortcuts

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