NeurIPS 2026QuestionsPapersAreasAboutMarkdown

Long-Context Generation Is a Sampling Problem

Allen Roush, Minh N Nguyen, Ravid Shwartz-Ziv, Judah Goldfeder, Sanjay Basu

NeurIPS page · OpenReview · Open on the map

Category: LLM Reasoning, Memory & RAG › Diffusion Language Model Sampling · Type: new method · Keywords: long-context generation, sampling algorithms, repetition reduction, language model evaluation, token selection

Areas: Long Context › Long-context mechanisms › Long-context reasoning

Summary

The paper shows that the sampling algorithm is a primary determinant of long-context generation quality, demonstrating that full-distribution-aware samplers dramatically reduce repetition without any model retraining.

Explained to a 5-year-old

When a computer writes a long story, it sometimes repeats the same words over and over. People who build these computers have tried making the computers bigger, but that costs a lot of money. The researchers found that the way the computer chooses each word is very important. By using a smarter way to pick words that looks at all the possibilities, the stories become much less repetitive. This helps the computer write longer, better stories without needing to change the whole computer.

Explained to a 5-year-old, longer

When a computer program writes a long text, like a story or an article, it sometimes gets stuck and repeats the same words many times. People who build these programs have thought that maybe the computer itself needs to be bigger or learn more to fix this. But the new research shows that the way the computer picks each word is a big reason for the repeats. Usually, the computer only looks at a few of the most likely words, which can lead it into a loop. The scientists tried a different idea: they made the computer look at all the possible words, not just a few. This new way of picking words helps the computer avoid getting stuck and makes the text smoother. They tested this on many different computer models, from small ones to very big ones. Even the biggest models wrote longer texts with almost no repeats when using the new picking method. The improvement works without having to change how the computer was trained, saving time and money. This makes it easier for people to use computers for writing long documents, coding, or other tasks that need lots of text.

For a technical reader

The study evaluates sampling algorithms across a range of model sizes and context lengths, measuring repetition with both automated metrics and human judgments. It finds that distribution-aware samplers consistently outperform truncation-based methods, with the advantage increasing as model scale grows. A per-step rank analysis reveals why standard truncation drives token selection toward the argmax floor, causing late-context repetition. The results suggest that careful sampler selection can yield substantial quality gains at negligible cost.

Problem

Language models often produce repetitive outputs when generating long texts, limiting their usefulness for long-context tasks. Existing solutions focus on model capacity or training, leaving the impact of the sampling algorithm under-explored.

Method

The authors evaluate a range of sampling strategies on multiple open-weight models across varying context lengths, measuring repetition via automated metrics and human evaluation. They also employ a per-step rank diagnostic to analyze how different samplers affect token selection dynamics.

Results

Samplers that consider the full token distribution achieve significantly lower repetition than standard truncation methods, with near-zero 10-gram repetition at long contexts and a clear advantage that grows with model size.

Contributions

The paper demonstrates that the sampling algorithm is a primary factor in long-context generation quality, showing that distribution-aware sampling greatly reduces repetition without model retraining. It also provides a rank diagnostic to explain why standard truncation fails and highlights the underappreciated bottleneck of sampler choice.

Practical relevance

The findings enable cheaper improvements to long-context language model outputs by simply choosing better sampling algorithms, benefiting applications such as long-context coding and other tasks requiring extended text generation.

Research questions this paper is counted under

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. Suggest a correction