Dataset Token Count Calculator
Inputs
| Words | 100 |
|---|---|
| Tokens per word | 1.3 |
| Epochs | 1 |
Dataset Token Count Calculator
Estimate how many tokens a text corpus holds from its word count and a tokens-per-word ratio, then scale by training epochs to find the total tokens a model will see.
Inputs
Corpus
Results
Enter a value to see results.
Details
Dataset Token Count
Training and budgeting a language model start from a single quantity: how many tokens the dataset contains. Corpora, however, are usually described in words, documents, or gigabytes, not tokens, and the model only ever reads tokens. This calculator bridges that gap by converting a word count into an estimated token count with a tokens-per-word ratio, then scaling by the number of training epochs to give the total a model will process.
Tokens, not words
A token is the atomic unit a tokenizer produces when it splits text into subword pieces. Frequent words often become a single token, while rarer or longer words are divided into several, so a passage almost always contains more tokens than words. Because the mapping is learned by the tokenizer, the ratio between tokens and words is a property of the tokenizer and the text rather than a universal constant. Treating words and tokens as interchangeable understates the true count and, with it, the compute a run will need.
How the estimate works
The corpus size enters in millions of words, . Multiplying by the tokens-per-word ratio gives the tokens in a single pass over the data. Repeating the corpus for epochs multiplies the work the model performs, so the effective training tokens are the one-pass total times the epoch count. A billions figure is derived from the millions total because training-set sizes are most often quoted in billions of tokens.
The formula
With in millions of words, ratio , and epochs, the one-pass total (millions), its billions form, and the epoch-scaled training total (millions) are
TE=W⋅r=T⋅eThe billions figure is simply .
Worked example
Take a 100-million-word corpus tokenized at 1.3 tokens per word and trained for three epochs:
TE=100×1.3=130 million tokens=130×3=390 million tokensOne pass over the data is about 130 million tokens, or 0.13 billion. Training for three epochs means the model performs forward and backward passes over the equivalent of 390 million tokens, even though only 130 million are unique. The unique total describes the information available; the epoch-scaled total describes the work and therefore the compute.
Choosing the ratio
For English prose with a modern byte-pair tokenizer, roughly 1.3 tokens per word is a reasonable default, and about four characters per token is a related approximation. Code, mathematics, and non-Latin scripts tend to fragment into more tokens, raising the ratio. The dependable approach is to run the intended tokenizer on a representative sample and divide its token output by the word count of that sample, then use the measured ratio here. The inverse conversion, from a token budget back to readable length, is handled by the Tokens to Words Calculator.
Limits
The result is an estimate. The exact token count depends on the specific tokenizer, on formatting and whitespace, and on how documents are joined, none of which a single ratio captures perfectly. Counting epochs as additional tokens is correct for compute and scaling, but repeated tokens carry no new information and offer diminishing returns past a few passes. To check whether a dataset is large enough for a given model size, compare the one-pass total against the compute-optimal target in the Chinchilla Optimal Tokens Calculator.
Frequently Asked Questions (FAQ)
How do tokens differ from words?
A token is the unit a model actually reads, produced by a tokenizer that splits text into subword pieces. Common words often map to a single token, while rarer or longer words are broken into several, so the token count of a text is usually higher than its word count.
The ratio between the two depends on the tokenizer and the language, which is why this estimate scales a word count by an explicit tokens-per-word factor rather than assuming they are equal.
What tokens-per-word ratio is reasonable?
For English prose tokenized with a modern byte-pair or unigram tokenizer, roughly 1.3 tokens per word is a common rule of thumb, and about four characters per token is a related estimate. Code, mathematics, and morphologically rich or non-Latin-script languages typically produce more tokens per word.
The most reliable figure comes from running the target tokenizer on a representative sample of the actual corpus and dividing the resulting token count by the word count.
Should repeated epochs be counted as more tokens?
For compute and scaling estimates, yes: each epoch performs another full set of forward and backward passes over the data, so the effective training tokens are the one-pass count times the number of epochs.
For data-uniqueness questions the distinction matters, because repeated tokens are not new information and offer diminishing returns past a few passes. This calculator reports both the unique one-pass total and the epoch-scaled training total so either view is available.
Disclaimer
Token counts are estimates based on an average tokens-per-word ratio; the exact total depends on the specific tokenizer and the text itself. Run the intended tokenizer on a sample for a precise figure before committing compute budgets.