mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-09-29 01:17:36 -05:00
ui : read the parameters of a hub served model
Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { isLocalOption, modelParamsLabel } from './ModelsManager/utils';
|
||||
import { modelParamsLabel } from './ModelsManager/utils';
|
||||
import { HuggingFaceService } from '$lib/services';
|
||||
import type { ModelOption } from '$lib/types/models';
|
||||
|
||||
@@ -42,11 +42,12 @@
|
||||
total = null;
|
||||
|
||||
// nothing to look up when the id or the listing already carries the count
|
||||
if (!isNearViewport || !isLocalOption(option)) return;
|
||||
if (!isNearViewport) return;
|
||||
|
||||
if (option.parsedId?.params || typeof option.meta?.n_params === 'number') return;
|
||||
|
||||
// a local GGUF names no parameter count, but the Hub knows the model's
|
||||
// a GGUF names no parameter count and a provider listing never carries one,
|
||||
// but the Hub knows the model behind an `org/name` id
|
||||
const repo = option.model.split(':')[0] ?? '';
|
||||
|
||||
if (!repo.includes('/')) return;
|
||||
@@ -55,7 +56,7 @@
|
||||
|
||||
void HuggingFaceService.getDetails(repo)
|
||||
.then((details) => {
|
||||
if (!cancelled) total = details?.gguf?.total ?? null;
|
||||
if (!cancelled) total = HuggingFaceService.parameterCount(details);
|
||||
})
|
||||
// best-effort: offline or a repo we cannot read keeps the dash
|
||||
.catch(() => {});
|
||||
|
||||
+4
-1
@@ -6,6 +6,7 @@
|
||||
CollapsibleSection
|
||||
} from '$lib/components/app';
|
||||
import { Badge } from '$lib/components/ui/badge';
|
||||
import { HuggingFaceService } from '$lib/services';
|
||||
import { modelsStore } from '$lib/stores';
|
||||
import type { ApiLlamaCppServerProps } from '$lib/types/api';
|
||||
import type { HfModelDetailInfo } from '$lib/types/huggingface';
|
||||
@@ -23,6 +24,8 @@
|
||||
|
||||
let quant = $derived(modelQuantLabel(option));
|
||||
let size = $derived(modelSizeLabel(option));
|
||||
// a GGUF carries the count in its metadata, a transformers repo in its SafeTensors index
|
||||
let hubParameters = $derived(HuggingFaceService.parameterCount(hub));
|
||||
let resolvedSize = $state<string | null>(null);
|
||||
|
||||
// the router rarely reports a size, the repo tree does
|
||||
@@ -75,7 +78,7 @@
|
||||
label: 'Parameters',
|
||||
value: meta?.n_params
|
||||
? formatParameters(meta.n_params)
|
||||
: (option.parsedId?.params ?? (gguf?.total ? formatParameters(gguf.total) : null))
|
||||
: (option.parsedId?.params ?? (hubParameters ? formatParameters(hubParameters) : null))
|
||||
},
|
||||
{ label: 'Embedding Size', value: meta?.n_embd ? formatNumber(meta.n_embd) : null },
|
||||
{
|
||||
|
||||
@@ -140,7 +140,7 @@ export function modelSizeLabel(option: ModelOption): string | null {
|
||||
export function modelParamCount(option: ModelOption): number {
|
||||
const label = modelParamsLabel(
|
||||
option,
|
||||
HuggingFaceService.cachedDetails(option.model)?.gguf?.total
|
||||
HuggingFaceService.parameterCount(HuggingFaceService.cachedDetails(option.model))
|
||||
);
|
||||
const match = label ? /([\d.]+)\s*([BMK])?/i.exec(label) : null;
|
||||
const value = match ? Number.parseFloat(match[1]) : Number.NaN;
|
||||
|
||||
@@ -562,8 +562,6 @@ export class HuggingFaceService {
|
||||
return `${HF_BASE_URL}${PATH_SEPARATOR}${modelId}`;
|
||||
}
|
||||
|
||||
// Utility Methods
|
||||
|
||||
/**
|
||||
* Get most liked GGUF models
|
||||
*/
|
||||
@@ -571,6 +569,8 @@ export class HuggingFaceService {
|
||||
return this.search({ limit, sort: HfModelSort.LIKES });
|
||||
}
|
||||
|
||||
// Utility Methods
|
||||
|
||||
/**
|
||||
* Get newly released GGUF models
|
||||
*/
|
||||
@@ -668,6 +668,14 @@ export class HuggingFaceService {
|
||||
return this.search({ limit, sort: HfModelSort.TRENDING_SCORE });
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameter count a repo reports: a GGUF repo spells it out in its metadata,
|
||||
* a transformers repo reports it in its SafeTensors index.
|
||||
*/
|
||||
static parameterCount(details?: HfModelDetailInfo | null): number | null {
|
||||
return details?.gguf?.total ?? details?.safetensors?.total ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a local HF cache file path
|
||||
* (`.../models--<org>--<name>/snapshots/<sha>/<file>`) into its repo id and
|
||||
|
||||
+7
@@ -154,6 +154,13 @@ export interface HfModelDetailInfo extends HfModelInfo {
|
||||
cardData?: HfModelCardData;
|
||||
/** GGUF metadata (only present when full=true for GGUF repos) */
|
||||
gguf?: HfModelGguf;
|
||||
/** SafeTensors counts (only present when full=true for transformers repos) */
|
||||
safetensors?: {
|
||||
/** Total parameter count */
|
||||
total?: number;
|
||||
/** Per dtype parameter counts */
|
||||
parameters?: Record<string, number>;
|
||||
};
|
||||
/** Model config (only present when full=true) */
|
||||
config?: Record<string, unknown>;
|
||||
/** Total repo storage in bytes (only present when full=true) */
|
||||
|
||||
Reference in New Issue
Block a user