Skip to content

Commit c11dbad

Browse files
authored
docs(0.8): backport minP / repetitionPenalty docs to v0.8.x (#1111)
## Description Backports the sampling and multimodal-rename doc edits from #1099 into the v0.8.x useLLM.md and LLMModule.md pages, plus a JSDoc fence fix on `useInstanceSegmentation.ts`. New `minP` / `repetitionPenalty` / `topP` field names are rendered as plain inline code rather than anchor links, since the v0.8.x `GenerationConfig.md` snapshot doesn't have those entries. ### 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 `yarn build` in `docs/`. ### Screenshots ### Related issues Follow-up to #1108 / `v0.8.4`. ### Checklist - [x] I have performed a self-review of my code - [ ] 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
1 parent 2372854 commit c11dbad

3 files changed

Lines changed: 28 additions & 10 deletions

File tree

docs/versioned_docs/version-0.8.x/03-hooks/01-natural-language-processing/useLLM.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,15 @@ To configure model (i.e. change system prompt, load initial conversation history
211211

212212
- [`temperature`](../../06-api-reference/interfaces/GenerationConfig.md#temperature) - Scales output logits by the inverse of temperature. Controls the randomness / creativity of text generation.
213213

214-
- [`topp`](../../06-api-reference/interfaces/GenerationConfig.md#topp) - Only samples from the smallest set of tokens whose cumulative probability exceeds topp.
214+
- `topP` - Only samples from the smallest set of tokens whose cumulative probability exceeds topP. Range `[0, 1]`. Values of `0` or `1` disable top-p filtering.
215+
216+
- `minP` - Minimum-probability threshold applied after softmax: tokens whose probability is below `minP * max_prob` are excluded from sampling. Range `[0, 1]`. Default `0` disables the filter. Stacks with `topP` when both are set.
217+
218+
- `repetitionPenalty` - Multiplicative penalty applied to logits of tokens that already appeared in the prompt or the generated text. Values greater than `1` discourage repetition; default `1` disables the penalty.
219+
220+
:::info[Built-in models ship with sampling defaults]
221+
Model presets expose an optional [`generationConfig`](../../06-api-reference/interfaces/LLMProps.md) on the `model` prop. Whenever the upstream model card publishes recommended values (currently Qwen3 and LFM2-VL) the preset carries them and `useLLM` applies them automatically before `isReady` flips — you don't need to call `configure` just to get sensible defaults. Any fields you then pass to `configure` still override on a per-field basis.
222+
:::
215223

216224
### Model configuration example
217225

@@ -282,7 +290,9 @@ useEffect(() => {
282290
outputTokenBatchSize: 15,
283291
batchTimeInterval: 100,
284292
temperature: 0.7,
285-
topp: 0.9,
293+
topP: 0.9,
294+
minP: 0.05,
295+
repetitionPenalty: 1.05,
286296
},
287297
});
288298
}, [configure]);
@@ -491,9 +501,9 @@ Some models support multimodal input — text and images together. To use them,
491501
### Loading a VLM
492502

493503
```tsx
494-
import { useLLM, LFM2_VL_1_6B_QUANTIZED } from 'react-native-executorch';
504+
import { useLLM, LFM2_5_VL_1_6B_QUANTIZED } from 'react-native-executorch';
495505

496-
const llm = useLLM({ model: LFM2_VL_1_6B_QUANTIZED });
506+
const llm = useLLM({ model: LFM2_5_VL_1_6B_QUANTIZED });
497507
```
498508

499509
The `capabilities` field is already set on the model constant. You can also construct the model object explicitly:
@@ -514,7 +524,7 @@ Passing `capabilities` unlocks the typed `media` argument on `sendMessage`.
514524
### Sending a message with an image
515525

516526
```tsx
517-
const llm = useLLM({ model: LFM2_VL_1_6B_QUANTIZED });
527+
const llm = useLLM({ model: LFM2_5_VL_1_6B_QUANTIZED });
518528

519529
const send = () => {
520530
llm.sendMessage('What is in this image?', {
@@ -537,7 +547,7 @@ The `imagePath` should be a local file path on the device.
537547
You can also use `generate` directly by setting `mediaPath` on user messages:
538548

539549
```tsx
540-
const llm = useLLM({ model: LFM2_VL_1_6B_QUANTIZED });
550+
const llm = useLLM({ model: LFM2_5_VL_1_6B_QUANTIZED });
541551

542552
const handleGenerate = async () => {
543553
const chat: Message[] = [

docs/versioned_docs/version-0.8.x/04-typescript-api/01-natural-language-processing/LLMModule.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,25 @@ To configure model (i.e. change system prompt, load initial conversation history
107107

108108
- [`temperature`](../../06-api-reference/interfaces/GenerationConfig.md#temperature) - Scales output logits by the inverse of temperature. Controls the randomness / creativity of text generation.
109109

110-
- [`topp`](../../06-api-reference/interfaces/GenerationConfig.md#topp) - Only samples from the smallest set of tokens whose cumulative probability exceeds topp.
110+
- `topP` - Only samples from the smallest set of tokens whose cumulative probability exceeds topP. Range `[0, 1]`. Values of `0` or `1` disable top-p filtering.
111+
112+
- `minP` - Minimum-probability threshold applied after softmax: tokens whose probability is below `minP * max_prob` are excluded from sampling. Range `[0, 1]`. Default `0` disables the filter. Stacks with `topP` when both are set.
113+
114+
- `repetitionPenalty` - Multiplicative penalty applied to logits of tokens that already appeared in the prompt or the generated text. Values greater than `1` discourage repetition; default `1` disables the penalty.
115+
116+
:::info[Built-in models ship with sampling defaults]
117+
Model presets expose an optional `generationConfig` that `LLMModule.fromModelName` applies automatically when available — for Qwen3 and LFM2-VL this means the model-card recommended sampling settings are in effect without any explicit `configure` call. Any fields you pass to `configure` still override on a per-field basis.
118+
:::
111119

112120
## Vision-Language Models (VLM)
113121

114122
Some models support multimodal input — text and images together. To use them, pass `capabilities` in the model object when calling [`fromModelName`](../../06-api-reference/classes/LLMModule.md#frommodelname):
115123

116124
```typescript
117-
import { LLMModule, LFM2_VL_1_6B_QUANTIZED } from 'react-native-executorch';
125+
import { LLMModule, LFM2_5_VL_1_6B_QUANTIZED } from 'react-native-executorch';
118126

119127
const llm = await LLMModule.fromModelName(
120-
LFM2_VL_1_6B_QUANTIZED,
128+
LFM2_5_VL_1_6B_QUANTIZED,
121129
undefined,
122130
(token) => console.log(token)
123131
);

packages/react-native-executorch/src/hooks/computer_vision/useInstanceSegmentation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { useModuleFactory } from '../useModuleFactory';
1515
* @param props - Configuration object containing `model` config and optional `preventLoad` flag.
1616
* @returns An object with model state (`error`, `isReady`, `isGenerating`, `downloadProgress`), a typed `forward` function, `getAvailableInputSizes` helper, and a `runOnFrame` worklet for VisionCamera integration.
1717
* @example
18-
* ```ts
18+
* ```tsx
1919
* const { isReady, isGenerating, forward, error, downloadProgress, getAvailableInputSizes, runOnFrame } =
2020
* useInstanceSegmentation({
2121
* model: {

0 commit comments

Comments
 (0)