Skip to content

Commit 7135644

Browse files
committed
docs(llm): emphasize in-place logits modification in sample JSDoc
1 parent d7c9033 commit 7135644

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

  • packages/react-native-executorch/src/extensions/llm

‎packages/react-native-executorch/src/extensions/llm/sampler.ts‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ const DEFAULT_XTC_OPTIONS = {
148148
/**
149149
* Samples a token directly from a native logits tensor given generation context and config.
150150
*
151-
* The logits buffer is written to in place (penalties, DRY and constraints are
151+
* **Important:** The logits buffer is written to in place (penalties, DRY and constraints are
152152
* applied directly to it), so its contents are undefined after this call. Copy
153153
* the tensor first if the original logits are still needed.
154154
* @param logits 2D float32 logits Tensor of shape `[1, vocabSize]`. Clobbered by the call.
@@ -164,14 +164,8 @@ export function sample(logits: Tensor, ctx: SamplingContext, config: SamplingCon
164164
const options = {
165165
...DEFAULT_SAMPLING_OPTIONS,
166166
...config,
167-
dry: config.dry && {
168-
...DEFAULT_DRY_OPTIONS,
169-
...config.dry,
170-
},
171-
xtc: config.xtc && {
172-
...DEFAULT_XTC_OPTIONS,
173-
...config.xtc,
174-
},
167+
dry: config.dry && { ...DEFAULT_DRY_OPTIONS, ...config.dry },
168+
xtc: config.xtc && { ...DEFAULT_XTC_OPTIONS, ...config.xtc },
175169
};
176170
return rnexecutorchJsi.llm.sample(logits, ctx, options);
177171
}

0 commit comments

Comments
 (0)