feat(constants)!: switch URLs to v0.9.0 layout + add MODEL_REGISTRY#1148
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) |
c87ba4a to
6950512
Compare
6950512 to
5e10f9a
Compare
Conflict-resolution slip flipped "need to" -> "need ot" in the LLMController delete-while-generating error. The voice_chat screen was deleted in #1132 but the drawer entry was left behind.
The two-step install layout from #1146 (separate core / resource-fetcher sections with per-package-manager tabs) was lost during the rebase. Restore main's version verbatim.
Keep the registry-accessor useLLM example but bring back the npm / pnpm / yarn Tabs around the resource-fetcher install commands that were lost during the rebase.
The trailing block linking to the typedoc-generated selectByPoint / selectByBox / selectByText pages was dropped during the rebase.
The reference section's explanation that `code` is typed `RnExecutorchErrorCode | number` (and the guidance to include a `default` branch when switching on it) was lost during the rebase, along with two row wordings in the input/runtime error tables.
Rebase artifact — this file shouldn't have been touched by the PR at all.
The previous link pointed at /docs/next/api-reference/variables/MODEL_REGISTRY, which now 404s because this PR removes the MODEL_REGISTRY export from main. Switch to the 0.8.x snapshot's own api-reference page using the canonical .md-suffixed relative form so docusaurus resolves it through the source-file URL map.
DownloadInterrupted, ModuleNotLoaded and ModelGenerating already resolve to the exact same strings through DefaultErrorMessages in errorUtils.ts, so the per-call-site duplicates were dead weight that #1141 was meant to remove.
…on accessors The instance_segmentation namespace already implies segmentation, so the _seg suffix on yolo26* and rf_detr_nano was redundant and inconsistent with pose_estimation.yolo26n (no _pose suffix). Drop the suffix and update demo apps and docs accordingly.
…entation FastSAM is consumed via useInstanceSegmentation, so its accessor belongs in models.instance_segmentation. Move fastsam_s/fastsam_x and update demo apps and docs accordingly.
The craft() OCR accessor was throwing a plain Error when called with an unpublished language; use RnExecutorchError with LanguageNotSupported so consumers can switch on code like every other error path.
The three sanity checks in firstBackend/resolveCell/resolveVariant were the last plain Error throws in modelRegistry. The first two are truly-internal invariants -> Internal; the backend-missing one is reachable from untyped callers -> InvalidConfig.
## Description Tightens the LFM2.5 quickstart in the root README and all five translated readmes: - Flags the quickstart as Expo-targeted and links bare React Native users to the [Getting Started guide](https://docs.swmansion.com/react-native-executorch/docs/fundamentals/getting-started) instead of duplicating the bare install steps inline. - Drops the `react-native-executorch-bare-resource-fetcher` / `@dr.pogodin/react-native-fs` / `@kesha-antonov/react-native-background-downloader` lines from the install snippet now that the bare path lives in the docs. - Switches the sample to the model-registry accessor (`models.llm.lfm2_5_1_2b_instruct()`), matching the apps and the new MODEL_REGISTRY flow added in #1148. - Normalizes `yarn <ios|android>` placeholders — no spaces inside the angle brackets. ### Introduces a breaking change? - [ ] Yes - [x] No ### Type of change - [ ] Bug fix (change which fixes an issue) - [ ] New feature (change which adds functionality) - [x] Documentation update (improves or adds clarity to existing documentation) - [ ] Other (chores, tests, code style improvements etc.) ### Tested on - [ ] iOS - [ ] Android ### Testing instructions Docs-only change. Render the affected readmes on GitHub and confirm: - Quickstart heading is followed by the Expo / bare-RN doc-link sentence. - Install block lists only the Expo fetcher trio. - Code sample imports `models` and calls `models.llm.lfm2_5_1_2b_instruct()`. - No `< ios | android >` (with spaces) remains. ### Screenshots N/A ### Related issues N/A ### Checklist - [x] I have performed a self-review of my code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have updated the documentation accordingly - [x] My changes generate no new warnings ### Additional notes The translated readmes carry through the same edits with the disclaimer + doc link translated into each language; the docs URL is shared across all of them.
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