|
import pandas as pd |
|
import streamlit as st |
|
import re |
|
|
|
COLOR_MAP = { |
|
"light": { |
|
"yellow": "background-color: rgba(255, 255, 128, 0.3)", |
|
"green": "background-color: rgba(192, 255, 192, 0.3)", |
|
"blue": "background-color: rgba(192, 192, 255, 0.3)" |
|
}, |
|
} |
|
|
|
def get_color_map(): |
|
"""Returns the appropriate color map based on the current theme.""" |
|
return COLOR_MAP["light"] |
|
|
|
def style_zero_context(df): |
|
""" |
|
Similar approach to style_long_context: |
|
1) color rows based on model name |
|
2) numeric formatting |
|
""" |
|
import pandas as pd |
|
|
|
|
|
color_mapping = { |
|
"minimax-text-01": get_color_map()["green"], |
|
"jamba-1.5-large": get_color_map()["blue"], |
|
"deepseek-r1": get_color_map()["yellow"], |
|
"o1-mini": get_color_map()["yellow"], |
|
"o3-mini": get_color_map()["yellow"], |
|
"qwq-32b-preview": get_color_map()["yellow"], |
|
|
|
|
|
} |
|
|
|
df["Model"] = df.apply(lambda row: f'<a href="{row["Link"]}" target="_blank">{row["Model"]}</a>', axis=1) |
|
df.drop(columns=["Link"], inplace=True) |
|
|
|
styler = df.style.apply( |
|
lambda row: [color_mapping.get(re.sub(r'<[^>]+>', '', row["Model"]), "")]*len(row), |
|
axis=1 |
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
styler = styler.format({ |
|
"Symbolic": "{:,.2f}", |
|
"Medium": "{:,.2f}", |
|
"Hard": "{:,.2f}", |
|
"1st<50% op": "{:,.0f}", |
|
"1st<10% op": "{:,.0f}", |
|
"Avg. Acc op≤30": "{:.4f}", |
|
"Average↑": "{:,.2f}" |
|
}) |
|
|
|
html = styler.to_html(escape=False, index=False) |
|
|
|
|
|
for model, style in color_mapping.items(): |
|
html = re.sub(rf'<tr[^>]*>\s*<td[^>]*>{re.escape(model)}<', rf'<tr style="{style}"><td>', html, re.M) |
|
|
|
html = re.sub( |
|
r'<table(.*?)>', |
|
r'<table\1 style="width:100%; border-collapse:collapse;">', |
|
html |
|
) |
|
return html |
|
|
|
|
|
return styler |
|
|
|
def style_long_context(df): |
|
color_mapping = { |
|
"minimax-text-01": get_color_map()["green"], |
|
"jamba-1.5-large": get_color_map()["blue"] |
|
} |
|
|
|
df["Model"] = df.apply(lambda row: f'<a href="{row["Link"]}" target="_blank">{row["Model"]}</a>', axis=1) |
|
df.drop(columns=["Link"], inplace=True) |
|
|
|
styled_df = df.style.apply( |
|
lambda row: [color_mapping.get(re.sub(r'<[^>]+>', '', row["Model"]), "")]*len(row), |
|
axis=1 |
|
).format({ |
|
"8K": "{:,.2f}", |
|
"16K": "{:,.2f}", |
|
"32K": "{:,.2f}", |
|
"Average↑": "{:,.2f}", |
|
}) |
|
|
|
|
|
html = styled_df.to_html(escape=False, index=False) |
|
|
|
|
|
for model, style in color_mapping.items(): |
|
html = re.sub(rf'<tr[^>]*>\s*<td[^>]*>{re.escape(model)}<', rf'<tr style="{style}"><td>', html, re.M) |
|
|
|
html = re.sub( |
|
r'<table(.*?)>', |
|
r'<table\1 style="width:100%; border-collapse:collapse;">', |
|
html |
|
) |
|
|
|
return html |