Skip to content
Calcrivo

Sequence Truncation Calculator

Calculate how many tokens are lost when a sequence longer than the model's max length is truncated.

Inputs

tokens
tokens

Tokens Lost

388tokens

Truncated Length

512tokens

Loss Percentage

43.1%

Step by step

  1. Truncated length

    min(900, 512)

    = 512 tokens

  2. Tokens lost

    900 − 512

    = 388 tokens

  3. Loss percentage

    388 ÷ 900

    = 43.1%

How it works

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

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.

You might also need