react-native-executorch 0.8.2 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/swmansion/rnexecutorch/ETInstallerUnavailable.kt +27 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/RnExecutorchPackage.kt +12 -1
- package/common/rnexecutorch/host_objects/ModelHostObject.h +12 -1
- package/common/rnexecutorch/models/embeddings/text/TextEmbeddings.cpp +6 -0
- package/common/rnexecutorch/models/embeddings/text/TextEmbeddings.h +3 -0
- package/common/rnexecutorch/models/llm/LLM.cpp +31 -3
- package/common/rnexecutorch/models/llm/LLM.h +2 -0
- package/common/rnexecutorch/models/text_to_image/TextToImage.cpp +2 -0
- package/common/rnexecutorch/models/text_to_image/TextToImage.h +2 -0
- package/common/rnexecutorch/models/voice_activity_detection/VoiceActivityDetection.cpp +6 -0
- package/common/rnexecutorch/models/voice_activity_detection/VoiceActivityDetection.h +5 -0
- package/common/runner/base_llm_runner.cpp +8 -6
- package/common/runner/base_llm_runner.h +8 -4
- package/common/runner/encoders/vision_encoder.cpp +12 -4
- package/common/runner/irunner.h +15 -0
- package/common/runner/multimodal_decoder_runner.h +3 -2
- package/common/runner/multimodal_runner.cpp +4 -16
- package/common/runner/multimodal_runner.h +0 -4
- package/common/runner/sampler.cpp +32 -13
- package/common/runner/sampler.h +59 -1
- package/common/runner/text_decoder_runner.cpp +31 -3
- package/common/runner/text_decoder_runner.h +13 -46
- package/common/runner/text_runner.cpp +3 -26
- package/common/runner/text_runner.h +0 -4
- package/common/runner/text_token_generator.h +20 -18
- package/lib/module/constants/modelUrls.js +53 -10
- package/lib/module/constants/modelUrls.js.map +1 -1
- package/lib/module/controllers/LLMController.js +75 -22
- package/lib/module/controllers/LLMController.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useLLM.js +1 -0
- package/lib/module/hooks/natural_language_processing/useLLM.js.map +1 -1
- package/lib/module/index.js +11 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/natural_language_processing/LLMModule.js +1 -1
- package/lib/module/types/llm.js +4 -1
- package/lib/module/types/llm.js.map +1 -1
- package/lib/typescript/constants/modelUrls.d.ts +126 -0
- package/lib/typescript/constants/modelUrls.d.ts.map +1 -1
- package/lib/typescript/controllers/LLMController.d.ts +3 -1
- package/lib/typescript/controllers/LLMController.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +7 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts +1 -1
- package/lib/typescript/types/llm.d.ts +21 -1
- package/lib/typescript/types/llm.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/constants/modelUrls.ts +45 -2
- package/src/controllers/LLMController.ts +84 -25
- package/src/hooks/natural_language_processing/useLLM.ts +1 -0
- package/src/index.ts +11 -0
- package/src/modules/natural_language_processing/LLMModule.ts +1 -1
- package/src/types/llm.ts +21 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LLMController.d.ts","sourceRoot":"","sources":["../../../src/controllers/LLMController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,OAAO,EACP,OAAO,EAEP,WAAW,EACZ,MAAM,cAAc,CAAC;AAMtB,qBAAa,aAAa;IACxB,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,UAAU,CAAmC;IACrD,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,eAAe,CAAM;IAC7B,OAAO,CAAC,OAAO,CAAC,CAA0B;IAC1C,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,eAAe,CAAiB;IAExC,OAAO,CAAC,aAAa,CAA0B;IAC/C,OAAO,CAAC,sBAAsB,CAAsC;IACpE,OAAO,CAAC,eAAe,CAA6B;IACp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AE,gBAAgB,CAAC;KACrC;IAaD,OAAO,CAAC,qBAAqB;IA6C7B,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,mBAAmB;IAiBpB,MAAM;IAgBA,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAiCpE,SAAS;IAUT,sBAAsB,IAAI,MAAM;IAUhC,mBAAmB,IAAI,MAAM;IAU7B,kBAAkB,IAAI,MAAM;IAItB,QAAQ,CACnB,QAAQ,EAAE,OAAO,EAAE,EACnB,KAAK,CAAC,EAAE,OAAO,EAAE,GAChB,OAAO,CAAC,MAAM,CAAC;IAqCL,WAAW,CACtB,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAC7B,OAAO,CAAC,MAAM,CAAC;IA+DX,aAAa,CAAC,KAAK,EAAE,MAAM;IAQlC,OAAO,CAAC,iBAAiB;CA4B1B"}
|
|
@@ -39,6 +39,13 @@ declare global {
|
|
|
39
39
|
var loadVerticalOCR: (detectorSource: string, recognizer: string, symbols: string, independentCharacters?: boolean) => Promise<any>;
|
|
40
40
|
var __rne_isEmulator: boolean;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Whether the native ExecuTorch runtime is available on this device.
|
|
44
|
+
* Returns `false` when native libraries cannot be loaded (e.g. 32-bit Android
|
|
45
|
+
* devices where only arm64-v8a binaries are shipped).
|
|
46
|
+
* @category Utilities - General
|
|
47
|
+
*/
|
|
48
|
+
export declare const isAvailable: boolean;
|
|
42
49
|
export * from './hooks/computer_vision/useClassification';
|
|
43
50
|
export * from './hooks/computer_vision/useObjectDetection';
|
|
44
51
|
export * from './hooks/computer_vision/useStyleTransfer';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EA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,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AAExC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -67,7 +67,7 @@ export declare class LLMModule {
|
|
|
67
67
|
* It doesn't manage conversation context. It is intended for users that need access to the model itself without any wrapper.
|
|
68
68
|
* If you want a simple chat with model the consider using `sendMessage`
|
|
69
69
|
* @param input - Raw input string containing the prompt and conversation history.
|
|
70
|
-
* @param imagePaths - Optional array of local image paths for multimodal inference.
|
|
70
|
+
* @param imagePaths - Optional array of local image paths for multimodal inference. Each entry may be either `file:///absolute/path` or `/absolute/path` — the controller normalizes the path before passing it to native code.
|
|
71
71
|
* @returns The generated response as a string.
|
|
72
72
|
*/
|
|
73
73
|
forward(input: string, imagePaths?: string[]): Promise<string>;
|
|
@@ -46,6 +46,13 @@ export interface LLMProps {
|
|
|
46
46
|
* Example: `['vision']` enables `sendMessage(text, { imagePath })`.
|
|
47
47
|
*/
|
|
48
48
|
capabilities?: readonly LLMCapability[];
|
|
49
|
+
/**
|
|
50
|
+
* Recommended default generation settings, typically copied from the
|
|
51
|
+
* upstream `generation_config.json` or the model card. Applied automatically
|
|
52
|
+
* after the native module loads and before any user `configure()` call,
|
|
53
|
+
* so callers only need to override the values they want to change.
|
|
54
|
+
*/
|
|
55
|
+
generationConfig?: GenerationConfig;
|
|
49
56
|
};
|
|
50
57
|
/**
|
|
51
58
|
* Boolean that can prevent automatic model loading (and downloading the data if you load it for the first time) after running the hook.
|
|
@@ -189,6 +196,10 @@ export interface LLMConfig {
|
|
|
189
196
|
* `temperature` - Scales output logits by the inverse of temperature. Controls the randomness / creativity of text generation.
|
|
190
197
|
*
|
|
191
198
|
* `topp` - Only samples from the smallest set of tokens whose cumulative probability exceeds topp.
|
|
199
|
+
*
|
|
200
|
+
* `minP` - Minimum probability threshold: tokens with prob < minP * max_prob are excluded. 0 disables filtering.
|
|
201
|
+
*
|
|
202
|
+
* `repetitionPenalty` - Multiplicative penalty applied to logits of recently generated tokens. Values > 1 discourage repetition. 1 disables the penalty.
|
|
192
203
|
*/
|
|
193
204
|
generationConfig?: GenerationConfig;
|
|
194
205
|
}
|
|
@@ -209,6 +220,8 @@ export interface Message {
|
|
|
209
220
|
/**
|
|
210
221
|
* Optional local file path to media (image, audio, etc.).
|
|
211
222
|
* Only valid on `user` messages.
|
|
223
|
+
* Either `file:///absolute/path` or `/absolute/path` is accepted; the
|
|
224
|
+
* controller normalizes the path before passing it to native code.
|
|
212
225
|
*/
|
|
213
226
|
mediaPath?: string;
|
|
214
227
|
}
|
|
@@ -257,13 +270,20 @@ export interface ToolsConfig {
|
|
|
257
270
|
* Object configuring generation settings.
|
|
258
271
|
* @category Types
|
|
259
272
|
* @property {number} [temperature] - Scales output logits by the inverse of temperature. Controls the randomness / creativity of text generation.
|
|
260
|
-
* @property {number} [
|
|
273
|
+
* @property {number} [topP] - Only samples from the smallest set of tokens whose cumulative probability exceeds topP.
|
|
274
|
+
* @property {number} [topp] - **Deprecated.** Use `topP` instead.
|
|
275
|
+
* @property {number} [minP] - Minimum probability threshold: tokens with prob < minP * max_prob are excluded. 0 disables filtering.
|
|
276
|
+
* @property {number} [repetitionPenalty] - Multiplicative penalty applied to logits of recently generated tokens. Values > 1 discourage repetition. 1 disables the penalty.
|
|
261
277
|
* @property {number} [outputTokenBatchSize] - Soft upper limit on the number of tokens in each token batch (in certain cases there can be more tokens in given batch, i.e. when the batch would end with special emoji join character).
|
|
262
278
|
* @property {number} [batchTimeInterval] - Upper limit on the time interval between consecutive token batches.
|
|
263
279
|
*/
|
|
264
280
|
export interface GenerationConfig {
|
|
265
281
|
temperature?: number;
|
|
282
|
+
topP?: number;
|
|
283
|
+
/** @deprecated Use `topP` instead. */
|
|
266
284
|
topp?: number;
|
|
285
|
+
minP?: number;
|
|
286
|
+
repetitionPenalty?: number;
|
|
267
287
|
outputTokenBatchSize?: number;
|
|
268
288
|
batchTimeInterval?: number;
|
|
269
289
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../../src/types/llm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;AAErC;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,SAAS,aAAa,EAAE,IACrD,QAAQ,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC;AAE/D;;;GAGG;AACH,MAAM,MAAM,YAAY,GACpB,cAAc,GACd,oBAAoB,GACpB,wBAAwB,GACxB,cAAc,GACd,oBAAoB,GACpB,wBAAwB,GACxB,YAAY,GACZ,sBAAsB,GACtB,YAAY,GACZ,sBAAsB,GACtB,UAAU,GACV,oBAAoB,GACpB,gBAAgB,GAChB,0BAA0B,GAC1B,gBAAgB,GAChB,0BAA0B,GAC1B,cAAc,GACd,wBAAwB,GACxB,gBAAgB,GAChB,0BAA0B,GAC1B,gBAAgB,GAChB,0BAA0B,GAC1B,gBAAgB,GAChB,0BAA0B,GAC1B,cAAc,GACd,wBAAwB,GACxB,cAAc,GACd,wBAAwB,GACxB,YAAY,GACZ,sBAAsB,GACtB,eAAe,GACf,yBAAyB,GACzB,aAAa,GACb,uBAAuB,GACvB,sBAAsB,GACtB,gCAAgC,GAChC,0BAA0B,GAC1B,0BAA0B,CAAC;AAE/B;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE;QACL;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E,MAAM,CAAC;IACrB,eAAe,EAAE,eAAe,CAAC;CAClC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,mBAAmB,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAChE,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;OAOG;IACH,YAAY,CACV,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,OAAO,EAAE,EAClB,gBAAgB,EAAE,MAAM,EACxB,aAAa,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,MAAM,GAC7C,OAAO,EAAE,CAAC;CACd;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;;;CAQ1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -83,6 +83,14 @@ const QWEN3_4B_QUANTIZED_MODEL = `${URL_PREFIX}-qwen-3/${VERSION_TAG}/qwen-3-4B/
|
|
|
83
83
|
const QWEN3_TOKENIZER = `${URL_PREFIX}-qwen-3/${VERSION_TAG}/tokenizer.json`;
|
|
84
84
|
const QWEN3_TOKENIZER_CONFIG = `${URL_PREFIX}-qwen-3/${VERSION_TAG}/tokenizer_config.json`;
|
|
85
85
|
|
|
86
|
+
// Qwen3's published generation_config.json recommends temperature=0.6 and
|
|
87
|
+
// top_p=0.95. We propagate those to every Qwen3 preset so model quality is
|
|
88
|
+
// reasonable out of the box; users can override via `configure()`.
|
|
89
|
+
const QWEN3_GENERATION_CONFIG = {
|
|
90
|
+
temperature: 0.6,
|
|
91
|
+
topP: 0.95,
|
|
92
|
+
} as const;
|
|
93
|
+
|
|
86
94
|
/**
|
|
87
95
|
* @category Models - LLM
|
|
88
96
|
*/
|
|
@@ -91,6 +99,7 @@ export const QWEN3_0_6B = {
|
|
|
91
99
|
modelSource: QWEN3_0_6B_MODEL,
|
|
92
100
|
tokenizerSource: QWEN3_TOKENIZER,
|
|
93
101
|
tokenizerConfigSource: QWEN3_TOKENIZER_CONFIG,
|
|
102
|
+
generationConfig: QWEN3_GENERATION_CONFIG,
|
|
94
103
|
} as const;
|
|
95
104
|
|
|
96
105
|
/**
|
|
@@ -101,6 +110,7 @@ export const QWEN3_0_6B_QUANTIZED = {
|
|
|
101
110
|
modelSource: QWEN3_0_6B_QUANTIZED_MODEL,
|
|
102
111
|
tokenizerSource: QWEN3_TOKENIZER,
|
|
103
112
|
tokenizerConfigSource: QWEN3_TOKENIZER_CONFIG,
|
|
113
|
+
generationConfig: QWEN3_GENERATION_CONFIG,
|
|
104
114
|
} as const;
|
|
105
115
|
|
|
106
116
|
/**
|
|
@@ -111,6 +121,7 @@ export const QWEN3_1_7B = {
|
|
|
111
121
|
modelSource: QWEN3_1_7B_MODEL,
|
|
112
122
|
tokenizerSource: QWEN3_TOKENIZER,
|
|
113
123
|
tokenizerConfigSource: QWEN3_TOKENIZER_CONFIG,
|
|
124
|
+
generationConfig: QWEN3_GENERATION_CONFIG,
|
|
114
125
|
} as const;
|
|
115
126
|
|
|
116
127
|
/**
|
|
@@ -121,6 +132,7 @@ export const QWEN3_1_7B_QUANTIZED = {
|
|
|
121
132
|
modelSource: QWEN3_1_7B_QUANTIZED_MODEL,
|
|
122
133
|
tokenizerSource: QWEN3_TOKENIZER,
|
|
123
134
|
tokenizerConfigSource: QWEN3_TOKENIZER_CONFIG,
|
|
135
|
+
generationConfig: QWEN3_GENERATION_CONFIG,
|
|
124
136
|
} as const;
|
|
125
137
|
|
|
126
138
|
/**
|
|
@@ -131,6 +143,7 @@ export const QWEN3_4B = {
|
|
|
131
143
|
modelSource: QWEN3_4B_MODEL,
|
|
132
144
|
tokenizerSource: QWEN3_TOKENIZER,
|
|
133
145
|
tokenizerConfigSource: QWEN3_TOKENIZER_CONFIG,
|
|
146
|
+
generationConfig: QWEN3_GENERATION_CONFIG,
|
|
134
147
|
} as const;
|
|
135
148
|
|
|
136
149
|
/**
|
|
@@ -141,6 +154,7 @@ export const QWEN3_4B_QUANTIZED = {
|
|
|
141
154
|
modelSource: QWEN3_4B_QUANTIZED_MODEL,
|
|
142
155
|
tokenizerSource: QWEN3_TOKENIZER,
|
|
143
156
|
tokenizerConfigSource: QWEN3_TOKENIZER_CONFIG,
|
|
157
|
+
generationConfig: QWEN3_GENERATION_CONFIG,
|
|
144
158
|
} as const;
|
|
145
159
|
|
|
146
160
|
// HAMMER 2.1
|
|
@@ -444,25 +458,52 @@ const LFM2_VL_450M_TOKENIZER_CONFIG = `${URL_PREFIX}-lfm-2.5/${VERSION_TAG}/lfm2
|
|
|
444
458
|
/**
|
|
445
459
|
* @category Models - VLM
|
|
446
460
|
*/
|
|
447
|
-
|
|
461
|
+
// LiquidAI's LFM2-VL model card recommends the following sampling settings.
|
|
462
|
+
// Without them the model often produces generic / repetitive responses.
|
|
463
|
+
const LFM2_5_VL_GENERATION_CONFIG = {
|
|
464
|
+
temperature: 0.1,
|
|
465
|
+
minP: 0.15,
|
|
466
|
+
repetitionPenalty: 1.05,
|
|
467
|
+
} as const;
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* @category Models - VLM
|
|
471
|
+
*/
|
|
472
|
+
export const LFM2_5_VL_1_6B_QUANTIZED = {
|
|
448
473
|
modelName: 'lfm2.5-vl-1.6b-quantized',
|
|
449
474
|
capabilities: ['vision'],
|
|
450
475
|
modelSource: LFM2_VL_1_6B_QUANTIZED_MODEL,
|
|
451
476
|
tokenizerSource: LFM2_VL_1_6B_TOKENIZER,
|
|
452
477
|
tokenizerConfigSource: LFM2_VL_1_6B_TOKENIZER_CONFIG,
|
|
478
|
+
generationConfig: LFM2_5_VL_GENERATION_CONFIG,
|
|
453
479
|
} as const;
|
|
454
480
|
|
|
455
481
|
/**
|
|
456
482
|
* @category Models - VLM
|
|
457
483
|
*/
|
|
458
|
-
export const
|
|
484
|
+
export const LFM2_5_VL_450M_QUANTIZED = {
|
|
459
485
|
modelName: 'lfm2.5-vl-450m-quantized',
|
|
460
486
|
capabilities: ['vision'],
|
|
461
487
|
modelSource: LFM2_VL_450M_QUANTIZED_MODEL,
|
|
462
488
|
tokenizerSource: LFM2_VL_450M_TOKENIZER,
|
|
463
489
|
tokenizerConfigSource: LFM2_VL_450M_TOKENIZER_CONFIG,
|
|
490
|
+
generationConfig: LFM2_5_VL_GENERATION_CONFIG,
|
|
464
491
|
} as const;
|
|
465
492
|
|
|
493
|
+
/**
|
|
494
|
+
* @deprecated Use `LFM2_5_VL_1_6B_QUANTIZED` instead — the model is from the
|
|
495
|
+
* LFM2.5 family. This alias will be removed in a future major release.
|
|
496
|
+
* @category Models - VLM
|
|
497
|
+
*/
|
|
498
|
+
export const LFM2_VL_1_6B_QUANTIZED = LFM2_5_VL_1_6B_QUANTIZED;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* @deprecated Use `LFM2_5_VL_450M_QUANTIZED` instead — the model is from the
|
|
502
|
+
* LFM2.5 family. This alias will be removed in a future major release.
|
|
503
|
+
* @category Models - VLM
|
|
504
|
+
*/
|
|
505
|
+
export const LFM2_VL_450M_QUANTIZED = LFM2_5_VL_450M_QUANTIZED;
|
|
506
|
+
|
|
466
507
|
// Classification
|
|
467
508
|
const EFFICIENTNET_V2_S_MODEL =
|
|
468
509
|
Platform.OS === `ios`
|
|
@@ -1121,6 +1162,8 @@ export const MODEL_REGISTRY = {
|
|
|
1121
1162
|
LFM2_5_350M_QUANTIZED,
|
|
1122
1163
|
LFM2_5_1_2B_INSTRUCT,
|
|
1123
1164
|
LFM2_5_1_2B_INSTRUCT_QUANTIZED,
|
|
1165
|
+
LFM2_5_VL_1_6B_QUANTIZED,
|
|
1166
|
+
LFM2_5_VL_450M_QUANTIZED,
|
|
1124
1167
|
LFM2_VL_1_6B_QUANTIZED,
|
|
1125
1168
|
LFM2_VL_450M_QUANTIZED,
|
|
1126
1169
|
EFFICIENTNET_V2_S,
|
|
@@ -76,12 +76,14 @@ export class LLMController {
|
|
|
76
76
|
tokenizerSource,
|
|
77
77
|
tokenizerConfigSource,
|
|
78
78
|
capabilities,
|
|
79
|
+
defaultGenerationConfig,
|
|
79
80
|
onDownloadProgressCallback,
|
|
80
81
|
}: {
|
|
81
82
|
modelSource: ResourceSource;
|
|
82
83
|
tokenizerSource: ResourceSource;
|
|
83
84
|
tokenizerConfigSource: ResourceSource;
|
|
84
85
|
capabilities?: readonly LLMCapability[];
|
|
86
|
+
defaultGenerationConfig?: GenerationConfig;
|
|
85
87
|
onDownloadProgressCallback?: (downloadProgress: number) => void;
|
|
86
88
|
}) {
|
|
87
89
|
// reset inner state when loading new model
|
|
@@ -130,6 +132,12 @@ export class LLMController {
|
|
|
130
132
|
tokenizerPath,
|
|
131
133
|
capabilities ?? []
|
|
132
134
|
);
|
|
135
|
+
if (defaultGenerationConfig) {
|
|
136
|
+
// Apply model-specific recommended sampling defaults before flipping
|
|
137
|
+
// isReady so callers that react to it see the right config on first
|
|
138
|
+
// send. User-provided `configure()` calls still override these.
|
|
139
|
+
this.applyGenerationConfig(defaultGenerationConfig);
|
|
140
|
+
}
|
|
133
141
|
this.isReadyCallback(true);
|
|
134
142
|
this.onToken = (data: string) => {
|
|
135
143
|
if (!data) {
|
|
@@ -166,28 +174,58 @@ export class LLMController {
|
|
|
166
174
|
this.chatConfig = { ...DEFAULT_CHAT_CONFIG, ...chatConfig };
|
|
167
175
|
this.toolsConfig = toolsConfig;
|
|
168
176
|
|
|
169
|
-
if (generationConfig
|
|
177
|
+
if (generationConfig) {
|
|
178
|
+
this.applyGenerationConfig(generationConfig);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// reset inner state when loading new configuration
|
|
182
|
+
this.messageHistoryCallback(this.chatConfig.initialMessageHistory);
|
|
183
|
+
this.isGeneratingCallback(false);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
private applyGenerationConfig(generationConfig: GenerationConfig) {
|
|
187
|
+
if (generationConfig.outputTokenBatchSize) {
|
|
170
188
|
this.nativeModule.setCountInterval(generationConfig.outputTokenBatchSize);
|
|
171
189
|
}
|
|
172
|
-
if (generationConfig
|
|
190
|
+
if (generationConfig.batchTimeInterval) {
|
|
173
191
|
this.nativeModule.setTimeInterval(generationConfig.batchTimeInterval);
|
|
174
192
|
}
|
|
175
|
-
if (generationConfig
|
|
193
|
+
if (generationConfig.temperature !== undefined) {
|
|
176
194
|
this.nativeModule.setTemperature(generationConfig.temperature);
|
|
177
195
|
}
|
|
178
|
-
|
|
179
|
-
|
|
196
|
+
// `topp` is the legacy spelling kept for backwards compatibility — `topP`
|
|
197
|
+
// wins when both are set so callers migrating to the new name don't get
|
|
198
|
+
// surprised by stale values. Reading the deprecated alias is intentional.
|
|
199
|
+
const topP = generationConfig.topP ?? generationConfig.topp;
|
|
200
|
+
if (topP !== undefined) {
|
|
201
|
+
if (topP < 0 || topP > 1) {
|
|
180
202
|
throw new RnExecutorchError(
|
|
181
203
|
RnExecutorchErrorCode.InvalidConfig,
|
|
182
204
|
'Top P has to be in range [0, 1]'
|
|
183
205
|
);
|
|
184
206
|
}
|
|
185
|
-
this.nativeModule.setTopp(
|
|
207
|
+
this.nativeModule.setTopp(topP);
|
|
208
|
+
}
|
|
209
|
+
if (generationConfig.minP !== undefined) {
|
|
210
|
+
if (generationConfig.minP < 0 || generationConfig.minP > 1) {
|
|
211
|
+
throw new RnExecutorchError(
|
|
212
|
+
RnExecutorchErrorCode.InvalidConfig,
|
|
213
|
+
'Min P has to be in range [0, 1]'
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
this.nativeModule.setMinP(generationConfig.minP);
|
|
217
|
+
}
|
|
218
|
+
if (generationConfig.repetitionPenalty !== undefined) {
|
|
219
|
+
if (generationConfig.repetitionPenalty < 0) {
|
|
220
|
+
throw new RnExecutorchError(
|
|
221
|
+
RnExecutorchErrorCode.InvalidConfig,
|
|
222
|
+
'Repetition penalty must be non-negative'
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
this.nativeModule.setRepetitionPenalty(
|
|
226
|
+
generationConfig.repetitionPenalty
|
|
227
|
+
);
|
|
186
228
|
}
|
|
187
|
-
|
|
188
|
-
// reset inner state when loading new configuration
|
|
189
|
-
this.messageHistoryCallback(this.chatConfig.initialMessageHistory);
|
|
190
|
-
this.isGeneratingCallback(false);
|
|
191
229
|
}
|
|
192
230
|
|
|
193
231
|
private getImageToken(): string {
|
|
@@ -254,7 +292,7 @@ export class LLMController {
|
|
|
254
292
|
imagePaths && imagePaths.length > 0
|
|
255
293
|
? await this.nativeModule.generateMultimodal(
|
|
256
294
|
input,
|
|
257
|
-
imagePaths,
|
|
295
|
+
imagePaths.map(normalizeImagePath),
|
|
258
296
|
this.getImageToken(),
|
|
259
297
|
this.onToken
|
|
260
298
|
)
|
|
@@ -354,18 +392,6 @@ export class LLMController {
|
|
|
354
392
|
const updatedHistory = [...this._messageHistory, newMessage];
|
|
355
393
|
this.messageHistoryCallback(updatedHistory);
|
|
356
394
|
|
|
357
|
-
const historyForTemplate = updatedHistory.map((m) =>
|
|
358
|
-
m.mediaPath
|
|
359
|
-
? {
|
|
360
|
-
...m,
|
|
361
|
-
content: [
|
|
362
|
-
{ type: 'image' },
|
|
363
|
-
{ type: 'text', text: m.content },
|
|
364
|
-
] as any,
|
|
365
|
-
}
|
|
366
|
-
: m
|
|
367
|
-
);
|
|
368
|
-
|
|
369
395
|
const visualTokenCount = this.nativeModule.getVisualTokenCount();
|
|
370
396
|
const countTokensCallback = (messages: Message[]) => {
|
|
371
397
|
const rendered = this.applyChatTemplate(
|
|
@@ -383,7 +409,7 @@ export class LLMController {
|
|
|
383
409
|
const messageHistoryWithPrompt =
|
|
384
410
|
this.chatConfig.contextStrategy.buildContext(
|
|
385
411
|
this.chatConfig.systemPrompt,
|
|
386
|
-
|
|
412
|
+
updatedHistory,
|
|
387
413
|
maxContextLength,
|
|
388
414
|
countTokensCallback
|
|
389
415
|
);
|
|
@@ -448,7 +474,7 @@ export class LLMController {
|
|
|
448
474
|
);
|
|
449
475
|
|
|
450
476
|
const result = template.render({
|
|
451
|
-
messages,
|
|
477
|
+
messages: messagesForChatTemplate(messages),
|
|
452
478
|
tools,
|
|
453
479
|
...templateFlags,
|
|
454
480
|
...specialTokens,
|
|
@@ -456,3 +482,36 @@ export class LLMController {
|
|
|
456
482
|
return result;
|
|
457
483
|
}
|
|
458
484
|
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* The native multimodal pipeline expects image paths to be `file://` URIs.
|
|
488
|
+
* `ResourceFetcher.fetch` and most platform file APIs return raw filesystem
|
|
489
|
+
* paths without that prefix, so callers routinely pass either form. Accept
|
|
490
|
+
* both and normalize to the prefixed form here.
|
|
491
|
+
* @param path - Local image path, either with or without the `file://` prefix.
|
|
492
|
+
* @returns The same path with a `file://` prefix.
|
|
493
|
+
*/
|
|
494
|
+
function normalizeImagePath(path: string): string {
|
|
495
|
+
return path.startsWith('file://') ? path : `file://${path}`;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Multimodal chat templates expect message content for image-bearing turns
|
|
500
|
+
* to be an array of content parts with an `image` part as a placeholder.
|
|
501
|
+
* Callers of `LLMController.generate` and `LLMController.sendMessage` pass
|
|
502
|
+
* messages with a plain string `content` plus an optional `mediaPath`; this
|
|
503
|
+
* helper rewrites them into the structured form that the template engine
|
|
504
|
+
* understands.
|
|
505
|
+
* @param messages - Messages to prepare for the chat template engine.
|
|
506
|
+
* @returns Messages with image-bearing turns rewritten to structured content.
|
|
507
|
+
*/
|
|
508
|
+
function messagesForChatTemplate(messages: Message[]): any[] {
|
|
509
|
+
return messages.map((m) =>
|
|
510
|
+
m.mediaPath && typeof m.content === 'string'
|
|
511
|
+
? {
|
|
512
|
+
...m,
|
|
513
|
+
content: [{ type: 'image' }, { type: 'text', text: m.content }],
|
|
514
|
+
}
|
|
515
|
+
: m
|
|
516
|
+
);
|
|
517
|
+
}
|
|
@@ -62,6 +62,7 @@ export function useLLM({
|
|
|
62
62
|
tokenizerSource: model.tokenizerSource,
|
|
63
63
|
tokenizerConfigSource: model.tokenizerConfigSource!,
|
|
64
64
|
capabilities: model.capabilities,
|
|
65
|
+
defaultGenerationConfig: model.generationConfig,
|
|
65
66
|
onDownloadProgressCallback: setDownloadProgress,
|
|
66
67
|
});
|
|
67
68
|
} catch (e) {
|
package/src/index.ts
CHANGED
|
@@ -134,9 +134,20 @@ if (
|
|
|
134
134
|
`Failed to install react-native-executorch: The native module could not be found.`
|
|
135
135
|
);
|
|
136
136
|
}
|
|
137
|
+
// install() returns false when the native library is intentionally unavailable
|
|
138
|
+
// (e.g. ETInstallerUnavailable on unsupported ABIs). In that case, JSI
|
|
139
|
+
// bindings are not injected and globals remain unset.
|
|
137
140
|
ETInstallerNativeModule.install();
|
|
138
141
|
}
|
|
139
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Whether the native ExecuTorch runtime is available on this device.
|
|
145
|
+
* Returns `false` when native libraries cannot be loaded (e.g. 32-bit Android
|
|
146
|
+
* devices where only arm64-v8a binaries are shipped).
|
|
147
|
+
* @category Utilities - General
|
|
148
|
+
*/
|
|
149
|
+
export const isAvailable = typeof global.loadExecutorchModule === 'function';
|
|
150
|
+
|
|
140
151
|
// hooks
|
|
141
152
|
export * from './hooks/computer_vision/useClassification';
|
|
142
153
|
export * from './hooks/computer_vision/useObjectDetection';
|
|
@@ -139,7 +139,7 @@ export class LLMModule {
|
|
|
139
139
|
* It doesn't manage conversation context. It is intended for users that need access to the model itself without any wrapper.
|
|
140
140
|
* If you want a simple chat with model the consider using `sendMessage`
|
|
141
141
|
* @param input - Raw input string containing the prompt and conversation history.
|
|
142
|
-
* @param imagePaths - Optional array of local image paths for multimodal inference.
|
|
142
|
+
* @param imagePaths - Optional array of local image paths for multimodal inference. Each entry may be either `file:///absolute/path` or `/absolute/path` — the controller normalizes the path before passing it to native code.
|
|
143
143
|
* @returns The generated response as a string.
|
|
144
144
|
*/
|
|
145
145
|
async forward(input: string, imagePaths?: string[]): Promise<string> {
|
package/src/types/llm.ts
CHANGED
|
@@ -87,6 +87,13 @@ export interface LLMProps {
|
|
|
87
87
|
* Example: `['vision']` enables `sendMessage(text, { imagePath })`.
|
|
88
88
|
*/
|
|
89
89
|
capabilities?: readonly LLMCapability[];
|
|
90
|
+
/**
|
|
91
|
+
* Recommended default generation settings, typically copied from the
|
|
92
|
+
* upstream `generation_config.json` or the model card. Applied automatically
|
|
93
|
+
* after the native module loads and before any user `configure()` call,
|
|
94
|
+
* so callers only need to override the values they want to change.
|
|
95
|
+
*/
|
|
96
|
+
generationConfig?: GenerationConfig;
|
|
90
97
|
};
|
|
91
98
|
/**
|
|
92
99
|
* Boolean that can prevent automatic model loading (and downloading the data if you load it for the first time) after running the hook.
|
|
@@ -248,6 +255,10 @@ export interface LLMConfig {
|
|
|
248
255
|
* `temperature` - Scales output logits by the inverse of temperature. Controls the randomness / creativity of text generation.
|
|
249
256
|
*
|
|
250
257
|
* `topp` - Only samples from the smallest set of tokens whose cumulative probability exceeds topp.
|
|
258
|
+
*
|
|
259
|
+
* `minP` - Minimum probability threshold: tokens with prob < minP * max_prob are excluded. 0 disables filtering.
|
|
260
|
+
*
|
|
261
|
+
* `repetitionPenalty` - Multiplicative penalty applied to logits of recently generated tokens. Values > 1 discourage repetition. 1 disables the penalty.
|
|
251
262
|
*/
|
|
252
263
|
generationConfig?: GenerationConfig;
|
|
253
264
|
}
|
|
@@ -270,6 +281,8 @@ export interface Message {
|
|
|
270
281
|
/**
|
|
271
282
|
* Optional local file path to media (image, audio, etc.).
|
|
272
283
|
* Only valid on `user` messages.
|
|
284
|
+
* Either `file:///absolute/path` or `/absolute/path` is accepted; the
|
|
285
|
+
* controller normalizes the path before passing it to native code.
|
|
273
286
|
*/
|
|
274
287
|
mediaPath?: string;
|
|
275
288
|
}
|
|
@@ -323,13 +336,20 @@ export interface ToolsConfig {
|
|
|
323
336
|
* Object configuring generation settings.
|
|
324
337
|
* @category Types
|
|
325
338
|
* @property {number} [temperature] - Scales output logits by the inverse of temperature. Controls the randomness / creativity of text generation.
|
|
326
|
-
* @property {number} [
|
|
339
|
+
* @property {number} [topP] - Only samples from the smallest set of tokens whose cumulative probability exceeds topP.
|
|
340
|
+
* @property {number} [topp] - **Deprecated.** Use `topP` instead.
|
|
341
|
+
* @property {number} [minP] - Minimum probability threshold: tokens with prob < minP * max_prob are excluded. 0 disables filtering.
|
|
342
|
+
* @property {number} [repetitionPenalty] - Multiplicative penalty applied to logits of recently generated tokens. Values > 1 discourage repetition. 1 disables the penalty.
|
|
327
343
|
* @property {number} [outputTokenBatchSize] - Soft upper limit on the number of tokens in each token batch (in certain cases there can be more tokens in given batch, i.e. when the batch would end with special emoji join character).
|
|
328
344
|
* @property {number} [batchTimeInterval] - Upper limit on the time interval between consecutive token batches.
|
|
329
345
|
*/
|
|
330
346
|
export interface GenerationConfig {
|
|
331
347
|
temperature?: number;
|
|
348
|
+
topP?: number;
|
|
349
|
+
/** @deprecated Use `topP` instead. */
|
|
332
350
|
topp?: number;
|
|
351
|
+
minP?: number;
|
|
352
|
+
repetitionPenalty?: number;
|
|
333
353
|
outputTokenBatchSize?: number;
|
|
334
354
|
batchTimeInterval?: number;
|
|
335
355
|
}
|