From 91b1496d10d363ec461648cdf16760062ee4c1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Kardos?= Date: Tue, 12 Nov 2024 13:42:20 +0100 Subject: [PATCH] fix: Made n_parameters formatting smarter and more robust --- mteb/leaderboard/table.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mteb/leaderboard/table.py b/mteb/leaderboard/table.py index bc8103077..80c827cb5 100644 --- a/mteb/leaderboard/table.py +++ b/mteb/leaderboard/table.py @@ -30,13 +30,17 @@ def format_scores(score: float) -> float: def format_n_parameters(n_parameters) -> str: - if n_parameters is None: + if (n_parameters is None) or (not int(n_parameters)): return "" - n_million = int(n_parameters) // 1e6 - n_zeros = math.log10(n_million) + n_thousand = int(n_parameters // 1e3) + if n_thousand < 1: + return str(int(n_parameters)) + n_zeros = math.log10(n_thousand) + if n_zeros >= 6: + return str(n_thousand // (10**6)) + "B" if n_zeros >= 3: - return str(n_million // (10**3)) + "B" - return str(n_million) + "M" + return str(n_thousand // (10**3)) + "M" + return str(n_thousand) + "K" def split_on_capital(s: str) -> str: