Skip to content

Commit

Permalink
Increment start_pos by encoded size in generate (#1462)
Browse files Browse the repository at this point in the history
* Add encoded size to start_pos

* Only in chat mode

---------

Co-authored-by: nlpfollower <[email protected]>
Co-authored-by: Jack-Khuu <[email protected]>
  • Loading branch information
3 people authored Jan 23, 2025
1 parent 3ce9c8e commit 0ee4aea
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions torchchat/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,8 @@ def callback(x, *, done_generating=False):
max_seq_length=max_seq_length,
attention_backend=self.builder_args.attention_backend,
)
if generator_args.chat_mode:
start_pos += encoded.size(0)
for token_tensor, metrics in generator_func:
if token_tensor is not None:
start_pos += token_tensor.size(0)
Expand Down

0 comments on commit 0ee4aea

Please sign in to comment.