Skip to content
Better HN
Top
Best
Ask
Show
New
Jobs
Search
⌘K
Calculate the number of language model tokens for a string
(opens in new tab)
(blog.mastykarz.nl)
17 points
waldekm
1y ago
3 comments
Save
Share
3 comments
3 comments · 1 top-level
top
newest
oldest
sva_
1y ago
· 2 in thread
import tiktoken enc = tiktoken.encoding_for_model('o1-mini') len(enc.encode('some string'))
NitpickLawyer
1y ago
Does that work on anything other than openai?
topicseed
1y ago
No but most models have their own libs you can use
j
/
k
navigate · click thread line to collapse