Calculate the number of language model tokens for a string (blog.mastykarz.nl) 17 points by waldekm 1y ago ↗ HN
[–] sva_ 1y ago ↗ 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
[–] 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
3 comments
[ 4.2 ms ] story [ 20.8 ms ] thread