Get the latest tech news

Calculate the number of language model tokens for a string


Here's an easy way to calculate the number of language model tokens for a string.

You might also need to know the number of tokens to tell if your text fits into the context window of the language model you’re working with, or if you need to chunk it first. In reality, the actual number of tokens strongly depends on the language model you’re using. What’s great about calculating the number of tokens used in a string using a Jupyter Notebook is that it’s running on your machine.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of string

string

Photo of language model

language model

Photo of number

number

Related news:

News photo

Germany: Number of unemployed highest in 10 years

News photo

String of recent killings linked to Bay Area 'Zizians'

News photo

Microsoft reportedly makes "small" number of further layoffs across divisions including gaming