/** * Local embedding adapter * * Provides embedding generation without external API calls. * Uses a simple but effective TF-IDF based approach for semantic similarity. * * For production use with better quality, consider using transformers.js * with a model like 'Xenova/all-MiniLM-L6-v2'. * * @packageDocumentation */ import type { EmbeddingProvider, LocalEmbeddingConfig, EmbeddingResult, BatchEmbeddingResult } from '../types/graphrag.js'; import { BaseEmbeddingAdapter } from './base.js'; /** * Local embedding adapter using TF-IDF-like approach * * This provides a simple, fast, offline embedding that works well for * finding similar skills based on shared vocabulary and structure. */ export declare class LocalEmbeddingAdapter extends BaseEmbeddingAdapter { private readonly modelName; private readonly dims; private vocabulary; private idfScores; private documentCount; constructor(config: LocalEmbeddingConfig); get provider(): EmbeddingProvider; get model(): string; get dimensions(): number; isConfigured(): boolean; /** * Tokenize text into normalized tokens */ private tokenize; /** * Calculate term frequency for a document */ private calculateTF; /** * Generate a deterministic embedding vector from text * * Uses a combination of: * 1. Token-based hashing for semantic representation * 2. N-gram features for capturing word relationships * 3. Positional encoding for word order sensitivity */ private generateEmbedding; /** * Extract character n-grams from text */ private getCharNgrams; embed(text: string): Promise; embedBatch(texts: string[]): Promise; /** * Build vocabulary from a corpus for improved embeddings * * Call this with your skill names/descriptions to improve * the quality of embeddings through proper IDF weighting. */ buildVocabulary(documents: string[]): void; /** * Get vocabulary size */ getVocabularySize(): number; } /** * Create a local embedding adapter * * @example * ```typescript * // Create adapter * const adapter = createLocalEmbeddingAdapter(); * * // Optionally build vocabulary for better quality * adapter.buildVocabulary(skillDescriptions); * * // Generate embedding * const result = await adapter.embed('Learn to write JavaScript functions'); * ``` */ export declare function createLocalEmbeddingAdapter(model?: string): LocalEmbeddingAdapter; //# sourceMappingURL=local.d.ts.map