Skip to content

Commit

Permalink
use decode instead batch decode for streaming (deepjavalibrary#1016)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qing Lan authored Aug 12, 2023
1 parent f5cc091 commit 4bc70f7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions engines/python/setup/djl_python/streaming_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ def __init__(self, tokenizer, **decode_kwargs):

def put(self, value):
self.started = True
text = self.tokenizer.batch_decode(value, **self.decode_kwargs)
self.queue.put(text)
if len(value.shape) == 1:
value = [value]
result = []
for item in value:
result.append(self.tokenizer.decode(item, **self.decode_kwargs))
self.queue.put(result)

def put_text(self, value):
self.queue.put(value)
Expand Down

0 comments on commit 4bc70f7

Please sign in to comment.