/** * lm/text_embedder.ts — text → vector, on the CPU, from an `EvermindLM`. * * `EvermindLM.embed()` turns TOKENS into a `dModel` vector. Every consumer that * wants SEMANTIC RECALL wants it over TEXT, and needs the vector to be stable * across processes, so it also needs (a) the tokenizer that produced those ids * and (b) a way to tell whether a cached vector came from this exact model. This * class is that pairing, in one place, so no consumer re-derives it. * * It deliberately satisfies the SAME structural shape the memory runtime's * `embed(text)` seam expects (`MemoryStore.recallRanked(query, k, runtime)` * accepts anything with an async `embed(text): Float32Array`), so a headless host * can hand one of these straight to the memory layer and get embedding-ranked * recall with NO GPU — the CPU LM is the whole dependency. */ import type { EvermindLM, TextCodec } from "./evermind_lm.js"; /** The minimal text-embedder seam the memory/recall layers consume. */ export interface TextEmbedder { /** Embed `text` as an L2-normalised vector of length {@link dimensions}. */ embed(text: string): Promise; /** Vector width (the model's `dModel`). */ readonly dimensions: number; /** * Identity of the model+tokenizer that produces these vectors. Vectors are only * comparable within one fingerprint, so a persistent cache MUST discard entries * stamped with a different one. */ readonly fingerprint: string; } /** A tokenizer this embedder can encode through (the engine's `BPETokenizer` fits). */ export type EmbedderCodec = Pick; /** * Pairs an `EvermindLM` with the tokenizer whose ids it was trained on. * * Pure compute and stateless: caching belongs to whoever owns a lifetime (the * memory store's in-process LRU, or a host's on-disk vector cache), not here. */ export declare class EvermindTextEmbedder implements TextEmbedder { private readonly model; private readonly codec; readonly dimensions: number; readonly fingerprint: string; constructor(model: EvermindLM, codec: EmbedderCodec, /** Override the derived fingerprint (e.g. with a published model version). */ fingerprint?: string); /** * Embed `text`. Async only to match the seam — the work is synchronous CPU, so * a caller that wants the vector without a microtask can use * {@link embedSync}. */ embed(text: string): Promise; /** The synchronous form — encode with the codec, then run the CPU LM. */ embedSync(text: string): Float32Array; } //# sourceMappingURL=text_embedder.d.ts.map