一键导入
remen-executorch
react-native-executorch integration guide — model loading, API surface, lifecycle management, quantization, and device optimization for Remen.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
react-native-executorch integration guide — model loading, API surface, lifecycle management, quantization, and device optimization for Remen.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
On-device AI processing pipeline for Remen — model lifecycle, LLM prompts, tag/title/classify generation, queue management, and react-native-executorch integration.
Remen codebase architecture — file structure conventions, module patterns, component organization, and coding standards. Must-read before making any structural changes.
Remen SQLite database — schema, migrations, CRUD operations, query patterns, and expo-sqlite usage.
Remen search and retrieval system — semantic search, keyword search, temporal parsing, query NLP, and result ranking.
基于 SOC 职业分类
| name | remen-executorch |
| description | react-native-executorch integration guide — model loading, API surface, lifecycle management, quantization, and device optimization for Remen. |
| version | 1.0.0 |
Reference for the on-device ML runtime. Docs: https://docs.swmansion.com/react-native-executorch/
react-native-executorch@^0.6.0 (upgrading to 0.8.x).pte files stored on device filesystem (managed by library).delete()).| Constant | Params | Quantization | Use Case |
|---|---|---|---|
SMOLLM2_1_135M | 135M | BF16 | Current, baseline |
SMOLLM2_1_135M_QUANTIZED | 135M | 8da4w | Smaller RAM |
SMOLLM2_1_360M_QUANTIZED | 360M | 8da4w | Target upgrade |
SMOLLM2_1_1_7B_QUANTIZED | 1.7B | 8da4w | Likely too large |
QWEN3_0_6B_8DA4W | 0.6B | 8da4w | Alternative |
QWEN2_5_0_5B_8DA4W | 0.5B | 8da4w | Alternative |
| Constant | Dims | Size |
|---|---|---|
ALL_MINILM_L6_V2 | 384 | ~91MB |
ALL_MPNET_BASE_V2 | 768 | ~438MB |
// LLM
const llm = useLLM({ model: SMOLLM2_1_360M_QUANTIZED, preventLoad: true });
// Returns: isReady, isGenerating, downloadProgress, response, error
// Methods: generate(messages), sendMessage(text), configure(opts), interrupt()
// Embeddings
const embeddings = useTextEmbeddings({ model: ALL_MINILM_L6_V2 });
// Returns: isReady, isGenerating, downloadProgress, error
// Methods: forward(text) → Float32Array
// Better for lifecycle management — use this in the AI queue
const llm = await LLMModule.fromModelName("SMOLLM2_1_360M_QUANTIZED");
llm.configure({ temperature: 0.3, topp: 0.9 });
const response = await llm.generate(messages);
await llm.interrupt(); // Must call before delete if generating
await llm.delete(); // Frees RAM
// Embeddings
const emb = await TextEmbeddingsModule.fromModelName("ALL_MINILM_L6_V2");
const vector = await emb.forward("some text"); // Float32Array
await emb.delete();
llm.configure({
temperature: 0.3, // Lower = more deterministic (0.0-2.0)
topp: 0.9, // Nucleus sampling threshold
// contextStrategy, // Context window management
});
llm.getGeneratedTokenCount();
llm.getPromptTokensCount();
llm.getTotalTokensCount();
EMBEDDINGS (always loaded):
- Load at app start via useTextEmbeddings() hook in AIProvider.
- Never unload — needed for search at any time.
- ~91MB RAM footprint.
LLM (load on demand):
- NOT loaded at app start.
- Queue calls ensureLLMLoaded() when work arrives.
- Uses LLMModule class API (imperative, not hook).
- configure({ temperature: 0.3 }) immediately after load.
- Unloads after 30s idle via scheduleLLMUnload().
- Falls back 360M → 135M if larger model crashes.
- Store successful model name in preferences.
OCR (removed):
- Cut to free memory for larger LLM.
- Scan flow uses optional user caption instead.
maxTokens or stop sequences — model generates until EOS..pte file — cannot change at runtime.preventLoad: true on hook → model downloads but doesn't load into RAM.interrupt() before delete() if model was generating.bad_alloc error → device ran out of RAM. Try smaller model or unload other models first.ModelGenerating error → previous generation not complete. Use waitForModel() or interrupt()..pte file.