mirror of
https://github.com/p-e-w/heretic.git
synced 2026-10-15 15:10:08 -07:00
+29
-28
@@ -1327,6 +1327,15 @@ def run():
|
|||||||
else:
|
else:
|
||||||
table.add_column("Value", justify="right")
|
table.add_column("Value", justify="right")
|
||||||
|
|
||||||
|
def format_value(value: Any) -> str:
|
||||||
|
if isinstance(
|
||||||
|
value,
|
||||||
|
(float, np.floating),
|
||||||
|
):
|
||||||
|
return f"{value:.4f}"
|
||||||
|
else:
|
||||||
|
return f"{value}"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
first_benchmark = True
|
first_benchmark = True
|
||||||
|
|
||||||
@@ -1350,37 +1359,29 @@ def run():
|
|||||||
first_row = True
|
first_row = True
|
||||||
|
|
||||||
for metric, value in results.items():
|
for metric, value in results.items():
|
||||||
if metric != "alias":
|
# Skip non-metrics.
|
||||||
if first_row and not first_benchmark:
|
if metric in ["name", "alias", "sample_len"]:
|
||||||
if benchmark_original_model:
|
continue
|
||||||
table.add_row("", "", "", "")
|
|
||||||
else:
|
|
||||||
table.add_row("", "", "")
|
|
||||||
|
|
||||||
def format_value(value: Any) -> str:
|
if first_row and not first_benchmark:
|
||||||
if isinstance(
|
|
||||||
value,
|
|
||||||
(float, np.floating),
|
|
||||||
):
|
|
||||||
return f"{value:.4f}"
|
|
||||||
else:
|
|
||||||
return f"{value}"
|
|
||||||
|
|
||||||
cells = [
|
|
||||||
benchmark.name if first_row else "",
|
|
||||||
metric,
|
|
||||||
format_value(value),
|
|
||||||
]
|
|
||||||
if benchmark_original_model:
|
if benchmark_original_model:
|
||||||
cells.append(
|
table.add_row("", "", "", "")
|
||||||
format_value(
|
else:
|
||||||
original_results[metric]
|
table.add_row("", "", "")
|
||||||
)
|
|
||||||
)
|
|
||||||
table.add_row(*cells)
|
|
||||||
|
|
||||||
first_row = False
|
cells = [
|
||||||
first_benchmark = False
|
benchmark.name if first_row else "",
|
||||||
|
metric,
|
||||||
|
format_value(value),
|
||||||
|
]
|
||||||
|
if benchmark_original_model:
|
||||||
|
cells.append(
|
||||||
|
format_value(original_results[metric])
|
||||||
|
)
|
||||||
|
table.add_row(*cells)
|
||||||
|
|
||||||
|
first_row = False
|
||||||
|
first_benchmark = False
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user