mirror of
https://github.com/ollama/ollama-python.git
synced 2026-07-21 09:05:23 -04:00
ollama-python outputs sometimes half tokens. original ollama works fine in my system #76
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @binodil on GitHub (May 2, 2024).
Hi there,
I was playing around with ollama-python in jupyter notebook.
I have created small HTML form to show dynamic results of the model.
In the result, I see some words consists of two tokens or even more.
In the image below:
This kind of behaviour does noto appear in the ollama (the same model) in terminal

Screen shot of Ollama in terminal
Looking forward to hearing from you!
@mxyng commented on GitHub (May 2, 2024):
Here are the raw decoded tokens for a similar prompt.
As you can see, it does split some words into multiple tokens. This is common for many tokenizers since longer words are usually composed of smaller parts.
Can you confirm this is not rendering or postprocessing issue? For llm outputs, you're intended to join the output without additional spaces since the tokens themselves capture spacing.
Here's the same response but joined into a reader friendly string
Here's
tmp.py@binodil commented on GitHub (May 2, 2024):
I thought tokens are created without any consideration of whitespace. My fault. I fixed it!