Commit 3314cf5
authored
feat(constants)!: switch URLs to v0.9.0 layout + add MODEL_REGISTRY (#1148)
## Description
Refreshes every URL constant to the restructured HF layout under
`resolve/v0.9.0` and adds the typed `models` accessor.
### URL refresh
All URLs follow `<model>_<size>_<backend>_<precision>.pte`, files sit
under per-size and per-backend directories on HF.
- `modelUrls.ts` — every URL rewritten; multi-backend URLs hoisted here
so the registry stays declarative. The `lfm2_5_350m_xnnpack_8w4da.pte`
typo 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.0` retained for the `@deprecated` Llama QLoRA aliases.
### `models` accessor
New `constants/modelRegistry.ts` exports `models`, a typed accessor
grouped one-to-one with hooks:
| Group | Hook |
| ----------------------- | ----------------------------------- |
| `llm` | `useLLM` (includes vision-capable LLMs like `lfm2_5_vl_*`) |
| `classification` | `useClassification` |
| `privacy_filter` | `usePrivacyFilter` |
| `object_detection` | `useObjectDetection` |
| `pose_estimation` | `usePoseEstimation` |
| `semantic_segmentation` | `useSemanticSegmentation` |
| `instance_segmentation` | `useInstanceSegmentation` |
| `style_transfer` | `useStyleTransfer` |
| `speech_to_text` | `useSpeechToText` |
| `text_to_speech` | `useTextToSpeech` |
| `text_embedding` | `useTextEmbeddings` |
| `image_embedding` | `useImageEmbeddings` |
| `image_generation` | `useTextToImage` |
| `vad` | `useVAD` |
| `ocr` | `useOCR` / `useVerticalOCR` |
Each entry is a function — call it (optionally with `{ quant, backend
}`) to get the resolved config:
```ts
models.llm.llama3_2_3b() // default (quantized, platform-default backend)
models.llm.llama3_2_3b({ quant: false }) // base
models.llm.lfm2_5_vl_1_6b() // vision-capable LLM (same hook)
models.text_embedding.distiluse_base_multilingual_cased_v2({ backend: 'coreml' })
models.ocr({ language: 'en' }) // OCR is parameterized by language
```
- The `backend` parameter is typed to exactly the backends each model
ships with — `models.llm.llama3_2_3b({ backend: 'coreml' })` is a
compile-time error (xnnpack-only).
- Defaults to the quantized variant when `{ quant }` is omitted.
- `text_to_speech` exposes `kokoro_small`/`kokoro_medium` plus plain
voice configs under `voices.*`.
ESLint's `camelcase` rule is relaxed to `properties: 'never'` so the
snake_case property keys pass while bindings/functions stay camelCase.
### Migration
```ts
// Before // After
LLAMA3_2_1B_SPINQUANT → models.llm.llama3_2_1b()
LFM2_5_1_2B_INSTRUCT → models.llm.lfm2_5_1_2b_instruct({ quant: false })
LFM2_5_VL_1_6B_QUANTIZED → models.llm.lfm2_5_vl_1_6b()
EFFICIENTNET_V2_S → models.classification.efficientnet_v2_s()
PRIVACY_FILTER_OPENAI → models.privacy_filter.openai()
YOLO26N_POSE → models.pose_estimation.yolo26n()
WHISPER_TINY_EN → models.speech_to_text.whisper_tiny_en()
{ model: KOKORO_MEDIUM, voice: KOKORO_VOICE_AF_HEART }
→ { model: models.text_to_speech.kokoro_medium(),
voice: models.text_to_speech.voices.af_heart }
OCR_ENGLISH → models.ocr({ language: 'en' })
MODEL_REGISTRY.LLM.LLAMA3_2_3B → models.llm.llama3_2_3b()
```
Individual constant imports (`LLAMA3_2_1B_SPINQUANT`, `KOKORO_MEDIUM`,
etc.) still work — the new accessor is the recommended path. The flat
`MODEL_REGISTRY = { ALL_MODELS: {...} }` export from `modelUrls.ts` is
removed; the internal `getModelNameForUrl` lookup is preserved.
### Example apps + docs
- All example apps migrated to `models.*()`. Heavily-used groups are
destructured at the top of the file (`const segmentation =
models.semantic_segmentation;`).
- Picker entries compared by `modelName` to handle accessor-function
values.
- `bare-rn` LLM demo switched to LFM-2.5.
- Every documentation code snippet that selected a model via a named
constant is rewritten to use the typed `models.<group>.<entry>()`
accessor across `03-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.
- Model Registry docs page rewritten for the new accessor; the 0.8.x
version's anchor is repointed to its own version to survive the rename.
### Deprecations
- `LLAMA3_2_3B_QLORA`, `LLAMA3_2_1B_QLORA` — `@deprecated`; the .pte
files stay at `v0.8.0` and the constants still resolve those URLs. Use
`LLAMA3_2_*_SPINQUANT` going forward.
### Introduces a breaking change?
- [x] Yes
- [ ] No
URL paths under `${VERSION_TAG}` change — code that hardcoded
`resolve/v0.8.0` URLs through the constants keeps working only if it
read them at runtime. The flat `MODEL_REGISTRY` export is removed in
favour of the new `models` accessor.
### Type of change
- [x] New feature (change which adds functionality)
- [x] Other (chores, tests, code style improvements etc.)
### Tested on
- [ ] iOS
- [x] Android
`yarn typecheck` and `yarn lint` clean across the monorepo. Every
example app runs against the v0.9.0 HF state.
### Testing instructions
```bash
yarn typecheck
yarn lint
```
In application code:
```ts
import { models } from 'react-native-executorch';
const llm = useLLM({ model: models.llm.llama3_2_3b() });
const emb = useTextEmbeddings({
model: models.text_embedding.distiluse_base_multilingual_cased_v2({ backend: 'coreml' }),
});
```
### Related issues
#431
#612
### 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 warnings1 parent 1864a14 commit 3314cf5
84 files changed
Lines changed: 1714 additions & 1079 deletions
File tree
- apps
- bare-rn
- computer-vision
- app
- classification
- instance_segmentation
- object_detection
- ocr_vertical
- ocr
- pose_estimation
- segment_anything
- semantic_segmentation
- style_transfer
- text_to_image
- components/vision_camera/tasks
- llm
- app
- llm_structured_output
- llm_tool_calling
- llm
- multimodal_llm
- privacy_filter
- components
- speech/screens
- text-embeddings/app
- clip-embeddings
- text-embeddings
- docs
- docs
- 01-fundamentals
- 02-benchmarks
- 03-hooks
- 01-natural-language-processing
- 02-computer-vision
- 03-executorch-bindings
- 04-typescript-api
- 01-natural-language-processing
- 02-computer-vision
- 03-executorch-bindings
- 05-utilities
- versioned_docs/version-0.8.x/05-utilities
- packages/react-native-executorch/src
- constants
- ocr
- controllers
- types
- skills
- canary/react-native-executorch/references
- react-native-executorch/references
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
| 16 | + | |
21 | 17 | | |
22 | 18 | | |
23 | 19 | | |
| |||
144 | 140 | | |
145 | 141 | | |
146 | 142 | | |
147 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
148 | 146 | | |
149 | 147 | | |
150 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | | - | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
14 | 20 | | |
15 | 21 | | |
16 | 22 | | |
| |||
22 | 28 | | |
23 | 29 | | |
24 | 30 | | |
25 | | - | |
| 31 | + | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
| |||
Lines changed: 14 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | 8 | | |
14 | | - | |
15 | | - | |
16 | 9 | | |
17 | 10 | | |
18 | 11 | | |
| |||
29 | 22 | | |
30 | 23 | | |
31 | 24 | | |
| 25 | + | |
32 | 26 | | |
33 | 27 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
42 | 39 | | |
43 | 40 | | |
44 | 41 | | |
45 | 42 | | |
46 | | - | |
| 43 | + | |
47 | 44 | | |
48 | 45 | | |
49 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | 9 | | |
16 | 10 | | |
17 | 11 | | |
| |||
20 | 14 | | |
21 | 15 | | |
22 | 16 | | |
| 17 | + | |
23 | 18 | | |
24 | 19 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 5 | + | |
16 | 6 | | |
17 | 7 | | |
18 | 8 | | |
| |||
22 | 12 | | |
23 | 13 | | |
24 | 14 | | |
| 15 | + | |
| 16 | + | |
25 | 17 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
33 | 25 | | |
34 | 26 | | |
35 | 27 | | |
| |||
41 | 33 | | |
42 | 34 | | |
43 | 35 | | |
44 | | - | |
45 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
46 | 39 | | |
47 | 40 | | |
48 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | | - | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | 28 | | |
32 | 29 | | |
33 | 30 | | |
| |||
48 | 45 | | |
49 | 46 | | |
50 | 47 | | |
| 48 | + | |
51 | 49 | | |
52 | 50 | | |
53 | 51 | | |
54 | 52 | | |
55 | | - | |
56 | | - | |
| 53 | + | |
| 54 | + | |
57 | 55 | | |
58 | 56 | | |
59 | 57 | | |
60 | 58 | | |
61 | 59 | | |
62 | 60 | | |
63 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
82 | 85 | | |
83 | | - | |
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
| |||
0 commit comments