Skip to main content

Number Token Loss - A regression-alike loss to improve numerical reasoning in language models

Project description

NTLoss - a regression-like loss for LLMs

Paper Landing Demo CI License PyPI Docs Downloads

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


📖 Overview

This repo maintains the code for the ntloss PyPI package

🏃‍♂️ Quick Start

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.

📝 Citation

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}
}

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ntloss-0.3.0.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ntloss-0.3.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file ntloss-0.3.0.tar.gz.

File metadata

  • Download URL: ntloss-0.3.0.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ntloss-0.3.0.tar.gz
Algorithm Hash digest
SHA256 5c66fc8db60e4223ff6b28f2064b5464d89a14810e013538ac23583b33fbad2c
MD5 5d032ffcda0ecf191c666f5cbb183040
BLAKE2b-256 b3d2d139e3a9854958e898d4aea9629ff47acad9ccc0897c692f3a079ffc1362

See more details on using hashes here.

File details

Details for the file ntloss-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: ntloss-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ntloss-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c7cbeec96da0f18508044fd0ffac79f59cdfe2977da4c6244e4f1dfa542e7267
MD5 20fd85ddc6e5e9e6d8882d379df823d1
BLAKE2b-256 b5a15e144a9f35208f9617ceaa51838a6c36ab0aa076aa1aa5408186a3a56e61

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page