/** * Semantic Embeddings for Drift Detection * * Provides optional embedding-based similarity for improved paraphrase detection. * Uses Ollama for local embeddings (free, no API cost) or can be extended * for other providers. */ import type { ConfidenceFactor } from './types.js'; /** * Interface for embedding providers. */ export interface EmbeddingProvider { /** Provider name */ name: string; /** Generate embedding vector for text */ embed(text: string): Promise; /** Calculate similarity between two embedding vectors */ similarity(a: number[], b: number[]): number; /** Check if the provider is available */ isAvailable(): Promise; } /** * Ollama-based local embeddings using nomic-embed-text model. * Free and runs locally without API costs. */ export declare class OllamaEmbeddings implements EmbeddingProvider { name: string; private baseUrl; private model; private cache; constructor(options?: { baseUrl?: string; model?: string; }); isAvailable(): Promise; embed(text: string): Promise; similarity(a: number[], b: number[]): number; clearCache(): void; } /** * Calculate cosine similarity between two vectors. * Returns a value between -1 and 1, where 1 is identical. */ export declare function cosineSimilarity(a: number[], b: number[]): number; /** * Configuration for embedding-enhanced comparison. */ export interface EmbeddingConfig { /** Whether to use embeddings (default: false) */ enabled: boolean; /** Embedding provider to use */ provider: EmbeddingProvider; /** Weight for embedding similarity in overall confidence (0-1) */ weight: number; /** Minimum similarity to consider a match (0-1) */ matchThreshold: number; /** Timeout for embedding requests in ms */ timeout: number; } /** * Default embedding configuration. */ export declare const DEFAULT_EMBEDDING_CONFIG: EmbeddingConfig; /** * Result of embedding-based comparison. */ export interface EmbeddingComparisonResult { /** Whether embeddings were successfully used */ used: boolean; /** Cosine similarity score (0-1) */ similarity: number; /** Similarity as percentage (0-100) */ similarityPercent: number; /** Whether similarity meets match threshold */ meetsThreshold: boolean; /** Error message if embeddings failed */ error?: string; } /** * Compare two texts using embeddings. */ export declare function compareWithEmbeddings(text1: string, text2: string, config?: Partial): Promise; /** * Create a confidence factor from embedding comparison. */ export declare function createEmbeddingFactor(result: EmbeddingComparisonResult): ConfidenceFactor | null; /** * Enhanced semantic comparator that optionally uses embeddings. */ export declare class EmbeddingEnhancedComparator { private config; private providerChecked; private providerAvailable; constructor(config?: Partial); /** * Check provider availability (cached). */ checkAvailability(): Promise; /** * Get embedding similarity as an additional confidence factor. * Falls back gracefully if embeddings are unavailable. */ getEmbeddingFactor(text1: string, text2: string): Promise; /** * Determine if texts match based on embedding similarity alone. */ matchesByEmbedding(text1: string, text2: string): Promise; } /** * Check if Ollama is available and has the embedding model. */ export declare function checkOllamaEmbeddings(): Promise<{ available: boolean; hasModel: boolean; modelName: string; error?: string; }>; //# sourceMappingURL=embeddings.d.ts.map