Usable context seems to be 512 tokens, not 1024

#5
by xjlc - opened

Hi,
a heads-up for users of this model: although config.json declares n_positions=1024, the per-token loss rises 5–30× from position 512 on (e.g. Kafka's Die Verwandlung: perplexity ~20–90 at positions 0–511, ~180–1,280 at 512–1,023, consistently across five windows). The model card refers to the JAX/FLAX example hyperparameters, which use block_size=512, so the model was probably trained on 512-token sequences.

Practical consequences:

  • Perplexity or surprisal computed with windows longer than 512 tokens is inflated.
  • The tokenizer reports model_max_length = 1e30, so truncation=True does not protect against inputs over 1,024 tokens.

Workaround for long texts: sliding windows of at most 512 tokens.

Details, numbers and a reproduction script: https://github.com/stefan-it/german-gpt2/issues/20

Jochen Laubrock

Sign up or log in to comment