https://github.com/zer0int/clip-tokenizer
A simple CLIP tokenizer encode / decode script. For when you need to know CLIP's tokenization and / or token IDs for some reason.
https://github.com/zer0int/clip-tokenizer
Last synced: 4 months ago
JSON representation
A simple CLIP tokenizer encode / decode script. For when you need to know CLIP's tokenization and / or token IDs for some reason.
- Host: GitHub
- URL: https://github.com/zer0int/clip-tokenizer
- Owner: zer0int
- Created: 2024-10-17T15:14:40.000Z (over 1 year ago)
- Default Branch: CLIP-vision
- Last Pushed: 2024-10-18T09:57:31.000Z (over 1 year ago)
- Last Synced: 2025-09-10T03:10:10.465Z (9 months ago)
- Language: Python
- Size: 1.27 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## CLIP-tokenizer
- A simple CLIP tokenizer encode / decode script. For when you need to know CLIP's tokenization and / or IDs for some reason.
---------
- `python clip-tokenizer.py --text "a photo of a cat"` - returns:
- 5: a photo of a cat ['a', 'photo', 'of', 'a', 'cat'] 320,1125,539,320,2368
- Where `5:` is the total number of tokens (token count).
---------
- `python clip-tokenizer.py --text "333, 6554, 5322" --reverse` with `--reverse`, get tokens for comma-separated IDs:
- 3: n kabrie ['n', 'kab', 'rie'] 333,6554,5322
---------
- `python clip-tokenizer.py --file exampleTEXT.txt` with `--file`, batch processes file (newline = separate input).
- `python clip-tokenizer.py --file exampleIDs.txt --reverse` batch process, but for token IDs. Both save output as file.
---------