Open xdevfaheem opened 1 year ago
fixed by
last_tokens = []
for index, x in enumerate(generator):
tokens = x.cpu().numpy().tolist()
tokens = last_tokens + tokens
word = tokenizer.decode(tokens, skip_special_tokens=True)
if "�" in word:
last_tokens = tokens
else:
if " " in tokenizer.decode(
tokens, skip_special_tokens=True
) and " " not in word:
word = " " + word
last_tokens = []
print(word, end='', flush=True)
The Code:
The output is this:
Generator yielding the token well but how does i make it await word generation instead of awaiting token without that long loop to yield the token in web example script.
@LowinLi Can you please Chime in?