Span Corruption › Span Corruption Variants
Language AI HandbookAll chapters Span Corruption › Span Corruption VariantsOne section · Sections in this chapter8 / 14 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Researchers have explored several variations of the basic span corruption approach. Each variant modifies one or more of the core design choices: the span length distribution, the corruption rate, or the attention pattern used during training. Understanding these variants illuminates the space of possible pretraining objectives and helps explain design choices in models beyond T5.
Uniform vs. Geometric Span Lengths
While T5 uses geometric distribution, some work explores uniform distributions. With uniform sampling between 1 and , every span length up to is equally likely:
def sample_span_lengths_uniform(num_spans, min_length=1, max_length=5):
"""Sample span lengths from uniform distribution."""
return np.random.randint(min_length, max_length + 1, size=num_spans)
def sample_span_lengths_geometric(num_spans, mean_length=3):
"""Sample span lengths from geometric distribution."""
p = 1 / mean_length
return np.random.geometric(p, size=num_spans)n_samples = 5000
uniform_spans = sample_span_lengths_uniform(n_samples, max_length=5)
geometric_spans = sample_span_lengths_geometric(n_samples, mean_length=3)

Geometric distributions produce more short spans but allow occasional long ones. Uniform distributions guarantee exposure to longer spans but may waste capacity on trivially short reconstructions.
The practical implication is that the choice of distribution should match the downstream task distribution. If the primary downstream tasks involve short phrase completions and entity identification, the geometric distribution with a small mean aligns well. If the tasks involve longer document-level generation or summarization where multi-sentence spans matter, experimenting with higher mean values or distributions with heavier tails may be worthwhile.
We can also explore how different mean span lengths affect the distribution shape. Higher means produce flatter distributions with more emphasis on longer spans.

With , nearly half of all spans are single tokens. This provides mostly token-level signal. With , the distribution flattens clearly. This exposes the model to longer spans more frequently but at the cost of fewer distinct spans per sequence. T5's choice of balances these extremes.
Corruption Rate Variations
The original T5 paper tested corruption rates from 10% to 50%. Higher rates create shorter inputs but longer targets:
def analyze_corruption_rate(
seq_length, corruption_rate, mean_span=3, num_trials=1000
):
"""Analyze the effect of corruption rate on sequence lengths."""
input_lengths = []
target_lengths = []
for _ in range(num_trials):
mask = select_corruption_mask(seq_length, corruption_rate, mean_span)
spans = get_span_boundaries(mask)
# Input length = original - corrupted + num_sentinels
corrupted_count = mask.sum()
input_len = seq_length - corrupted_count + len(spans)
input_lengths.append(input_len)
# Target length = corrupted + num_sentinels
target_len = corrupted_count + len(spans)
target_lengths.append(target_len)
return np.mean(input_lengths), np.mean(target_lengths)seq_length = 512
corruption_rates = [0.1, 0.15, 0.2, 0.25, 0.3, 0.4, 0.5]
results = []
for rate in corruption_rates:
input_len, target_len = analyze_corruption_rate(seq_length, rate)
results.append(
{
"rate": rate,
"input_length": input_len,
"target_length": target_len,
"total": input_len + target_len,
}
)
At 15% corruption, the input shrinks modestly while the target remains manageable. Higher rates shift more content to the target, which can slow training due to longer autoregressive generation.
Prefix LM Variant
Some models combine span corruption with prefix language modeling. The uncorrupted prefix receives bidirectional attention, while corrupted spans use causal attention:
Input: "The quick brown" + <extra_id_0> + "jumps over" + <extra_id_1>
Attention:
- "The quick brown": Bidirectional (full visibility)
- Sentinels and after: Causal (left-to-right only)
This hybrid approach lets the model use bidirectional context for understanding while maintaining generative capability. The intuition is that a strong language model needs both skills: reading and understanding text (served by bidirectional attention) and generating new text (served by causal autoregressive generation). The prefix LM variant approximates this by giving the prefix full attention while treating the generation phase causally.
UL2 (Unifying Language Learning Paradigms), introduced by Google in 2022, extended this idea further by mixing multiple denoising objectives during pretraining, including span corruption, prefix language modeling, and extreme long-span corruption. The UL2 paper showed that no single objective is universally best across all tasks and that a mixture of objectives produces more versatile models. This finding validated the span corruption design while also showing its limitations: a model pretrained only on span corruption will underperform on tasks that require strong causal generation from an open-ended prompt.