Spaces:
Running
Running
Commit
·
9ff08e9
1
Parent(s):
5b34d46
mod - Modify the Title and Navigation Bar
Browse files- app.py +119 -20
- app/__init__.py +1 -0
- app/backend/data_engine.py +37 -6
- app/backend/data_page.py +216 -0
- app/ui/__init__.py +0 -0
- app/ui/pages/__init__.py +0 -0
- app/ui/pages/data_page.py +0 -170
- app/ui/pages_sections.toml +0 -38
app.py
CHANGED
|
@@ -1,22 +1,10 @@
|
|
| 1 |
import os
|
| 2 |
-
|
| 3 |
import streamlit as st
|
| 4 |
|
| 5 |
-
from st_pages import add_page_title, get_nav_from_toml
|
| 6 |
-
|
| 7 |
from app.backend.constant import LEADERBOARD_MAP
|
| 8 |
from app.backend.data_engine import DataEngine
|
|
|
|
| 9 |
|
| 10 |
-
# init pages
|
| 11 |
-
with open("app/ui/pages/data_page.py", "r", encoding="utf-8") as f:
|
| 12 |
-
data_page = f.read()
|
| 13 |
-
for leaderboard, group_names in LEADERBOARD_MAP.items():
|
| 14 |
-
|
| 15 |
-
for group_name in group_names:
|
| 16 |
-
path = os.path.join("app/ui/pages", f"{group_name}.py")
|
| 17 |
-
with open(path, "w", encoding="utf-8") as f:
|
| 18 |
-
f.write(data_page.replace("$group_name$", group_name)
|
| 19 |
-
)
|
| 20 |
# init global data engine
|
| 21 |
data_engine = DataEngine()
|
| 22 |
data_engine.jsons_to_df()
|
|
@@ -24,13 +12,124 @@ st.session_state["data_engine"] = data_engine
|
|
| 24 |
|
| 25 |
st.set_page_config(layout="wide")
|
| 26 |
|
| 27 |
-
#
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
|
|
|
|
|
|
|
| 4 |
from app.backend.constant import LEADERBOARD_MAP
|
| 5 |
from app.backend.data_engine import DataEngine
|
| 6 |
+
from app.backend.data_page import render_page
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
# init global data engine
|
| 9 |
data_engine = DataEngine()
|
| 10 |
data_engine.jsons_to_df()
|
|
|
|
| 12 |
|
| 13 |
st.set_page_config(layout="wide")
|
| 14 |
|
| 15 |
+
# Add custom CSS
|
| 16 |
+
st.markdown("""
|
| 17 |
+
<style>
|
| 18 |
+
/* Sidebar background color */
|
| 19 |
+
section[data-testid="stSidebar"] {
|
| 20 |
+
background-color: #f0f2f6;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
/* Navigation button style */
|
| 24 |
+
section[data-testid="stSidebar"] .stButton button {
|
| 25 |
+
width: 100%;
|
| 26 |
+
padding: 0.75rem 1rem;
|
| 27 |
+
background-color: transparent;
|
| 28 |
+
border: none;
|
| 29 |
+
text-align: left;
|
| 30 |
+
color: rgb(49, 51, 63);
|
| 31 |
+
font-size: 0.9rem;
|
| 32 |
+
font-weight: 400;
|
| 33 |
+
line-height: 1.6;
|
| 34 |
+
margin: 0.1rem 0;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
.st-emotion-cache-64tehz {
|
| 38 |
+
|
| 39 |
+
gap: 0rem;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
.st-emotion-cache-qsto9u {
|
| 43 |
+
|
| 44 |
+
justify-content: left;
|
| 45 |
+
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
[data-testid="stVerticalBlock"] .stVerticalBlock {
|
| 49 |
+
text-indent: 2rem;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
/* Navigation button hover effect */
|
| 53 |
+
section[data-testid="stSidebar"] .stButton button:hover {
|
| 54 |
+
background-color: rgba(151, 166, 195, 0.15);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
/* Selected state */
|
| 58 |
+
section[data-testid="stSidebar"] .stButton button.selected,
|
| 59 |
+
section[data-testid="stSidebar"] .stButton button:active,
|
| 60 |
+
section[data-testid="stSidebar"] .stButton button:focus {
|
| 61 |
+
background-color: #fff;
|
| 62 |
+
border: none;
|
| 63 |
+
box-shadow: none;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
/* Page title style */
|
| 67 |
+
h1 {
|
| 68 |
+
font-size: 3rem !important;
|
| 69 |
+
font-weight: 600 !important;
|
| 70 |
+
color: rgb(49, 51, 63) !important;
|
| 71 |
+
margin-bottom: 1rem !important;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
/* Divider style */
|
| 75 |
+
hr {
|
| 76 |
+
margin: 0.5rem 0;
|
| 77 |
+
border-color: rgba(49, 51, 63, 0.1);
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
/* Subpage indentation */
|
| 81 |
+
.child-page {
|
| 82 |
+
padding-left: 1rem;
|
| 83 |
+
}
|
| 84 |
+
</style>
|
| 85 |
+
""", unsafe_allow_html=True)
|
| 86 |
+
|
| 87 |
+
# Implement navigation using sidebar
|
| 88 |
+
with st.sidebar:
|
| 89 |
+
# Initialize session state
|
| 90 |
+
if "selected_page" not in st.session_state:
|
| 91 |
+
st.session_state.selected_page = "text"
|
| 92 |
+
|
| 93 |
+
# Text Leaderboard as clickable button
|
| 94 |
+
selected_class = "selected" if st.session_state.selected_page == "text" else ""
|
| 95 |
+
if st.button("📚 Text Leaderboard", key="text",
|
| 96 |
+
use_container_width=True,
|
| 97 |
+
):
|
| 98 |
+
st.session_state.selected_page = "text"
|
| 99 |
+
st.rerun()
|
| 100 |
+
|
| 101 |
+
# Subpage list
|
| 102 |
+
pages = [
|
| 103 |
+
("law", "⚖️ Law"),
|
| 104 |
+
("multilingual", "🌎 Multilingual"),
|
| 105 |
+
("german", "🇩🇪 German"),
|
| 106 |
+
("code", "💻 Code"),
|
| 107 |
+
("tech", "🛠️ Tech")
|
| 108 |
+
]
|
| 109 |
|
| 110 |
+
# Use container for indentation
|
| 111 |
+
with st.container():
|
| 112 |
+
st.markdown('<div class="child-page">', unsafe_allow_html=True)
|
| 113 |
+
for page_id, page_title in pages:
|
| 114 |
+
selected_class = "selected" if st.session_state.selected_page == page_id else ""
|
| 115 |
+
if st.button(page_title, key=page_id, use_container_width=True):
|
| 116 |
+
st.session_state.selected_page = page_id
|
| 117 |
+
# st.rerun()
|
| 118 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 119 |
|
| 120 |
+
# Add page title
|
| 121 |
+
if st.session_state.selected_page == "text":
|
| 122 |
+
st.title("📚 Text Leaderboard")
|
| 123 |
+
elif st.session_state.selected_page == "law":
|
| 124 |
+
st.title("⚖️ Law")
|
| 125 |
+
elif st.session_state.selected_page == "multilingual":
|
| 126 |
+
st.title("🌎 Multilingual")
|
| 127 |
+
elif st.session_state.selected_page == "german":
|
| 128 |
+
st.title("🇩🇪 German")
|
| 129 |
+
elif st.session_state.selected_page == "code":
|
| 130 |
+
st.title("💻 Code")
|
| 131 |
+
elif st.session_state.selected_page == "tech":
|
| 132 |
+
st.title("🛠️ Tech")
|
| 133 |
|
| 134 |
+
# Render current selected page
|
| 135 |
+
render_page(st.session_state.selected_page)
|
app/__init__.py
CHANGED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
app/backend/data_engine.py
CHANGED
|
@@ -12,12 +12,12 @@ from utils.http_utils import get
|
|
| 12 |
COLUMNS = ['model_name',
|
| 13 |
'embd_dtype', 'embd_dim', 'num_params', 'max_tokens', 'similarity',
|
| 14 |
'query_instruct', 'corpus_instruct',
|
| 15 |
-
|
| 16 |
]
|
| 17 |
COLUMNS_TYPES = ["markdown",
|
| 18 |
'str', 'str', 'number', 'number', 'str',
|
| 19 |
'str', 'str',
|
| 20 |
-
|
| 21 |
]
|
| 22 |
|
| 23 |
GIT_URL = "https://raw.githubusercontent.com/embedding-benchmark/ebr/refs/heads/main/results/"
|
|
@@ -83,6 +83,8 @@ class DataEngine:
|
|
| 83 |
df_results_list.append(df_result_row)
|
| 84 |
df_result = pd.concat(df_results_list)
|
| 85 |
|
|
|
|
|
|
|
| 86 |
df_datasets_list = []
|
| 87 |
for item in self.datasets:
|
| 88 |
dataset_names = item["datasets"]
|
|
@@ -101,12 +103,36 @@ class DataEngine:
|
|
| 101 |
df_model = pd.DataFrame(models_list)
|
| 102 |
|
| 103 |
df = pd.merge(df_result, df_dataset, on=["dataset_name"], how="inner")
|
| 104 |
-
df =
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
if df.empty:
|
| 108 |
-
return pd.DataFrame(columns=COLUMNS + ["
|
| 109 |
-
return df
|
| 110 |
|
| 111 |
def filter_df(self, group_name: str):
|
| 112 |
"""
|
|
@@ -115,3 +141,8 @@ class DataEngine:
|
|
| 115 |
df = self.jsons_to_df()
|
| 116 |
|
| 117 |
return df[df["group_name"] == group_name][COLUMNS][:]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
COLUMNS = ['model_name',
|
| 13 |
'embd_dtype', 'embd_dim', 'num_params', 'max_tokens', 'similarity',
|
| 14 |
'query_instruct', 'corpus_instruct',
|
| 15 |
+
|
| 16 |
]
|
| 17 |
COLUMNS_TYPES = ["markdown",
|
| 18 |
'str', 'str', 'number', 'number', 'str',
|
| 19 |
'str', 'str',
|
| 20 |
+
|
| 21 |
]
|
| 22 |
|
| 23 |
GIT_URL = "https://raw.githubusercontent.com/embedding-benchmark/ebr/refs/heads/main/results/"
|
|
|
|
| 83 |
df_results_list.append(df_result_row)
|
| 84 |
df_result = pd.concat(df_results_list)
|
| 85 |
|
| 86 |
+
df_result = df_result[["model_name", "dataset_name", "ndcg_at_10"]]
|
| 87 |
+
|
| 88 |
df_datasets_list = []
|
| 89 |
for item in self.datasets:
|
| 90 |
dataset_names = item["datasets"]
|
|
|
|
| 103 |
df_model = pd.DataFrame(models_list)
|
| 104 |
|
| 105 |
df = pd.merge(df_result, df_dataset, on=["dataset_name"], how="inner")
|
| 106 |
+
# df = pd.merge(df, df_model, on=["model_name"], how="inner")
|
| 107 |
+
|
| 108 |
+
dataset_num_map = {}
|
| 109 |
+
grouped_dataset_count = df.groupby(["group_name"]).agg({
|
| 110 |
+
"dataset_name": "nunique"
|
| 111 |
+
}).reset_index()
|
| 112 |
+
|
| 113 |
+
for _, row in grouped_dataset_count.iterrows():
|
| 114 |
+
dataset_num_map[row["group_name"]] = row["dataset_name"]
|
| 115 |
+
|
| 116 |
+
grouped_model = df.groupby(["model_name", "group_name"]).agg({
|
| 117 |
+
"ndcg_at_10": "mean",
|
| 118 |
+
}).reset_index()
|
| 119 |
+
|
| 120 |
+
pivot = grouped_model.pivot(index="model_name", columns="group_name", values=["ndcg_at_10"])
|
| 121 |
+
|
| 122 |
+
# Rename columns
|
| 123 |
+
pivot.columns = list(
|
| 124 |
+
map(lambda x: f"{x[1].capitalize()} Average ({dataset_num_map[x[1]]} datasets)" if x[
|
| 125 |
+
1] != 'text' else f"Average ({dataset_num_map[x[1]]} datasets)",
|
| 126 |
+
pivot.columns))
|
| 127 |
+
|
| 128 |
+
pivot_dataset = df_result.pivot(index="model_name", columns="dataset_name", values="ndcg_at_10")
|
| 129 |
+
|
| 130 |
+
df = pd.merge(df_model, pivot, on="model_name")
|
| 131 |
+
df = pd.merge(df, pivot_dataset, on="model_name")
|
| 132 |
|
| 133 |
if df.empty:
|
| 134 |
+
return pd.DataFrame(columns=COLUMNS + ["reference"])
|
| 135 |
+
return df
|
| 136 |
|
| 137 |
def filter_df(self, group_name: str):
|
| 138 |
"""
|
|
|
|
| 141 |
df = self.jsons_to_df()
|
| 142 |
|
| 143 |
return df[df["group_name"] == group_name][COLUMNS][:]
|
| 144 |
+
|
| 145 |
+
def summarize_dataframe(self):
|
| 146 |
+
"""
|
| 147 |
+
Summarize data statistics
|
| 148 |
+
"""
|
app/backend/data_page.py
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# @Date : 2025/2/5 16:26
|
| 3 |
+
# @Author : q275343119
|
| 4 |
+
# @File : data_page.py
|
| 5 |
+
# @Description:
|
| 6 |
+
from st_aggrid import AgGrid, JsCode, ColumnsAutoSizeMode
|
| 7 |
+
|
| 8 |
+
import streamlit as st
|
| 9 |
+
|
| 10 |
+
COLUMNS = ['model_name',
|
| 11 |
+
'embd_dtype', 'embd_dim', 'num_params', 'max_tokens', 'similarity',
|
| 12 |
+
'query_instruct', 'corpus_instruct', 'reference'
|
| 13 |
+
|
| 14 |
+
]
|
| 15 |
+
HEADER_STYLE = {'fontSize': '18px'}
|
| 16 |
+
CELL_STYLE = {'fontSize': '18px'}
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def render_page(group_name):
|
| 20 |
+
# Add theme color and grid styles
|
| 21 |
+
st.markdown("""
|
| 22 |
+
<style>
|
| 23 |
+
:root {
|
| 24 |
+
--theme-color: rgb(129, 150, 64);
|
| 25 |
+
--theme-color-light: rgba(129, 150, 64, 0.2);
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
/* AG Grid specific overrides */
|
| 29 |
+
.ag-theme-alpine {
|
| 30 |
+
--ag-selected-row-background-color: var(--theme-color-light) !important;
|
| 31 |
+
--ag-row-hover-color: var(--theme-color-light) !important;
|
| 32 |
+
--ag-selected-tab-color: var(--theme-color) !important;
|
| 33 |
+
--ag-range-selection-border-color: var(--theme-color) !important;
|
| 34 |
+
--ag-range-selection-background-color: var(--theme-color-light) !important;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
.ag-row-hover {
|
| 38 |
+
background-color: var(--theme-color-light) !important;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
.ag-row-selected {
|
| 42 |
+
background-color: var(--theme-color-light) !important;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
.ag-row-focus {
|
| 46 |
+
background-color: var(--theme-color-light) !important;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
.ag-cell-focus {
|
| 50 |
+
border-color: var(--theme-color) !important;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/* Keep existing styles */
|
| 54 |
+
.center-text {
|
| 55 |
+
text-align: center;
|
| 56 |
+
color: var(--theme-color);
|
| 57 |
+
}
|
| 58 |
+
.center-image {
|
| 59 |
+
display: block;
|
| 60 |
+
margin-left: auto;
|
| 61 |
+
margin-right: auto;
|
| 62 |
+
}
|
| 63 |
+
h2 {
|
| 64 |
+
color: var(--theme-color) !important;
|
| 65 |
+
}
|
| 66 |
+
.ag-header-cell {
|
| 67 |
+
background-color: var(--theme-color) !important;
|
| 68 |
+
color: white !important;
|
| 69 |
+
}
|
| 70 |
+
a {
|
| 71 |
+
color: var(--theme-color) !important;
|
| 72 |
+
}
|
| 73 |
+
a:hover {
|
| 74 |
+
color: rgba(129, 150, 64, 0.8) !important;
|
| 75 |
+
}
|
| 76 |
+
</style>
|
| 77 |
+
""", unsafe_allow_html=True)
|
| 78 |
+
|
| 79 |
+
# logo
|
| 80 |
+
# st.markdown('<img src="https://www.voyageai.com/logo.svg" class="center-image" width="200">', unsafe_allow_html=True)
|
| 81 |
+
|
| 82 |
+
# title
|
| 83 |
+
st.markdown('<h2 class="center-text">Embedding Benchmark For Retrieval</h2>', unsafe_allow_html=True)
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
data_engine = st.session_state["data_engine"]
|
| 87 |
+
|
| 88 |
+
df = data_engine.jsons_to_df()[:]
|
| 89 |
+
# get columns
|
| 90 |
+
column_list = []
|
| 91 |
+
avg_column = None
|
| 92 |
+
if group_name == "text":
|
| 93 |
+
avg_columns = []
|
| 94 |
+
for column in df.columns:
|
| 95 |
+
|
| 96 |
+
if column.startswith("Average"):
|
| 97 |
+
avg_columns.insert(0, column)
|
| 98 |
+
continue
|
| 99 |
+
if "Average" in column:
|
| 100 |
+
avg_columns.append(column)
|
| 101 |
+
continue
|
| 102 |
+
avg_column = avg_columns[0]
|
| 103 |
+
column_list.extend(avg_columns)
|
| 104 |
+
else:
|
| 105 |
+
for column in df.columns:
|
| 106 |
+
|
| 107 |
+
if column.startswith(group_name.capitalize() + " "):
|
| 108 |
+
avg_column = column
|
| 109 |
+
new_column = avg_column.replace(group_name.capitalize(), "").strip()
|
| 110 |
+
df.rename(columns={avg_column: new_column}, inplace=True)
|
| 111 |
+
column_list.append(new_column)
|
| 112 |
+
avg_column = new_column
|
| 113 |
+
|
| 114 |
+
dataset_list = []
|
| 115 |
+
if group_name != "text":
|
| 116 |
+
for dataset_dict in data_engine.datasets:
|
| 117 |
+
if dataset_dict["name"] == group_name:
|
| 118 |
+
dataset_list = dataset_dict["datasets"]
|
| 119 |
+
column_list.extend(dataset_list)
|
| 120 |
+
|
| 121 |
+
df = df[COLUMNS + column_list].sort_values(by=avg_column, ascending=False)
|
| 122 |
+
|
| 123 |
+
# setting column config
|
| 124 |
+
grid_options = {
|
| 125 |
+
'columnDefs': [
|
| 126 |
+
{
|
| 127 |
+
'headerName': 'Model Name',
|
| 128 |
+
'field': 'model_name',
|
| 129 |
+
'pinned': 'left',
|
| 130 |
+
'sortable': False,
|
| 131 |
+
'headerStyle': HEADER_STYLE,
|
| 132 |
+
'cellStyle': CELL_STYLE,
|
| 133 |
+
'cellRenderer': JsCode("""class CustomHTML {
|
| 134 |
+
init(params) {
|
| 135 |
+
const link = params.data.reference;
|
| 136 |
+
this.eGui = document.createElement('div');
|
| 137 |
+
this.eGui.innerHTML = link ?
|
| 138 |
+
`<a href="${link}" target="_blank">${params.value}</a>` :
|
| 139 |
+
params.value;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
getGui() {
|
| 143 |
+
return this.eGui;
|
| 144 |
+
}
|
| 145 |
+
}"""),
|
| 146 |
+
},
|
| 147 |
+
{'headerName': avg_column,
|
| 148 |
+
'field': avg_column,
|
| 149 |
+
'headerStyle': HEADER_STYLE,
|
| 150 |
+
'cellStyle': CELL_STYLE,
|
| 151 |
+
'suppressSizeToFit': True},
|
| 152 |
+
{
|
| 153 |
+
'headerName': 'Data Type',
|
| 154 |
+
'field': 'embd_dtype',
|
| 155 |
+
'headerStyle': HEADER_STYLE,
|
| 156 |
+
'cellStyle': CELL_STYLE,
|
| 157 |
+
},
|
| 158 |
+
{
|
| 159 |
+
'headerName': 'Embd Dim',
|
| 160 |
+
'field': 'embd_dim',
|
| 161 |
+
'headerStyle': HEADER_STYLE,
|
| 162 |
+
'cellStyle': CELL_STYLE,
|
| 163 |
+
},
|
| 164 |
+
{
|
| 165 |
+
'headerName': 'Model Size (# of Parameters)',
|
| 166 |
+
'field': 'num_params',
|
| 167 |
+
'cellDataType': 'number',
|
| 168 |
+
'headerStyle': HEADER_STYLE,
|
| 169 |
+
'cellStyle': CELL_STYLE,
|
| 170 |
+
},
|
| 171 |
+
{
|
| 172 |
+
'headerName': 'Context Length',
|
| 173 |
+
'field': 'max_tokens',
|
| 174 |
+
'headerStyle': HEADER_STYLE,
|
| 175 |
+
'cellStyle': CELL_STYLE,
|
| 176 |
+
},
|
| 177 |
+
{
|
| 178 |
+
'headerName': 'Query Instruction',
|
| 179 |
+
'field': 'query_instruct',
|
| 180 |
+
'headerStyle': HEADER_STYLE,
|
| 181 |
+
'cellStyle': CELL_STYLE,
|
| 182 |
+
'suppressSizeToFit': True,
|
| 183 |
+
|
| 184 |
+
},
|
| 185 |
+
{
|
| 186 |
+
'headerName': 'Corpus Instruction',
|
| 187 |
+
'field': 'corpus_instruct',
|
| 188 |
+
'headerStyle': HEADER_STYLE,
|
| 189 |
+
'cellStyle': CELL_STYLE,
|
| 190 |
+
'suppressSizeToFit': True,
|
| 191 |
+
|
| 192 |
+
},
|
| 193 |
+
*[{'headerName': column,
|
| 194 |
+
'field': column,
|
| 195 |
+
'headerStyle': HEADER_STYLE,
|
| 196 |
+
'cellStyle': CELL_STYLE,
|
| 197 |
+
'suppressSizeToFit': True} for column in column_list if column != avg_column]
|
| 198 |
+
],
|
| 199 |
+
'defaultColDef': {
|
| 200 |
+
'filter': True,
|
| 201 |
+
'sortable': True,
|
| 202 |
+
'resizable': True
|
| 203 |
+
},
|
| 204 |
+
'autoSizeStrategy': {
|
| 205 |
+
'type': 'fitCellContents'
|
| 206 |
+
}
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
AgGrid(
|
| 210 |
+
df,
|
| 211 |
+
enable_enterprise_modules=False,
|
| 212 |
+
gridOptions=grid_options,
|
| 213 |
+
allow_unsafe_jscode=True,
|
| 214 |
+
columns_auto_size_mode=ColumnsAutoSizeMode.FIT_CONTENTS,
|
| 215 |
+
theme="streamlit",
|
| 216 |
+
)
|
app/ui/__init__.py
DELETED
|
File without changes
|
app/ui/pages/__init__.py
DELETED
|
File without changes
|
app/ui/pages/data_page.py
DELETED
|
@@ -1,170 +0,0 @@
|
|
| 1 |
-
from st_aggrid import AgGrid, JsCode, ColumnsAutoSizeMode
|
| 2 |
-
|
| 3 |
-
import streamlit as st
|
| 4 |
-
|
| 5 |
-
HEADER_STYLE = {'fontSize': '18px'}
|
| 6 |
-
CELL_STYLE = {'fontSize': '18px'}
|
| 7 |
-
|
| 8 |
-
# Add theme color and grid styles
|
| 9 |
-
st.markdown("""
|
| 10 |
-
<style>
|
| 11 |
-
:root {
|
| 12 |
-
--theme-color: rgb(129, 150, 64);
|
| 13 |
-
--theme-color-light: rgba(129, 150, 64, 0.2);
|
| 14 |
-
}
|
| 15 |
-
|
| 16 |
-
/* AG Grid specific overrides */
|
| 17 |
-
.ag-theme-alpine {
|
| 18 |
-
--ag-selected-row-background-color: var(--theme-color-light) !important;
|
| 19 |
-
--ag-row-hover-color: var(--theme-color-light) !important;
|
| 20 |
-
--ag-selected-tab-color: var(--theme-color) !important;
|
| 21 |
-
--ag-range-selection-border-color: var(--theme-color) !important;
|
| 22 |
-
--ag-range-selection-background-color: var(--theme-color-light) !important;
|
| 23 |
-
}
|
| 24 |
-
|
| 25 |
-
.ag-row-hover {
|
| 26 |
-
background-color: var(--theme-color-light) !important;
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
-
.ag-row-selected {
|
| 30 |
-
background-color: var(--theme-color-light) !important;
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
.ag-row-focus {
|
| 34 |
-
background-color: var(--theme-color-light) !important;
|
| 35 |
-
}
|
| 36 |
-
|
| 37 |
-
.ag-cell-focus {
|
| 38 |
-
border-color: var(--theme-color) !important;
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
-
/* Keep existing styles */
|
| 42 |
-
.center-text {
|
| 43 |
-
text-align: center;
|
| 44 |
-
color: var(--theme-color);
|
| 45 |
-
}
|
| 46 |
-
.center-image {
|
| 47 |
-
display: block;
|
| 48 |
-
margin-left: auto;
|
| 49 |
-
margin-right: auto;
|
| 50 |
-
}
|
| 51 |
-
h2 {
|
| 52 |
-
color: var(--theme-color) !important;
|
| 53 |
-
}
|
| 54 |
-
.ag-header-cell {
|
| 55 |
-
background-color: var(--theme-color) !important;
|
| 56 |
-
color: white !important;
|
| 57 |
-
}
|
| 58 |
-
a {
|
| 59 |
-
color: var(--theme-color) !important;
|
| 60 |
-
}
|
| 61 |
-
a:hover {
|
| 62 |
-
color: rgba(129, 150, 64, 0.8) !important;
|
| 63 |
-
}
|
| 64 |
-
</style>
|
| 65 |
-
""", unsafe_allow_html=True)
|
| 66 |
-
|
| 67 |
-
# logo
|
| 68 |
-
# st.markdown('<img src="https://www.voyageai.com/logo.svg" class="center-image" width="200">', unsafe_allow_html=True)
|
| 69 |
-
|
| 70 |
-
# title
|
| 71 |
-
st.markdown('<h2 class="center-text">Embedding Benchmark For Retrieval</h2>', unsafe_allow_html=True)
|
| 72 |
-
|
| 73 |
-
group_name = "$group_name$"
|
| 74 |
-
|
| 75 |
-
data_engine = st.session_state["data_engine"]
|
| 76 |
-
|
| 77 |
-
df = data_engine.jsons_to_df()[:]
|
| 78 |
-
|
| 79 |
-
df = df[df["group_name"] == group_name].sort_values(by="ndcg_at_10", ascending=False)
|
| 80 |
-
|
| 81 |
-
# setting column config
|
| 82 |
-
grid_options = {
|
| 83 |
-
'columnDefs': [
|
| 84 |
-
{
|
| 85 |
-
'headerName': 'Model Name',
|
| 86 |
-
'field': 'model_name',
|
| 87 |
-
'pinned': 'left',
|
| 88 |
-
'sortable': False,
|
| 89 |
-
'headerStyle': HEADER_STYLE,
|
| 90 |
-
'cellStyle': CELL_STYLE,
|
| 91 |
-
'cellRenderer': JsCode("""class CustomHTML {
|
| 92 |
-
init(params) {
|
| 93 |
-
const link = params.data.reference;
|
| 94 |
-
this.eGui = document.createElement('div');
|
| 95 |
-
this.eGui.innerHTML = link ?
|
| 96 |
-
`<a href="${link}" target="_blank">${params.value}</a>` :
|
| 97 |
-
params.value;
|
| 98 |
-
}
|
| 99 |
-
|
| 100 |
-
getGui() {
|
| 101 |
-
return this.eGui;
|
| 102 |
-
}
|
| 103 |
-
}"""),
|
| 104 |
-
},
|
| 105 |
-
{
|
| 106 |
-
'headerName': 'NDCG@10',
|
| 107 |
-
'field': 'ndcg_at_10',
|
| 108 |
-
'headerStyle': HEADER_STYLE,
|
| 109 |
-
'cellStyle': CELL_STYLE,
|
| 110 |
-
},
|
| 111 |
-
{
|
| 112 |
-
'headerName': 'Data Type',
|
| 113 |
-
'field': 'embd_dtype',
|
| 114 |
-
'headerStyle': HEADER_STYLE,
|
| 115 |
-
'cellStyle': CELL_STYLE,
|
| 116 |
-
},
|
| 117 |
-
{
|
| 118 |
-
'headerName': 'Embd Dim',
|
| 119 |
-
'field': 'embd_dim',
|
| 120 |
-
'headerStyle': HEADER_STYLE,
|
| 121 |
-
'cellStyle': CELL_STYLE,
|
| 122 |
-
},
|
| 123 |
-
{
|
| 124 |
-
'headerName': 'Model Size (# of Parameters)',
|
| 125 |
-
'field': 'num_params',
|
| 126 |
-
'cellDataType': 'number',
|
| 127 |
-
'headerStyle': HEADER_STYLE,
|
| 128 |
-
'cellStyle': CELL_STYLE,
|
| 129 |
-
},
|
| 130 |
-
{
|
| 131 |
-
'headerName': 'Context Length',
|
| 132 |
-
'field': 'max_tokens',
|
| 133 |
-
'headerStyle': HEADER_STYLE,
|
| 134 |
-
'cellStyle': CELL_STYLE,
|
| 135 |
-
},
|
| 136 |
-
{
|
| 137 |
-
'headerName': 'Query Instruction',
|
| 138 |
-
'field': 'query_instruct',
|
| 139 |
-
'headerStyle': HEADER_STYLE,
|
| 140 |
-
'cellStyle': CELL_STYLE,
|
| 141 |
-
'suppressSizeToFit': True,
|
| 142 |
-
|
| 143 |
-
},
|
| 144 |
-
{
|
| 145 |
-
'headerName': 'Corpus Instruction',
|
| 146 |
-
'field': 'corpus_instruct',
|
| 147 |
-
'headerStyle': HEADER_STYLE,
|
| 148 |
-
'cellStyle': CELL_STYLE,
|
| 149 |
-
'suppressSizeToFit': True,
|
| 150 |
-
|
| 151 |
-
},
|
| 152 |
-
],
|
| 153 |
-
'defaultColDef': {
|
| 154 |
-
'filter': True,
|
| 155 |
-
'sortable': True,
|
| 156 |
-
'resizable': True
|
| 157 |
-
},
|
| 158 |
-
'autoSizeStrategy': {
|
| 159 |
-
'type': 'fitCellContents'
|
| 160 |
-
}
|
| 161 |
-
}
|
| 162 |
-
|
| 163 |
-
ag = AgGrid(
|
| 164 |
-
df,
|
| 165 |
-
enable_enterprise_modules=False,
|
| 166 |
-
gridOptions=grid_options,
|
| 167 |
-
allow_unsafe_jscode=True,
|
| 168 |
-
columns_auto_size_mode=ColumnsAutoSizeMode.FIT_CONTENTS,
|
| 169 |
-
theme="streamlit",
|
| 170 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/ui/pages_sections.toml
DELETED
|
@@ -1,38 +0,0 @@
|
|
| 1 |
-
[[pages]]
|
| 2 |
-
name = "Text Leaderboard"
|
| 3 |
-
icon = "📚"
|
| 4 |
-
is_section = true
|
| 5 |
-
|
| 6 |
-
[[pages]]
|
| 7 |
-
path = "app/ui/pages/text.py"
|
| 8 |
-
name = "Overall"
|
| 9 |
-
icon = "🏆"
|
| 10 |
-
|
| 11 |
-
[[pages]]
|
| 12 |
-
path = "app/ui/pages/law.py"
|
| 13 |
-
name = "Law"
|
| 14 |
-
icon = "⚖️"
|
| 15 |
-
|
| 16 |
-
[[pages]]
|
| 17 |
-
path = "app/ui/pages/multilingual.py"
|
| 18 |
-
name = "Multilingual"
|
| 19 |
-
icon = "🌎"
|
| 20 |
-
|
| 21 |
-
[[pages]]
|
| 22 |
-
path = "app/ui/pages/german.py"
|
| 23 |
-
name = "German"
|
| 24 |
-
icon = "🇩🇪"
|
| 25 |
-
|
| 26 |
-
[[pages]]
|
| 27 |
-
path = "app/ui/pages/code.py"
|
| 28 |
-
name = "Code"
|
| 29 |
-
icon = "💻"
|
| 30 |
-
|
| 31 |
-
[[pages]]
|
| 32 |
-
path = "app/ui/pages/tech.py"
|
| 33 |
-
name = "Tech"
|
| 34 |
-
icon = "🛠️"
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|