feat(constants)!: switch URLs to v0.9.0 layout + add MODEL_REGISTRY#1148
feat(constants)!: switch URLs to v0.9.0 layout + add MODEL_REGISTRY#1148msluszniak wants to merge 1 commit into
Conversation
667d6b3 to
fc5eeb0
Compare
|
There are some problems with HF repos:
That's what I managed to find, probably someone else should also have a look at the updated HF repos. I will be testing example apps now. |
@barhanc I don't think these are sizes per se in this case. You have specified only the backbone of the final model. These models might be smaller or bigger but semantically do not indicate sizes immediately (in comparison where models from the same family have different number of parameters and the name derives from this number of is explicitly named s,m,l, xl etc.). |
modelRegistry.ts duplicated the same `${URL_PREFIX}-…/${VERSION_TAG}/…`
strings that modelUrls.ts already had inline in each Platform.OS branch.
Hoist a single set of per-backend URL constants into modelUrls.ts and
have both consumers reference them, so each URL string lives in exactly
one place.
- Add per-backend exports for efficientnet-v2-s, ssdlite320-mobilenet-v3-
large, rfdetr-nano-detector, rfdetr-nano-segmentation, fast-sam {s,x},
distiluse-base-multilingual-cased-v2.
- Add `styleTransferUrls(display, slug)` helper for the 4 style-transfer
styles; the registry's `styleTransferVariants` now consumes it.
- Drop the now-unused `URL_PREFIX, VERSION_TAG` import from
modelRegistry.ts.
Addresses #1148 (comment)
…al/tts/ocr Adopts Bartek's feedback on #1148 — the accessor is no longer dual-shaped (value AND function). Each leaf is a pure function: call it (optionally with \`{ quant, backend }\`) to get the resolved config. This eliminates the \`useState\` lazy-init footgun and \`useMemo\`/\`useCallback\` dep hazards, so pickers fall back to plain \`===\` reference equality (drops the \`sameValue\` workaround across four \`ModelPicker.tsx\` files). Renames: - \`MODEL_REGISTRY\` → \`models\` (lowercase top-level) - group keys lowercased: \`LLM\` → \`llm\`, etc. - per Kuba: \`vlm\` → \`multimodal\` (anticipates audio-capable LMs like Gemma 4) Adds: - \`models.text_to_speech\` group: \`kokoro_small\`, \`kokoro_medium\`, plus voices as plain configs under \`voices\` (no quant/backend axis). - \`models.ocr({ language })\` parameterized accessor — covers all ISO language tokens via a runtime map built from the existing \`OCR_<LANGUAGE>\` exports. Example apps (22 files, ~150 substitutions) migrated by script. bare-rn demo swapped from \`llama3_2_1b\` to \`lfm2_5_1_2b_instruct\` per Kuba's note. Docs rewritten with the new syntax + TTS + OCR sections. Relaxes the project's \`camelcase\` rule with \`properties: 'never'\` so the lowercase snake_case keys in \`models\` (which mirror the \`.pte\` filename convention) pass without per-file disables. Variable and function names still require camelCase.
Per Kuba's review on #1148 — hoist a camelCase alias for any group used ≥ 2 times in a file, e.g. const instanceSegmentation = models.instance_segmentation; const objectDetection = models.object_detection; Then \`models.instance_segmentation.yolo26n_seg()\` becomes \`instanceSegmentation.yolo26n_seg()\`. Applied to 14 files where it actually reduces noise. Skips aliasing when the camelCase name would shadow an existing local identifier — common in the LLM/STT/embeddings screens where \`llm\`, \`speechToText\`, \`imageEmbedding\` etc. already name hook return values or temporaries.
barhanc
left a comment
There was a problem hiding this comment.
In docs we have many snippets that use the old API for selecting the model, these should probably be changed as well.
We can just put all these models under |
|
Agreed, I'm also in favour of moving them under llm. Also regarding this one:
Do you have anything particular solution on your mind? |
|
I guess we already have something like this in place, since the user can check it like this const LFM2_5_VL = models.llm.lfm2_5_vl_1_6b()
console.log(LFM2_5_VL.capabilities) |
8bf0010 to
6704118
Compare
|
TODO when rebasing after #1132 lands: unify the Whisper URLs (no separate
|
c87ba4a to
6950512
Compare
6950512 to
5e10f9a
Compare
Description
Refreshes every URL constant to the restructured HF layout under
resolve/v0.9.0and adds the typedmodelsaccessor.URL refresh
All URLs follow
<model>_<size>_<backend>_<precision>.pte, files situnder per-size and per-backend directories on HF.
modelUrls.ts— every URL rewritten; multi-backend URLs hoisted here so the registry stays declarative. Thelfm2_5_350m_xnnpack_8w4da.ptetypo is corrected to_8da4w.pte.ocr/models.ts,tts/models.ts,tts/voices.ts— paths updated to the new shape.versions.ts—VERSION_TAG → resolve/v0.9.0;PREVIOUS_VERSION_TAG = resolve/v0.8.0retained for the@deprecatedLlama QLoRA aliases.modelsaccessorNew
constants/modelRegistry.tsexportsmodels, a typed accessor grouped one-to-one with hooks:llmuseLLM(includes vision-capable LLMs likelfm2_5_vl_*)classificationuseClassificationprivacy_filterusePrivacyFilterobject_detectionuseObjectDetectionpose_estimationusePoseEstimationsemantic_segmentationuseSemanticSegmentationinstance_segmentationuseInstanceSegmentationstyle_transferuseStyleTransferspeech_to_textuseSpeechToTexttext_to_speechuseTextToSpeechtext_embeddinguseTextEmbeddingsimage_embeddinguseImageEmbeddingsimage_generationuseTextToImagevaduseVADocruseOCR/useVerticalOCREach entry is a function — call it (optionally with
{ quant, backend }) to get the resolved config:backendparameter is typed to exactly the backends each model ships with —models.llm.llama3_2_3b({ backend: 'coreml' })is a compile-time error (xnnpack-only).{ quant }is omitted.text_to_speechexposeskokoro_small/kokoro_mediumplus plain voice configs undervoices.*.ESLint's
camelcaserule is relaxed toproperties: 'never'so the snake_case property keys pass while bindings/functions stay camelCase.Migration
Individual constant imports (
LLAMA3_2_1B_SPINQUANT,KOKORO_MEDIUM, etc.) still work — the new accessor is the recommended path. The flatMODEL_REGISTRY = { ALL_MODELS: {...} }export frommodelUrls.tsis removed; the internalgetModelNameForUrllookup is preserved.Example apps + docs
models.*(). Heavily-used groups are destructured at the top of the file (const segmentation = models.semantic_segmentation;).modelNameto handle accessor-function values.bare-rnLLM demo switched to LFM-2.5.models.<group>.<entry>()accessor across03-hooks/**,04-typescript-api/**,01-fundamentals/**, etc. The webrtc-integration page intentionally keeps the named-constant style — the snippet reads cleaner alongside imports from other libraries.Deprecations
LLAMA3_2_3B_QLORA,LLAMA3_2_1B_QLORA—@deprecated; the .pte files stay atv0.8.0and the constants still resolve those URLs. UseLLAMA3_2_*_SPINQUANTgoing forward.Introduces a breaking change?
URL paths under
${VERSION_TAG}change — code that hardcodedresolve/v0.8.0URLs through the constants keeps working only if it read them at runtime. The flatMODEL_REGISTRYexport is removed in favour of the newmodelsaccessor.Type of change
Tested on
yarn typecheckandyarn lintclean across the monorepo. Every example app runs against the v0.9.0 HF state.Testing instructions
In application code:
Related issues
#431
#612
Checklist