Fourier Head: Helping Large Language Models Learn Complex Probability Distributions

Nate Gillman, Daksh Aggarwal, Michael Freeman, Chen Sun

The Challenge of Continuous Data in LLMs

As Large Language Models (LLMs) continue to advance, researchers are increasingly adapting them for non-linguistic tasks like robotic control (e.g., Decision Transformers) and time series forecasting (e.g., Chronos). In these continuous domains, standard practice involves discretizing continuous values into discrete "bins" or tokens.

However, this approach introduces a significant flaw: a standard linear head treats these bins as entirely independent categories. To an LLM, token ID 1000 and 1001 are as unrelated as the words "apple" and "zebra," even if they represent nearly identical numerical values. This lack of "continuity awareness" forces the model to learn the relationship between adjacent bins from scratch, often resulting in jagged, noisy probability distributions that overfit to training artifacts. Conversely, simpler alternatives like Gaussian heads are often too restrictive to model the complex, multi-modal distributions found in real-world data.

Comparison of a learned linear PMF versus a learned Fourier PMF on a bimodal distribution.

Introducing the Fourier Head

To bridge this gap, researchers introduce the Fourier Head, a novel, drop-in replacement for the final linear layer in LLMs designed specifically to help them master continuous data. Instead of predicting independent logits for every possible bin, the Fourier Head parameterizes the probability distribution as a Fourier series.

How It Works

  1. Fourier Series Construction: The head uses a linear layer to predict coefficients for a truncated Fourier series rather than $m$ independent logits.
  2. The Continuity Prior: Because the distribution is built from a finite sum of sines and cosines, the resulting output is inherently continuous and smooth. It acts as a low-pass filter, allowing the model to learn the underlying "signal" of the distribution while ignoring high-frequency noise.
  3. Drop-in Compatibility: The Fourier Head uses the same cross-entropy loss as standard heads, making it incredibly easy to swap into existing architectures without overhauling the training pipeline.

Key Insights and Synthetic Benchmarks

The core "aha moment" of the Fourier Head is that for numerical data, nearby tokens should have similar probabilities. The architecture bakes this inductive bias directly into the model. In noisy domains like reinforcement learning or time series, a standard linear head tends to "fit the noise," creating unnatural spikes. The Fourier Head's inability to represent infinite frequencies forces it to produce smoother, more physically plausible distributions.

Performance of Linear, GMM, and Fourier heads on synthetic Gaussian and Beta datasets.

When tested on synthetic distributions (like Gaussian and Beta datasets), the Fourier Head demonstrates a clear advantage over both standard Linear PMFs and Gaussian Mixture Model (GMM) PMFs, accurately capturing the true probability density function with significantly smoother curves. Interestingly, a side-study revealed that standard LLMs like Llama-3 are surprisingly poor random number generators; replacing Llama-3's head with a Fourier Head improved its sampling accuracy from a simple Gaussian distribution by nearly 5x.

Real-World Results: Atari and Forecasting

The theoretical benefits of the Fourier Head translate into substantial real-world performance gains across diverse benchmarks:

  • Offline Reinforcement Learning: When integrated into a Decision Transformer architecture playing Atari games, the Fourier Head led to massive improvements. In the game Gravitar, it boosted returns by a staggering 377%, and in Seaquest, it provided a 46% boost.
  • Time Series Forecasting: The researchers swapped the Fourier Head into the state-of-the-art Chronos foundation model. Across 20 zero-shot benchmarks (including weather, traffic, and electricity datasets unseen during training), it improved forecasting accuracy (MASE) by 3.5%, setting a new state-of-the-art.

Limitations and Future Directions

While powerful, the Fourier Head does have limitations. Most notably, it requires the output bins to have a natural, semantically meaningful order (like numbers, coordinates, or directions). It cannot be applied to arbitrary natural language tokens where no such continuous relationship exists. Additionally, the number of frequencies ($N$) is a critical hyperparameter that requires task-specific tuning, though the authors provide a "Fourier Head Scaling Law" to help guide this choice.

Future work may explore training objectives that bypass discretization entirely—such as direct Maximum Likelihood Estimation on continuous values—and investigate how Fourier Heads might be integrated earlier in the pre-training phase of general-purpose foundation models.

Summary updated

BibTeX
@inproceedings{gillman2025fourier,
  author = {Nate Gillman and Daksh Aggarwal and Michael Freeman and Chen Sun},
  title = {{Fourier Head: Helping Large Language Models Learn Complex Probability Distributions}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=4hPwLg7zD3},
}
Figure