Documentation
¶
Overview ¶
Package rerank provides reranking implementations for retrieval results.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain chains multiple rerankers together.
type CrossEncoder ¶
type CrossEncoder struct {
// contains filtered or unexported fields
}
CrossEncoder implements reranking using a cross-encoder model.
func NewCrossEncoder ¶
func NewCrossEncoder(cfg CrossEncoderConfig) *CrossEncoder
NewCrossEncoder creates a new cross-encoder reranker.
func (*CrossEncoder) Rerank ¶
func (r *CrossEncoder) Rerank(ctx context.Context, q retrieve.Query, items []retrieve.ContextItem) ([]retrieve.ContextItem, error)
Rerank implements retrieve.Reranker.
type CrossEncoderConfig ¶
type CrossEncoderConfig struct {
// Scorer is the cross-encoder model to use.
Scorer CrossEncoderScorer
// TopK limits output to top K results after reranking.
TopK int
// MinScore filters results below this threshold.
MinScore float64
}
CrossEncoderConfig configures the cross-encoder reranker.
type CrossEncoderScorer ¶
type CrossEncoderScorer interface {
// Score returns relevance scores for query-document pairs.
Score(ctx context.Context, query string, documents []string) ([]float64, error)
// Model returns the model name.
Model() string
}
CrossEncoderScorer scores query-document pairs using a cross-encoder model.
type Heuristic ¶
type Heuristic struct {
// contains filtered or unexported fields
}
Heuristic implements heuristic-based reranking.
func NewHeuristic ¶
func NewHeuristic(cfg HeuristicConfig) *Heuristic
NewHeuristic creates a new heuristic reranker.
type HeuristicConfig ¶
type HeuristicConfig struct {
// Strategy is the scoring strategy.
Strategy Strategy
// Weights for different signals (e.g., "similarity", "recency", "popularity").
Weights map[string]float64
// TopK limits output.
TopK int
// MinScore threshold.
MinScore float64
// BoostExactMatch boosts items containing exact query matches.
BoostExactMatch bool
// ExactMatchBoost is the boost factor for exact matches.
ExactMatchBoost float64
}
HeuristicConfig configures heuristic reranking.
Click to show internal directories.
Click to hide internal directories.