Documentation
¶
Overview ¶
Package reranker provides reranking implementations for improving retrieval quality.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidRerankerConfig = errors.New("invalid reranker config")
ErrInvalidRerankerConfig возвращается при невалидной конфигурации reranker'а.
@sk-task reranker-cross-encoder#T1.2: sentinel для валидации опций (AC-003)
Functions ¶
This section is empty.
Types ¶
type BatchReranker ¶
type BatchReranker = domain.BatchReranker
BatchReranker — опциональное расширение Reranker для batch-режима.
@sk-task reranker-cross-encoder#T1.1: re-export BatchReranker interface (AC-008)
type CohereRerankOptions ¶
type CohereRerankOptions struct {
APIKey string
Model string
BaseURL string
Timeout time.Duration
MaxRetries int
MaxTokensPerDoc int
HTTPClient *http.Client
}
CohereRerankOptions задаёт параметры для Cohere Rerank API v2.
type CohereReranker ¶
type CohereReranker struct {
// contains filtered or unexported fields
}
CohereReranker реализует Reranker и BatchReranker через Cohere Rerank API v2.
func NewCohereRerank ¶
func NewCohereRerank(opts CohereRerankOptions) (*CohereReranker, error)
NewCohereRerank создаёт CohereReranker. APIKey обязателен.
@sk-task reranker-cross-encoder#T2.1: конструктор CohereReranker (AC-001, AC-003) @sk-task reranker-cross-encoder#T3.1: error handling 401/429/5xx/таймаут (AC-006)
func (*CohereReranker) Rerank ¶
func (c *CohereReranker) Rerank(ctx context.Context, query string, chunks []domain.RetrievedChunk) ([]domain.RetrievedChunk, error)
Rerank отправляет один запрос к Cohere Rerank API и возвращает переранжированные чанки.
func (*CohereReranker) RerankBatch ¶
func (c *CohereReranker) RerankBatch(ctx context.Context, queries []string, chunks []domain.RetrievedChunk) ([][]domain.RetrievedChunk, error)
RerankBatch выполняет N запросов к Cohere Rerank API конкурентно (fan-out).
@sk-task reranker-cross-encoder#T3.2: BatchReranker.RerankBatch implementation (AC-008)