/**
 * Cross-Encoder Reranker for RAG
 *
 * Implements cross-encoder based reranking for improved RAG retrieval precision.
 * Cross-encoders jointly encode query and document for more accurate relevance scoring.
 *
 * Research basis:
 * - "Sentence-BERT" (Reimers & Gurevych, 2019): Cross-encoder architecture
 * - "MS MARCO" benchmark: Cross-encoder reranking improvements
 * - ColBERT, MonoT5: Modern reranking techniques
 *
 * Architecture:
 * - Stage 1: Fast bi-encoder retrieval (existing RAG)
 * - Stage 2: Cross-encoder reranking of top-K candidates
 *
 * Benefits:
 * - Higher precision in top results
 * - Better semantic matching
 * - Context-aware relevance scoring
 */
import { EventEmitter } from 'events';
import { ScoredChunk, CodeChunk } from './codebase-rag/types.js';
export interface RerankerConfig {
    /** Maximum candidates to rerank (default: 50) */
    maxCandidates: number;
    /** Final top-K to return after reranking (default: 10) */
    topK: number;
    /** Minimum score threshold (0-1) */
    minScore: number;
    /** Weight for original bi-encoder score (0-1) */
    biEncoderWeight: number;
    /** Weight for cross-encoder score (0-1) */
    crossEncoderWeight: number;
    /** Enable query expansion */
    enableQueryExpansion: boolean;
    /** Cache TTL in milliseconds */
    cacheTTL: number;
}
export interface RerankedResult {
    chunk: CodeChunk;
    originalScore: number;
    crossEncoderScore: number;
    finalScore: number;
    rank: number;
    explanation?: string;
}
export interface RerankerStats {
    candidatesProcessed: number;
    resultsReturned: number;
    avgOriginalScore: number;
    avgCrossEncoderScore: number;
    avgFinalScore: number;
    processingTimeMs: number;
}
export declare class CrossEncoderReranker extends EventEmitter {
    private config;
    private scorer;
    private expander;
    private cache;
    constructor(config?: Partial<RerankerConfig>);
    /**
     * Rerank candidates using cross-encoder scoring
     */
    rerank(query: string, candidates: ScoredChunk[]): {
        results: RerankedResult[];
        stats: RerankerStats;
    };
    /**
     * Rerank with diversity (MMR - Maximal Marginal Relevance)
     */
    rerankWithDiversity(query: string, candidates: ScoredChunk[], lambda?: number): {
        results: RerankedResult[];
        stats: RerankerStats;
    };
    /**
     * Calculate similarity between two documents
     */
    private calculateSimilarity;
    /**
     * Generate cache key
     */
    private getCacheKey;
    /**
     * Calculate statistics
     */
    private calculateStats;
    /**
     * Cleanup old cache entries
     */
    private cleanupCache;
    /**
     * Clear cache
     */
    clearCache(): void;
    /**
     * Get configuration
     */
    getConfig(): RerankerConfig;
    /**
     * Update configuration
     */
    updateConfig(updates: Partial<RerankerConfig>): void;
    /**
     * Format status
     */
    formatStatus(): string;
    /**
     * Dispose resources and cleanup
     */
    dispose(): void;
}
export declare function getCrossEncoderReranker(config?: Partial<RerankerConfig>): CrossEncoderReranker;
export declare function resetCrossEncoderReranker(): void;
