reranker

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package reranker provides reranking implementations for improving retrieval quality.

Index

Constants

This section is empty.

Variables

View Source
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)

type Reranker

type Reranker = domain.Reranker

Reranker — опциональный интерфейс для переранжирования результатов retrieval.

Jump to

Keyboard shortcuts

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