/** * multimodal_vocab.ts — one flat token space shared by text and video. * * Evermind's generator ({@link ../lm/evermind_lm.EvermindLM}) is a pure * next-token predictor: it neither knows nor cares whether a token id is a BPE * text piece or a quantised video-patch code. So "make Evermind generate video" * is a *vocabulary* problem, not a model problem — lay text tokens, a handful of * modality control tokens, and the video codebook codes out on a single integer * axis, and the same model handles `(caption … … frames … )`. * * Layout (low → high): * * [ 0 .. textVocabSize ) text (BPE) — passthrough * textVocabSize + 0 (BOS_VIDEO) * textVocabSize + 1 (EOS_VIDEO) * textVocabSize + 2 (start of an intra frame) * textVocabSize + 3 (start of an inter frame) * codeBase + bank·levels·K + level·K + code residual-VQ code tokens * * where `bank ∈ {INTRA, INTER}`, `level ∈ [0, levels)`, `code ∈ [0, K)` and * `K = codebookSize`. A frame is therefore a marker followed by * `patchesPerFrame · levels` code tokens — a deterministic, self-delimiting * structure the codec can parse straight out of the generator's output. */ export declare const VIDEO_BANK_INTRA = 0; export declare const VIDEO_BANK_INTER = 1; export interface MultimodalVocabConfig { /** Size of the text (BPE) region; 0 for a pure-video model. */ textVocabSize: number; /** Residual-VQ depth (codes emitted per patch). */ levels: number; /** Entries per codebook per level per bank. */ codebookSize: number; } /** What a token id decodes to when parsing a mixed stream. */ export type TokenKind = { kind: "text"; id: number; } | { kind: "control"; control: "bosVideo" | "eosVideo" | "frameKey" | "frameDelta"; } | { kind: "code"; bank: number; level: number; code: number; }; /** * Bijective map between (text ids, control tokens, video codes) and a single * flat token id space. Owns the offset arithmetic so nothing else has to. */ export declare class MultimodalVocab { readonly textVocabSize: number; readonly levels: number; readonly codebookSize: number; readonly bosVideo: number; readonly eosVideo: number; readonly frameKey: number; readonly frameDelta: number; readonly codeBase: number; /** Total vocabulary size — pass this as EvermindLM's `vocabSize`. */ readonly size: number; private readonly perBank; constructor(cfg: MultimodalVocabConfig); /** Global token id for a residual-VQ code. */ codeToken(bank: number, level: number, code: number): number; isText(tok: number): boolean; isCode(tok: number): boolean; isVideoMarker(tok: number): boolean; /** Decompose a code token into (bank, level, code). Level/code are meaningful even if the bank differs. */ decodeCode(tok: number): { bank: number; level: number; code: number; }; /** Classify any token id in the flat space. */ classify(tok: number): TokenKind; } //# sourceMappingURL=multimodal_vocab.d.ts.map