Preprint
Machine Learning

Hyperfitting

December 1, 2024

0

Citations

0

Influential Citations

Venue

2024

Year

Abstract

Involves fine-tuning a pre-trained LLM on a small dataset until near-zero training loss, significantly improving greedy decoding generation quality despite worsening validation loss. This counter-intuitive process sharpens the model's prediction space, often favoring single tokens, and enhances long-sequence generation even with citation blocking, suggesting the improvement isn't simply memorization.

Analysis

Why This Paper Matters

Large language models (LLMs) often produce repetitive, dull text when using greedy decoding—the simplest and fastest generation method. This paper introduces hyperfitting, a counterintuitive fine-tuning approach that deliberately overfits a model on a tiny dataset to near-zero training loss. Surprisingly, this worsens validation loss but dramatically improves the quality of greedy decoding for long sequences, sometimes even surpassing more complex sampling methods. The finding challenges conventional wisdom that good generalization requires low validation loss and opens a practical path to better generation without expensive decoding strategies.

How It Works

Hyperfitting is conceptually simple: take a pre-trained LLM and fine-tune it on a small set of 2000 sequences (each 256 tokens) for 20 epochs using a low learning rate (1e-6) and no weight decay. The goal is to drive training loss to near zero, even at the cost of high validation loss. The authors test this on models ranging from TinyLlama 1.1B to Llama 3.1 70B, and even on ImageGPT for image generation.

Figure 1

The key insight is that hyperfitting sharpens the model's prediction distribution—it assigns extremely high probability to a single token at each step, producing low-entropy outputs. This sharpening persists even on unseen data, where the model confidently predicts tokens it favors, leading to high perplexity but more coherent and diverse long sequences.

Training and validation loss for TinyLlama during overfitting, along with the resulting mean type-token-ratio when greedily generating 96 tokens from contexts in the validation data.

To rule out simple memorization, the authors use a citation blocker that prevents the model from repeating long subsequences from the training data. Even with this blocker, hyperfitted models maintain their improved generation quality, indicating the effect is not just rote recall.

Results

Human evaluation shows hyperfitting boosts preference rates dramatically—for TinyLlama, from 4.9% to 34.4% for 256-token continuations. Hyperfitted models also achieve higher Type-Token Ratio (TTR) and lower Self-BLEU, meaning more diverse text. Greedy decoding with hyperfitted models even beats nucleus sampling with original models on human ratings and diversity.

Comparison of perplexity over contexts, human preference of generated texts, and lexical variation (as measured by TTR).

Interestingly, perplexity worsens after hyperfitting, confirming it is a poor metric for long-text generation quality. The sharpened predictions cause the model to assign low probability to unseen tokens, inflating cross-entropy.

Diversity metrics for generated texts of 96 tokens.

Data influence experiments reveal that data order matters: shuffling the training data changes top-1 predictions by ~30%. Reducing the number of samples (while keeping update steps constant) lowers TTR, but even 16 samples yield decent results. The type of training data (news, Wikipedia, fiction) affects overall performance but not in a dataset-specific way.

Left: Top-1 rank similarity matrix of Llama 3.1 (8B) hyperfitted on identical, but shuffled, data. Right: The resulting mean TTR of 300 generated texts as the number of training samples vary.

Human success ratio for 256 token lengths across Fiction, Wiki, and News datasets.

Hyperfitting also generalizes to image generation: hyperfitted ImageGPT produces noticeably better images when greedily generating the remaining 75% of an image from the first 25%.

Examples of generated images using greedy decoding when passed 25% of an image.

Significance

This paper provides a simple, computationally cheap method to improve greedy decoding for long-form generation, with implications for both text and image modalities. It challenges the reliance on perplexity as a quality metric and suggests that sharp, low-entropy predictions can be beneficial despite poor generalization on held-out data. The work also highlights the non-deterministic role of data order in fine-tuning, which warrants further investigation. For practitioners, hyperfitting offers an easy way to boost generation quality without switching to more complex sampling or larger models.