Skip to content

Commit

Permalink
Merge pull request ggerganov#1 from sumo43/master
Browse files Browse the repository at this point in the history
Fix streaming
  • Loading branch information
karpathy authored Jul 23, 2023
2 parents ad67d5e + 0bddcd9 commit deb3818
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions run_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@

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

Expand Down

0 comments on commit deb3818

Please sign in to comment.