Update run_wrap.py

This commit is contained in:
Artem Yatsenko
2023-07-23 09:28:49 -07:00
committed by GitHub
parent 00727ba1c0
commit 0bddcd94c1
+5 -4
View File
@@ -17,15 +17,16 @@ enc = Tokenizer()
t0 = time.time()
tokens = []
last = ''
for line in proc.stdout:
token = int(line.decode('utf-8').strip())
dec = enc.decode([token])
print(dec, end=" ", flush=True)
dec = enc.decode(tokens + [token])
chunk = dec[len(last):]
print(chunk, end='',flush=True)
tokens.append(token)
last = dec
t1 = time.time()
print('\n---\n')
print("Sorry I'm not sure why sentencepiece can't stream tokens properly, I'll solve it later. Here is the whole thing properly:")
print('\n---\n')
print(enc.decode(tokens))