char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Aleksander Grygierui: Constants refactor (#26908)e21152dc9

char/aliceai-t5-moe
1.6 KiB43 linesraw
1/**
2 * Parsing of `org/ModelName[-tag][:quant]` style model IDs.
3 */
4
5export const MODEL_ID = {
6	/**
7	 * Matches an activated-parameter-count segment, e.g. `A10B`, `a2.4b`.
8	 * The leading `A`/`a` distinguishes it from a regular params segment.
9	 */
10	ACTIVATED_PARAMS_RE: /^[Aa]\d+(\.\d+)?[BbMmKkTt]$/,
11
12	/** Matches prefix for custom quantization types, e.g. `UD-Q8_K_XL`. */
13	CUSTOM_QUANTIZATION_PREFIX_RE: /^UD$/i,
14	/** Container format segments to exclude from tags (every model uses these). */
15	IGNORED_SEGMENTS: new Set(['GGUF', 'GGML']),
16	/** Sentinel value returned by `indexOf` when a substring is not found. */
17	NOT_FOUND: -1,
18
19	/** Separates `<org>` from `<model>` in a model ID, e.g. `org/ModelName`. */
20	ORG_SEPARATOR: '/',
21
22	/**
23	 * Matches a parameter-count segment, e.g. `7B`, `1.5b`, `120M`.
24	 * The optional leading `E` covers effective-parameter sizes, e.g. Gemma's
25	 * `E2B`/`E4B` (MatFormer models sized by resident params).
26	 */
27	PARAMS_RE: /^[Ee]?\d+(\.\d+)?[BbMmKkTt]$/,
28
29	/**
30	 * Matches a quantization/precision segment, e.g. `Q4_K_M`, `IQ4_XS`, `F16`, `BF16`, `MXFP4`.
31	 * Case-insensitive to handle both uppercase and lowercase inputs.
32	 */
33	QUANTIZATION_SEGMENT_RE: /^(I?Q\d+(_[A-Z0-9]+)*|F\d+|BF\d+|MXFP\d+(_[A-Z0-9]+)*)$/i,
34
35	/** Separates the model path from the quantization tag, e.g. `model:Q4_K_M`. */
36	QUANTIZATION_SEPARATOR: ':',
37
38	/** Separates named segments within the model path, e.g. `ModelName-7B-GGUF`. */
39	SEGMENT_SEPARATOR: '-',
40
41	/** Matches a trailing weight file extension, e.g. `model.gguf` -> `model`. */
42	WEIGHT_EXTENSION_RE: /\.(gguf|ggml)$/i
43};