/** * engine.ts — node-llama-cpp integration: model loading, identity, and * corpus embedding. * * Uses node-llama-cpp DIRECTLY (the same engine dependency * harper-fabric-embeddings/HFE wraps for Harper) rather than going through * HFE — flair-bench has to run with no Flair/Harper installation at all, so * it can't depend on the Harper-only wrapper package. See prefixes.ts for * how the nomic search-prefix convention HFE applies is replicated here. */ import { type Llama, type LlamaModel } from "node-llama-cpp"; import type { BenchProgressEvent, CorpusInfo, ModelBenchResult, ModelIdentity } from "./types.js"; /** Shared Llama instance for the whole batch run — one backend/GPU detection, reused across every model load. */ export declare function getSharedLlama(): Promise; export declare function corpusInfo(): CorpusInfo; export declare function computeModelIdentity(model: LlamaModel, filePath: string): Promise; /** * Full single-model benchmark: load, embed the corpus, exact-cosine rank * every query, score p@3/MRR overall and per-kind. Disposes the model * before returning so a batch run's next model starts from a clean slate. * * Peak-RSS baseline is captured BEFORE `llama.loadModel()` runs — sampling * only from inside the embedding phase (an earlier version of this * function did that) would already have the model's own weights resident * in the baseline, silently undercounting the number the spec actually * wants ("how much memory does loading+using this model cost"). Verified * against the Q4 baseline: an 80 MiB GGUF was reporting a ~24 MiB delta * before this fix, because mmap'd model weight pages had already been * counted into the baseline by the time sampling started. */ export declare function benchModel(llama: Llama, filePath: string, options?: { warmupN?: number; onProgress?: (e: BenchProgressEvent) => void; index?: number; total?: number; }): Promise;