Regress, Don't Guess -- A Regression-like Loss on Number Tokens for Language Models

Jonas Zausinger, Lars Pennig, Anamarija Kozina, Sean Sdahl, Julian Sikora +11 more
11/4/2024
cs.CLcs.AIcs.CE

Official code: ai4sd/number-token-loss (25 stars, MIT, last commit 2026-04-07). 1 more implementation below.

Abstract

While language models have exceptional capabilities at text generation, they lack a natural inductive bias for emitting numbers and thus struggle in tasks involving quantitative reasoning, especially arithmetic. One fundamental limitation is the nature of the cross-entropy (CE) loss, which assumes a nominal scale and thus cannot convey proximity between generated number tokens. In response, we here present a regression-like loss that operates purely on token level. Our proposed Number Token Loss (NTL) comes in two flavors and minimizes either the $L_p$ norm or the Wasserstein distance between the numerical values of the real and predicted number tokens. NTL can easily be added to any language model and extend the CE objective during training without runtime overhead. We evaluate the proposed scheme on various mathematical datasets and find that it consistently improves performance in math-related tasks. In a direct comparison on a regression task, we find that NTL can match the performance of a regression head, despite operating on token level. Finally, we scale NTL up to 3B parameter models and observe improved performance, demonstrating its potential for seamless integration into LLMs. We hope to inspire LLM developers to improve their pretraining objectives and distribute NTL as a minimalistic and lightweight PyPI package $ntloss$: https://github.com/ai4sd/number-token-loss. Development code for full paper reproduction is available separately.

View on arXivView PDF

Code Implementations(2)

MIT

PyPI package for Number Token Loss (ICML 2025)

251PythonAug 5, 20256 months agoMIT
language-modelsllmllm-trainingreasoning
MIT

A regression-alike loss to improve numerical reasoning in language models - ICML 2025

305Python, Jupyter NotebookJul 3, 20241 years agoMIT
llm-trainingllmsnumber-token-lossreasoning-language-models

Similar Papers

Cite this paper

@article{zausinger2024regress,
  title  = {Regress, Don't Guess -- A Regression-like Loss on Number Tokens for Language Models},
  author = {Jonas Zausinger and Lars Pennig and Anamarija Kozina and Sean Sdahl and Julian Sikora and Adrian Dendorfer and Timofey Kuznetsov and Mohamad Hagog and Nina Wiedemann and Kacper Chlodny and Vincent Limbach and Anna Ketteler and Thorben Prein and Vishwa Mohan Singh and Michael Morris Danziger and Jannis Born},
  year   = {2024},
  eprint = {2411.02083},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2411.02083v3}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2411.02083.svg)](https://codeofpaper.com/paper/2411.02083)

Discussion