diff options
author | Laurent Mazare <laurent.mazare@gmail.com> | 2023-09-01 21:12:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-01 20:12:30 +0100 |
commit | 4d56cef58398a5f676ab1fe12d3ecc2e5c4edc66 (patch) | |
tree | 482f35bd3ff0d66d1d6537c29b85f711db103643 /candle-wasm-examples/llama2-c | |
parent | 19042962d5ae3ab17866522a0d2d99e873624441 (diff) | |
download | candle-4d56cef58398a5f676ab1fe12d3ecc2e5c4edc66.tar.gz candle-4d56cef58398a5f676ab1fe12d3ecc2e5c4edc66.tar.bz2 candle-4d56cef58398a5f676ab1fe12d3ecc2e5c4edc66.zip |
Handle the empty sequence case properly. (#712)
* Handle the empty sequence case properly.
* Proper fix.
Diffstat (limited to 'candle-wasm-examples/llama2-c')
-rw-r--r-- | candle-wasm-examples/llama2-c/src/bin/m.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/candle-wasm-examples/llama2-c/src/bin/m.rs b/candle-wasm-examples/llama2-c/src/bin/m.rs index ec5f7389..a71508ee 100644 --- a/candle-wasm-examples/llama2-c/src/bin/m.rs +++ b/candle-wasm-examples/llama2-c/src/bin/m.rs @@ -18,7 +18,7 @@ impl Model { let input = Tensor::new(tokens, &dev)?.unsqueeze(0)?; let logits = self.inner.llama.forward(&input, tokens.len())?; let logits = logits.squeeze(0)?; - let logits = if self.repeat_penalty == 1. { + let logits = if self.repeat_penalty == 1. || tokens.is_empty() { logits } else { let start_at = self.tokens.len().saturating_sub(REPEAT_LAST_N); |