harper-fabric-embeddings
Version:
Minimal llama.cpp embedding wrapper for Harper Fabric. Talks directly to the native addon — no build tools, no CLI, no chat wrappers.
47 lines • 2.15 kB
TypeScript
/**
* Minimal GGUF header reader — just enough to answer "what pooling does this
* model declare?" without loading the model.
*
* Why it exists (issue #12): the native addon accepts no pooling option, so
* the llama.cpp context always resolves pooling from the model's own
* `<arch>.pooling_type` metadata — and when that key is missing (common in
* third-party GGUF conversions), llama.cpp falls back to an arch-dependent
* default that may silently mean-pool a last-token model. Degraded vectors,
* no error. We can't override the pooling, but we CAN verify the file
* declares what the caller expects and fail loudly at init when it doesn't.
*
* Parses only the metadata KV section (never tensor data), early-exits once
* the interesting keys are found, and skips large values (tokenizer arrays)
* without materializing them.
*/
declare const POOLING_TYPES: {
readonly none: 0;
readonly mean: 1;
readonly cls: 2;
readonly last: 3;
readonly rank: 4;
};
export type PoolingName = keyof typeof POOLING_TYPES;
export declare const POOLING_NAMES: readonly PoolingName[];
export interface GgufPoolingInfo {
/** `general.architecture`, when present (e.g. `qwen3`, `bert`). */
architecture?: string;
/** Value of the `<arch>.pooling_type` key, when declared. */
poolingType?: number;
}
/**
* Read `general.architecture` and the model's `<arch>.pooling_type` from a
* GGUF file's metadata. Matches the pooling key by `.pooling_type` suffix so
* key order relative to `general.architecture` doesn't matter. Returns what
* it found; both fields are optional — absence is data, not an error.
*/
export declare function readGgufPooling(modelPath: string): Promise<GgufPoolingInfo>;
/**
* Verify a model file declares the pooling the caller expects. The addon
* offers no pooling override, so a declaration that isn't in the file cannot
* be satisfied — fail at init (registration time) instead of silently
* producing wrong-pooling vectors.
*/
export declare function assertDeclaredPooling(modelPath: string, declared: PoolingName): Promise<void>;
export {};
//# sourceMappingURL=gguf.d.ts.map