MCPcopy
hub / github.com/Andyyyy64/whichllm / _normalize_param_count

Function _normalize_param_count

src/whichllm/models/fetcher.py:290–324  ·  view source on GitHub ↗

Normalize parameter count when metadata is inconsistent.

(
    extracted: int,
    model_id: str,
    base_model: str | None,
)

Source from the content-addressed store, hash-verified

288
289
290def _normalize_param_count(
291 extracted: int,
292 model_id: str,
293 base_model: str | None,
294) -> int:
295 """Normalize parameter count when metadata is inconsistent."""
296 authoritative = _lookup_curated_count(_AUTHORITATIVE_PARAM_COUNTS, model_id)
297 if authoritative and authoritative > 0:
298 return authoritative
299 known = _lookup_curated_count(_KNOWN_PARAM_COUNTS, model_id)
300 if extracted <= 0:
301 return known or extracted
302 if known and extracted < int(known * 0.35):
303 return known
304
305 hints = [
306 h
307 for h in (
308 _extract_size_hint_from_id(model_id),
309 _extract_size_hint_from_id(base_model),
310 )
311 if h is not None
312 ]
313 if not hints:
314 return extracted
315
316 hinted = max(hints)
317 if _is_quantized_repo_name(model_id):
318 # 量子化派生モデルはsafetensors metadataが縮んだ値になることがある
319 if extracted < int(hinted * 0.70):
320 return hinted
321 elif extracted < int(hinted * 0.35):
322 return hinted
323
324 return extracted
325
326
327# Filename quant tokens that name the same format under a different spelling

Calls 3

_lookup_curated_countFunction · 0.85
_is_quantized_repo_nameFunction · 0.85