﻿# WikiText: preserve the original tokenization contract

Keep WikiText raw and vocabulary-limited variants separate, preserve article boundaries, and specify the denominator behind perplexity comparisons.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/data-guide-wikitext-tokenization-contract/
Language: en

## Choose a long-context language-modeling task

WikiText was introduced in [Pointer Sentinel Mixture Models](https://arxiv.org/abs/1609.07843) to evaluate language models on more realistic vocabulary and longer contexts. Its Wikipedia-derived prose preserves dependencies that short shuffled examples can erase. This makes it useful for checking language-model likelihood and context handling. It does not supply reference summaries, answers or entailment labels, so those tasks require a different evaluation definition.

## Pin the exact released variant

The [Salesforce dataset card](https://huggingface.co/datasets/Salesforce/wikitext) distinguishes WikiText-2 and WikiText-103, each with raw-v1 and vocabulary-limited v1 configurations. The non-raw version substitutes an unknown token for out-of-vocabulary items; the raw variant retains the tokens before that substitution. Raw does not mean untouched Wikipedia markup or arbitrary contemporary article text. Record the full configuration identifier and repository revision. Replacing it with a freshly cleaned Wikipedia dump changes the benchmark even if the subject matter looks similar.

## Reconstruct context from text rows

The hosted representation provides one string field, text, and predefined train, validation and test splits. Rows include headings, passages and empty strings. A row should not automatically be interpreted as an independent article or an unrelated sample. Decide how to preserve article transitions and blank lines before concatenation. The [document provenance guide](/journal/document-markdown-json-provenance/) helps document normalization choices, especially when an export changes whitespace or removes heading markers that the model would otherwise predict.

## Specify the perplexity denominator

The [Transformers evaluation documentation](https://huggingface.co/docs/transformers/perplexity) explains that tokenization directly affects perplexity and that fixed context windows require an explicit evaluation procedure. In a proposed comparison, hold the tokenizer, context window, stride and target masking constant. Count only the targets actually scored, rather than averaging unweighted batch losses. A subword-model score and an original word-level score are not directly interchangeable merely because both use the same test text and metric name.

## Freeze validation and test roles

Use validation to select context-handling and preprocessing decisions, then evaluate the frozen procedure on test. The [split leakage guide](/journal/document-level-data-split-leakage/) explains why extra Wikipedia training material can overlap through related articles or copied passages. For pretrained models, a good WikiText result alone cannot establish unseen-document generalization. Report that limitation alongside the exact variant and scoring protocol, without assuming that a public test was excluded from every upstream pretraining source.
