import type { AuraCanonicalAsset } from "./CanonicalAsset.js"; /** * Semantic-search upgrade seam over the keyword baseline in `ranking.ts`. * * The federation layer scores assets through a single seam (`scoreAsset`); this * module provides the vector-embedding alternative the comment there promises. * Everything here is dependency-free and fully deterministic: the default * provider hashes tokens into a fixed-size vector, so the same text always * yields the same embedding with no network, keys, randomness, or wall-clock * time involved. */ /** Pluggable text embedder. Implementations must be deterministic per input. */ export interface EmbeddingProvider { /** Embed each input string into a numeric vector of uniform dimension. */ embed(texts: readonly string[]): Promise; } /** Default embedding dimensionality for {@link LocalHashEmbedding}. */ export declare const DEFAULT_EMBEDDING_DIMS = 256; /** * Deterministic, dependency-free bag-of-words embedding. * * Each token is hashed into one of `dims` buckets and summed (sign derived from * a second hash bit so unrelated tokens do not all push in the same direction), * then the vector is L2-normalized. Identical text -> identical vector; cosine * similarity of identical text is exactly 1. */ export declare class LocalHashEmbedding implements EmbeddingProvider { readonly dims: number; constructor(dims?: number); private embedOne; embed(texts: readonly string[]): Promise; } /** * Cosine similarity of two equal-length vectors. Returns 0 when either vector * is all zeros or lengths differ. For L2-normalized vectors this equals the dot * product, but we recompute norms so it is correct for any input. */ export declare function cosineSimilarity(a: readonly number[], b: readonly number[]): number; /** * Canonical text used to embed an asset: title, tags, then description. This is * the same field set the ranking baseline scores against, concatenated so a * bag-of-words embedding can capture all of them. */ export declare function assetEmbeddingText(asset: AuraCanonicalAsset): string; /** * Rank assets against a query by cosine similarity of their embeddings. * * Embeds the query and every asset's {@link assetEmbeddingText} in one batched * call to the provider, then sorts descending by score. Ties break by asset id * so the ordering is stable and deterministic. */ export declare function embeddingRanker(provider: EmbeddingProvider, query: string, assets: readonly AuraCanonicalAsset[]): Promise<{ asset: AuraCanonicalAsset; score: number; }[]>; //# sourceMappingURL=embedding.d.ts.map