Reproduce “Language Models Encode the Value of Numbers Linearly” on OpenResearch

Turn your favorite coding agents into research agents that review literature, develop hypotheses, and run experiments.

Universal app for Apple silicon and Intel. Requires macOS 11 or later.

About this paper

Fangwei Zhu, Damai Dai, Zhifang Sui

Researchers from Peking University demonstrated that large language models linearly encode numerical values within their hidden states, and these encoded representations are causally utilized for performing arithmetic operations. While the encoding is linear, its precision decreases for larger numbers, revealing a root cause for current mathematical limitations.

Key insights

  • Numerical values are linearly encoded in LLM hidden states, evident from high probe performance, although encoding precision is not perfect and decreases for larger numbers.
  • The pattern of number encoding evolves across layers, transitioning from initial digit length processing to refined precise value representation in intermediate layers, before potential noise accumulation in deeper layers.
  • Encoded numerical information persists across subsequent token positions and is causally utilized by the model, with specific layers showing functional specialization for input processing versus calculation.

Summary by alphaXiv.

Tip: change arxiv.org to autoarxiv.org in any arXiv abstract link to open the paper here.