/** * bench/metrics.ts — pure scoring primitives over per-position logits. * * These are the building blocks the harness composes. They are exact, allocation * -light, and numerically stable (cross-entropy reuses the engine's stable * log-sum-exp). Nothing here trains or mutates the model — benchmarking is a * read-only forward pass over held-out data. */ /** Natural log of 2 — used to convert nats → bits. */ export declare const LN2: number; /** * Indices of the `k` largest logits, descending. O(V·k) — fine for the small * top-k used in accuracy scoring; avoids a full sort of the vocab per position. */ export declare function topKIndices(logits: Float32Array, k: number): number[]; /** Index of the single largest logit (argmax). */ export declare function argmax(logits: Float32Array): number; /** Perplexity from a mean cross-entropy (nats). */ export declare function perplexity(meanCrossEntropy: number): number; /** Bits-per-token from a mean cross-entropy (nats). */ export declare function bitsPerToken(meanCrossEntropy: number): number; /** Accumulator over predicted positions — cross-entropy + top-1/top-k hits. */ export interface ScoreAccumulator { tokens: number; ceSum: number; top1Hits: number; topKHits: number; } export declare function newAccumulator(): ScoreAccumulator; /** * Score one (logits, targets) pair into the accumulator. `logits[t]` predicts * `targets[t]`; positions with an out-of-range target are skipped. The caller * aligns logits/targets (next-token: logits[0..T-2] predict tokens[1..T-1]). */ export declare function scoreInto(acc: ScoreAccumulator, logits: Float32Array[], targets: number[], k: number): void; //# sourceMappingURL=metrics.d.ts.map