Skip to content

Commit

Permalink
fix: Made n_parameters formatting smarter and more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
x-tabdeveloping committed Nov 12, 2024
1 parent 7fd94f4 commit 91b1496
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions mteb/leaderboard/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 91b1496

Please sign in to comment.