/** Catalog of embedding models supported by enquire. Add new entries by * pinning the Xenova-converted ONNX model id + the dim count + a friendly * alias users pass on the CLI. */ export interface EmbeddingModel { /** CLI-friendly alias passed via `--embedding-model `. */ alias: string; /** HuggingFace model id (Xenova-converted to ONNX). */ hfId: string; /** Output vector dimensionality (384 for MiniLM family). */ dim: number; /** Approximate disk footprint in MB after download, for progress messages. */ approxSizeMB: number; /** True if this model has been trained on multilingual data. */ multilingual: boolean; /** Maximum input tokens before transformers.js truncates. */ maxTokens: number; } /** * Catalog of supported embedding models, keyed by CLI-friendly alias. * Add new entries by pinning the Xenova-converted ONNX model id, dim * count, and approximate download size. Frozen at module load so * runtime can't accidentally mutate. */ export declare const EMBEDDING_MODELS: Readonly>; /** Default model alias when the user doesn't pass `--embedding-model`. */ export declare const DEFAULT_MODEL_ALIAS = "multilingual"; /** * Pure helper: given the resolved main entry of `@huggingface/transformers` * (as returned by `require.resolve("@huggingface/transformers")`), derive the * package's `.cache` directory — the location transformers.js v3 uses for * downloaded model weights (`/.cache/Xenova//`). * * Works for BOTH layouts npm produces: * - hoisted: `/node_modules/@huggingface/transformers/dist/…` * - nested: `/node_modules/@oomkapwn/enquire-mcp/node_modules/ * @huggingface/transformers/dist/…` ← global-install case * by slicing at the LAST `node_modules/@huggingface/transformers` segment * (innermost wins, matching Node's own resolution). * * @param resolvedMain Absolute path to the transformers main module. * @returns The `.cache` dir path, or `null` if the marker isn't present. * @example deriveTransformersCacheDir("/a/node_modules/@huggingface/transformers/dist/x.cjs") * // → "/a/node_modules/@huggingface/transformers/.cache" */ export declare function deriveTransformersCacheDir(resolvedMain: string): string | null; /** * Resolve the directory where transformers.js actually caches model weights on * THIS install — resolved relative to the running module (so it is correct for * a global `npm i -g` install, where the model lives inside the package's own * nested `node_modules`, NOT under `~/.cache/huggingface`). * * This is the single source of truth for the model-cache path: `doctor`'s * health probe and `install-model`'s "cached under …" message both call it, so * the diagnostic and the success message can never disagree with reality * (the v3.9.1 bug-report Issues 1 + 2: doctor false-negative + wrong path). * * Resolution-only — does NOT import/load the ONNX runtime, so it keeps the * `doctor` fast-read-only promise. Returns `null` if the optional dependency * isn't installed (resolve throws → caught). * * @returns Absolute `.cache` dir path, or `null` if transformers isn't installed. */ export declare function resolveTransformersCacheDir(): string | null; /** * Look up an entry in the {@link EMBEDDING_MODELS} catalog. Throws with * a list of known aliases if the input is unknown — surfaces typos at * CLI parse time rather than after a 120MB model download. * * @param alias - Model alias, or `undefined` for the default ({@link DEFAULT_MODEL_ALIAS}). * @returns The matching {@link EmbeddingModel} entry. * @throws {Error} If `alias` isn't a known catalog key. */ export declare function resolveModel(alias: string | undefined): EmbeddingModel; /** Opaque handle for a loaded embedder. Constructed via `loadEmbedder()`. */ export interface Embedder { readonly model: EmbeddingModel; /** Embed a batch of texts. Each text is L2-normalized; output is one * Float32Array per input, length === model.dim. */ embed(texts: readonly string[]): Promise; } export declare function setEmbeddingsOffline(on?: boolean): void; export declare function isEmbeddingsOffline(): boolean; /** Force transformers.js to local-cache-only when serve has set the offline flag. * Idempotent; a no-op when online (build-embeddings). * v3.11.0-rc.12 (rc.11-audit L-2) — exported so a unit test asserts the WIRE-UP * (a transformers.js-shaped `{ env }` actually gets `allowRemoteModels=false`), * not merely that `setEmbeddingsOffline` flips the flag. */ export declare function applyOfflineEnv(mod: unknown): void; /** v3.10.0-rc.42 (F1) — translate a serve-offline model-load failure (with * allowRemoteModels=false the CDN fallback is blocked, so a failure is almost always a * cache miss) into an actionable fail-closed error. Pure → unit-testable without a model. */ export declare function offlineModelLoadError(alias: string, hfId: string, _original: unknown): Error; export declare function loadEmbedder(alias?: string): Promise; /** Cosine similarity between two L2-normalized vectors (= dot product). */ export declare function cosineSim(a: Float32Array, b: Float32Array): number; /** BGE reranker model catalog — analogous to `EMBEDDING_MODELS`. */ export interface RerankerModel { /** CLI-friendly alias passed via `--reranker-model `. */ alias: string; /** HuggingFace model id (Xenova-converted to ONNX). */ hfId: string; /** Approximate disk footprint in MB after download. */ approxSizeMB: number; /** True if trained on multilingual data. */ multilingual: boolean; /** Max combined (query + passage) tokens — BGE base is 512. */ maxTokens: number; } /** * Catalog of supported cross-encoder reranker models, keyed by CLI alias. * Each entry trades off quality vs latency vs download size; see comments * inline for guidance. Frozen at module load. */ export declare const RERANKER_MODELS: Readonly>; export declare const DEFAULT_RERANKER_ALIAS = "rerank-bge"; /** * Look up an entry in the {@link RERANKER_MODELS} catalog. Throws with * a list of known aliases if the input is unknown. * * @param alias - Reranker alias, or `undefined` for the default * ({@link DEFAULT_RERANKER_ALIAS}). * @returns The matching {@link RerankerModel} entry. * @throws {Error} If `alias` isn't a known catalog key. */ export declare function resolveRerankerModel(alias: string | undefined): RerankerModel; /** Opaque handle for a loaded reranker. Constructed via `loadReranker()`. */ export interface Reranker { readonly model: RerankerModel; /** * Score (query, passage) pairs. Higher = more relevant. BGE rerankers * return logits in roughly [-10, +10]; we apply sigmoid to get [0, 1] for * comparable scoring across models. Truncation of overly-long passages * is the model's responsibility (it'll silently chop at maxTokens). * * Returns one score per passage in input order. */ score(query: string, passages: readonly string[]): Promise; } export declare function loadReranker(alias?: string): Promise; //# sourceMappingURL=embeddings.d.ts.map