Urgent.News

What's breaking now, across thousands of outlets.

Tech

Are your model's probabilities calibrated? Expected calibration error in NumPy

There was a comment on Hacker News this week saying LLM token probabilities are badly calibrated for making decisions. I think that's right, and it's also something you can measure yourself in about fifteen lines, so here's how I'd do it. The usual number is expected calibration error. You take a set of predictions where you already know the outcome and put the stated probabilities into m…

A recent Hacker News comment highlighted that language model token probabilities are not well-calibrated for making decisions. The author explains how to measure this calibration using a technique called expected calibration error (ECE). By dividing predictions into equal-width bins and comparing the average stated probability with the actual outcomes, one can calculate the ECE. The code snippet provided calculates the ECE using the NumPy library in Python.

The author then compares the ECE and Brier score of four different models: one that is overconfident, one that always reports the base rate, one that is perfectly calibrated, and one that matches the true chances. The overconfident model performed poorly, while the model that always reports the base rate had an ECE of zero. The model that matches the true chances had the lowest ECE and Brier score, indicating the best calibration.

The author stresses the importance of reporting both ECE and Brier score, along with a reliability diagram, to assess a model's calibration and sharpness. They also mention that ECE can be affected by the number of bins chosen and provide a link to a worked solution for those who wish to implement and test the ECE calculation themselves.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Using NLTP with MQTT: Healing 35% Wireless Packet Loss on ESP-NOW & UDP Before Your Broker

If you have ever deployed outdoor sensor nodes over noisy 2.4 GHz radio links, ESP-NOW, or rural 4G CGNAT modems, you have probably hit the First-Mile Wall : MQTT over TCP is great inside the cloud…

  • NLTP protocol developed to address wireless packet loss in ESP-NOW and UDP
  • NLTP improves packet loss recovery by up to 35% before reaching MQTT broker
  • NLTP uses compact header, LZ4 compression, AEAD, and Reed-Solomon error correction

From Rocket Science to Code: 12 Real-World Thermodynamic Notebooks with pyglenn

Engineering textbooks routinely introduce gas dynamics under the convenient assumption of constant specific heats. Students memorize that air has a heat capacity ratio ( γ ) of 1.4, calculate cycle…

  • pyglenn-notebooks showcase real-world thermodynamic modeling
  • Brayton cycle efficiency formula assumes constant specific heats
  • pyglenn reveals 2.6 percentage point efficiency difference

More from Saturday 14 November →