Handle the empty sequence case properly. (#712)

* Handle the empty sequence case properly.

* Proper fix.
This commit is contained in:
Laurent Mazare 2023-09-01 21:12:30 +02:00 committed by GitHub
parent 19042962d5
commit 4d56cef583
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -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);