mirror of
https://github.com/openai/CLIP.git
synced 2026-11-05 01:37:26 +00:00
[GH-ISSUE #56] tokenizer.encode vs tokenizer.encoder #49
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#49
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 @normster on GitHub (Mar 10, 2021).
Original GitHub issue: https://github.com/openai/CLIP/issues/56
Hi,
I noticed that in the code and the colab notebooks you alternate between calling tokenizer.encode() and indexing into the tokenizer.encoder dict. What's the difference between the two?
tokenizer.encode('the')returns[518]buttokenizer.encoder['the']returns599.Thanks!
@crowsonkb commented on GitHub (Mar 19, 2021):
If you look at the tokenizer.encoder dict, you can see that 599 is 'the' but 518 is 'the' followed by a word boundary. So
.encode('the p')gives[518, 335]while.encode('thep')gives[599, 335]. It's probably correct to use theencode()method.