ntloss
is a PyPI package of the "Number Token Loss" for language models. A regression-like loss that improves LLM performance on math tasks. Follows Regress, Don't Guess, ICML 2025
This repo maintains the code for the ntloss
PyPI package
- 🧑🏽💻 Paper source code: Regress, Don't Guess – ICML 2025
- 📄 Paper: Regress, Don't Guess – A Regression-like Loss on Number Tokens for Language Models
- 🌐 Project Page: Landing Page
- 🎮 Demo: HuggingFace Spaces Demo (Streamlit)
- 📖 Docs: Documentation for the PyPI package
Simply install ntloss
into your existing project
uv add ntloss
pip install ntloss # if you are oldschool
Use like this:
from ntloss import NTLoss
ntl_fn = NTLoss(tokenizer=tokenizer)
ntl = ntl_fn(logits, labels)
# We recommend
loss = cross_entropy(logits, labels) + 0.3 * ntl
NOTE: ntloss
is currently in alpha phase and pre-release. Feedback & PRs are very welcome.
If you use ntloss
, please cite our paper:
@inproceedings{zausinger2025regress,
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 Danziger and Jannis Born},
booktitle = {Proc. of the 42nd International Conference on Machine Learning (ICML)},
year = {2025},
url = {https://ibm.biz/ntl-main}
}
This project is licensed under the MIT License - see the LICENSE file for details.