Sequence Truncation Calculator
Calculate how much of a sequence will be truncated to fit a maximum input length.
About Sequence Truncation Calculator
When an input sequence exceeds a model's maximum context length, it must be truncated — typically by cutting tokens from the end (or sometimes the middle or start, depending on the strategy) — which discards information. This calculator computes the truncated length as min(original, max), the number of tokens lost, and the percentage of the original sequence discarded, helping you gauge how much information loss to expect for long documents.
Formula
tokens_lost = max(0, sequence_length - max_length)
- sequence_length
- Original sequence length in tokens
- max_length
- Model maximum context length
Worked example
With the default values below, Sequence Truncation Calculator returns Tokens Lost of 388. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Original Sequence Lengthaccepts 0–10,000,000 tokens
- 900 tokens
- Max Length (model limit)accepts 1–10,000,000 tokens
- 512 tokens
Results
- Tokens Lost
- 388 tokens
- Truncated Length
- 512 tokens
- Loss Percentage
- 43.1 %
Step by step
- 1Truncated length= 512 tokens
- 2Tokens lost= 388 tokens
- 3Loss percentage= 43.1%
Assumptions and limits
- The result is derived only from the 2 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to 1 decimal place, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
Which end of the sequence gets truncated?
Convention varies by framework — many NLP pipelines truncate from the end by default, but some tasks (e.g. summarization of long documents) benefit from truncating the middle or keeping both the start and end.
How much loss is acceptable?
It depends on the task — for classification tasks where key information appears early, even high loss percentages may not hurt performance; for tasks needing full-document context, any truncation risks missing critical information.
What's an alternative to truncation?
Consider chunking the document into multiple overlapping windows and aggregating predictions, or using a model with a longer context window if truncation loss is unacceptable.
