mirror of
https://github.com/openai/CLIP.git
synced 2026-11-05 01:37:26 +00:00
[GH-ISSUE #305] Discrepancies between encode and decode in SimpleTokenizer #264
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openai/CLIP#264
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
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 @Quasimondo on GitHub (Dec 15, 2022).
Original GitHub issue: https://github.com/openai/CLIP/issues/305
I just came across a phenomenon which I find a bit confusing - not sure if this is expected behavior or shows an issue with SimpleTokenizer. Taking certain sequences of tokens and decoding them and then encoding the returned text again can result in a different sequence of tokens (whilst the two texts are identical).
Example:
In this example the input tokens were
[6808, 31978, 23644, 32441, 41003, 16125]
but the output tokens are
[6808, 31978, 950, 544, 36461, 41003, 16125]
The texts in both cases are identical an "critical murraycaneleroy brandi xiv "
Looking into the code one possibility was that the text cleanup methods are causing this, but overriding the two methods yields the same results:
@Quasimondo commented on GitHub (Dec 15, 2022):
Okay after some further looking into this I realize that this is simply a fact of life - there are simply multiple ways the same word can get encoded into tokens, e.g.
The word "murraycaneleroy" can either be tokenized as
murray | cane | leroy
or as
murray | can | el | eroy
And there is no way for the decoder to know which token combination created that word.