Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ df = pd.read_csv(DATA_FILE)
|
|
9 |
# Normalize column names
|
10 |
df.columns = df.columns.str.strip()
|
11 |
|
12 |
-
#
|
13 |
st.title("Russian Router Ranking (RRR) Leaderboard")
|
14 |
st.markdown("""
|
15 |
[GitHub Repository](https://github.com/EvilFreelancer/rrr-benchmark)
|
@@ -18,38 +18,34 @@ The table shows the accuracy and performance of the models on the
|
|
18 |
""")
|
19 |
|
20 |
|
|
|
21 |
def model_size_sort_key(size: str):
|
22 |
-
"""
|
23 |
-
Converts model size (e.g. '7b', '1m') to a numeric key for sorting.
|
24 |
-
'm' = mega (1e6), 'b' = billion (1e9)
|
25 |
-
"""
|
26 |
if not isinstance(size, str):
|
27 |
return float('inf')
|
28 |
match = re.match(r"(\d+(?:\.\d+)?)([mb])", size.lower())
|
29 |
if not match:
|
30 |
-
return float('inf')
|
31 |
-
|
32 |
num, unit = match.groups()
|
33 |
multiplier = 1e6 if unit == 'm' else 1e9
|
34 |
return float(num) * multiplier
|
35 |
|
36 |
|
37 |
-
# Sidebar
|
38 |
with st.sidebar:
|
39 |
st.header("Filters")
|
40 |
|
41 |
-
#
|
42 |
model_name_options = sorted(df["model_name"].dropna().unique(), key=str.lower)
|
43 |
model_name = st.multiselect("Select model:", options=model_name_options)
|
44 |
|
45 |
-
#
|
46 |
model_size_options = sorted(df["model_size"].dropna().unique(), key=model_size_sort_key)
|
47 |
model_size = st.multiselect("Select size:", options=model_size_options)
|
48 |
|
49 |
-
#
|
50 |
model_quant = st.multiselect("Select quantization:", options=sorted(df["model_quant"].dropna().unique()))
|
51 |
|
52 |
-
# Apply filters
|
53 |
filtered_df = df.copy()
|
54 |
if model_name:
|
55 |
filtered_df = filtered_df[filtered_df["model_name"].isin(model_name)]
|
@@ -58,17 +54,45 @@ if model_size:
|
|
58 |
if model_quant:
|
59 |
filtered_df = filtered_df[filtered_df["model_quant"].isin(model_quant)]
|
60 |
|
61 |
-
#
|
62 |
format_dict = {
|
63 |
"accuracy": "{:.2%}".format,
|
64 |
"avg_response_time": "{:.3f}".format,
|
65 |
"avg_token_count": "{:.1f}".format
|
66 |
}
|
67 |
|
68 |
-
# Remove model column
|
69 |
-
display_df = filtered_df.drop(columns=["model"], errors="ignore")
|
70 |
|
71 |
-
#
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
)
|
|
|
9 |
# Normalize column names
|
10 |
df.columns = df.columns.str.strip()
|
11 |
|
12 |
+
# Page header
|
13 |
st.title("Russian Router Ranking (RRR) Leaderboard")
|
14 |
st.markdown("""
|
15 |
[GitHub Repository](https://github.com/EvilFreelancer/rrr-benchmark)
|
|
|
18 |
""")
|
19 |
|
20 |
|
21 |
+
# Function to sort model sizes numerically (e.g., 7b < 13b < 32b, etc.)
|
22 |
def model_size_sort_key(size: str):
|
|
|
|
|
|
|
|
|
23 |
if not isinstance(size, str):
|
24 |
return float('inf')
|
25 |
match = re.match(r"(\d+(?:\.\d+)?)([mb])", size.lower())
|
26 |
if not match:
|
27 |
+
return float('inf')
|
|
|
28 |
num, unit = match.groups()
|
29 |
multiplier = 1e6 if unit == 'm' else 1e9
|
30 |
return float(num) * multiplier
|
31 |
|
32 |
|
33 |
+
# Sidebar filters
|
34 |
with st.sidebar:
|
35 |
st.header("Filters")
|
36 |
|
37 |
+
# Model name filter (case-insensitive sort)
|
38 |
model_name_options = sorted(df["model_name"].dropna().unique(), key=str.lower)
|
39 |
model_name = st.multiselect("Select model:", options=model_name_options)
|
40 |
|
41 |
+
# Model size filter (numerical sort)
|
42 |
model_size_options = sorted(df["model_size"].dropna().unique(), key=model_size_sort_key)
|
43 |
model_size = st.multiselect("Select size:", options=model_size_options)
|
44 |
|
45 |
+
# Quantization level filter (default alphabetical sort)
|
46 |
model_quant = st.multiselect("Select quantization:", options=sorted(df["model_quant"].dropna().unique()))
|
47 |
|
48 |
+
# Apply filters to the dataset
|
49 |
filtered_df = df.copy()
|
50 |
if model_name:
|
51 |
filtered_df = filtered_df[filtered_df["model_name"].isin(model_name)]
|
|
|
54 |
if model_quant:
|
55 |
filtered_df = filtered_df[filtered_df["model_quant"].isin(model_quant)]
|
56 |
|
57 |
+
# Format specification for numerical columns
|
58 |
format_dict = {
|
59 |
"accuracy": "{:.2%}".format,
|
60 |
"avg_response_time": "{:.3f}".format,
|
61 |
"avg_token_count": "{:.1f}".format
|
62 |
}
|
63 |
|
|
|
|
|
64 |
|
65 |
+
# Function to render model_name as a clickable link with a tooltip (title)
|
66 |
+
def make_clickable_label(row):
|
67 |
+
model_field = row["model"]
|
68 |
+
name = row["model_name"]
|
69 |
+
if model_field.startswith("hf.co/"):
|
70 |
+
url = f"https://{model_field}"
|
71 |
+
else:
|
72 |
+
url = f"https://ollama.com/library/{model_field}"
|
73 |
+
return f'<a href="{url}" title="{model_field}" target="_blank">{name}</a>'
|
74 |
+
|
75 |
+
|
76 |
+
# Create new column with HTML links for model_name
|
77 |
+
display_df = filtered_df.copy()
|
78 |
+
display_df["model_name"] = display_df.apply(make_clickable_label, axis=1)
|
79 |
+
|
80 |
+
# Drop 'model' column from display (but keep it for link rendering)
|
81 |
+
display_df = display_df.drop(columns=["model"], errors="ignore")
|
82 |
+
|
83 |
+
# Apply sorting, formatting, and styling
|
84 |
+
styled = (
|
85 |
+
display_df.sort_values(by="accuracy", ascending=False)
|
86 |
+
.reset_index(drop=True)
|
87 |
+
.style
|
88 |
+
.format(format_dict)
|
89 |
+
.set_sticky(axis="index") # Keep first column visible on scroll
|
90 |
+
.hide(axis="index") # Hide row index
|
91 |
+
.set_properties(subset=["model_name"], **{"text-align": "left"}) # Align left
|
92 |
+
)
|
93 |
+
|
94 |
+
# Display table with HTML support for links
|
95 |
+
st.write(
|
96 |
+
styled.to_html(escape=False),
|
97 |
+
unsafe_allow_html=True
|
98 |
)
|