@fanalis/models
v0.1.0
Published
Hardware tier detection + ML/DL model registry + lazy loader for the Fanalis audit toolkit.
Downloads
118
Readme
@fanalis/models
ml model loader + registry + hardware tier detection.
what's here
loader.ts—createLoader({noDownloads, log})→ModelLoader. handles download (withAbortSignal.timeout+2× declared sizecap), sha256 verify, on-disk cache, concurrent-call dedup via inflight promise map.registry.ts—MODEL_REGISTRY: Record<ModelEntry>— pin source repo + revision + size + license + optional sha256. v1 only registers entries that actually resolve on huggingface; vapor models are commented out at the bottom.tier-detect.ts—detectHardware()→HardwareProfile(cpu cores, mem GB, gpu kind, apple silicon family). picks suggested + ceiling tier.cache.ts— XDG-aware cache paths ($XDG_CACHE_HOME/fanalis/{models,work,reports}or~/Library/Caches/fanalis/*/~/.cache/fanalis/*per platform).reports.ts— atomic report persistence:<id>.json+<id>.meta.json+latest.json+index.json. prefix-id resolution. prune toFANALIS_MAX_REPORTS(default 200).
what's actually registered
3 entries in v1:
clip-vit-b32—Xenova/clip-vit-base-patch32(real, downloadable). image+text encoders for value-prop coherence checks. used by visual + conversion pillars at T≥4.qwen-1_5b-ollama—qwen2.5:1.5bvia local ollama. narrative orchestrator at T≥3.qwen-7b-ollama—qwen2.5:7bvia local ollama. narrative at T≥4.
models intentionally NOT registered (commented as post-v1 targets): laion-aesthetics, nima, uiclip, deepgaze, yolov8-ui, distilbert-cialdini, distilbert-cognitive, distilbert-secret-ner, amalfi-xgboost, llava-critic. each lists the missing primitive (no public ONNX export, training pipeline pending, etc.) so it doesn't drift to "claimed but not implemented".
checksum behaviour
if a registry entry has a pinned sha256, the loader verifies it. if not, the loader downloads + reports the computed sha so the maintainer can pin retroactively (Model X downloaded UNVERIFIED. To pin, add to registry: sha256: "..."). cache hits without a pin also log the unverified-load warning.
the 2× size cap catches grossly-oversized payloads, but a malicious mirror serving exactly the right size still passes without a pinned hash. registry pinning is the load-bearing primitive.
onnx runtime
loadONNX(modelId) lazy-imports onnxruntime-node and prefers coreml on apple silicon, cuda when CUDA_VISIBLE_DEVICES is set, cpu otherwise. session is cached per-modelId across the run. release() closes + drops the cache entry.
caveats
noDownloads: truemakes any missing model throwMissingModelErrorinstead of fetching. CLI surfaces this when the user passes--no-downloads.loadTokenizer(modelId)requires the entry to besource.type: "hf". raises if you try it on an ollama entry.- ollama entries don't get downloaded by
loader.ts— they live in the ollama daemon's cache.ensure()returns the model name (e.g.qwen2.5:1.5b) as the "path".
