File size: 4,928 Bytes
bf6e4d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
from st_aggrid import AgGrid, JsCode, ColumnsAutoSizeMode

import streamlit as st

HEADER_STYLE = {'fontSize': '18px'}
CELL_STYLE = {'fontSize': '18px'}

# Add theme color and grid styles
st.markdown("""
    <style>
        :root {
            --theme-color: rgb(129, 150, 64);
            --theme-color-light: rgba(129, 150, 64, 0.2);
        }
        
        /* AG Grid specific overrides */
        .ag-theme-alpine {
            --ag-selected-row-background-color: var(--theme-color-light) !important;
            --ag-row-hover-color: var(--theme-color-light) !important;
            --ag-selected-tab-color: var(--theme-color) !important;
            --ag-range-selection-border-color: var(--theme-color) !important;
            --ag-range-selection-background-color: var(--theme-color-light) !important;
        }
        
        .ag-row-hover {
            background-color: var(--theme-color-light) !important;
        }
        
        .ag-row-selected {
            background-color: var(--theme-color-light) !important;
        }
        
        .ag-row-focus {
            background-color: var(--theme-color-light) !important;
        }
        
        .ag-cell-focus {
            border-color: var(--theme-color) !important;
        }
        
        /* Keep existing styles */
        .center-text {
            text-align: center;
            color: var(--theme-color);
        }
        .center-image {
            display: block;
            margin-left: auto;
            margin-right: auto;
        }
        h2 {
            color: var(--theme-color) !important;
        }
        .ag-header-cell {
            background-color: var(--theme-color) !important;
            color: white !important;
        }
        a {
            color: var(--theme-color) !important;
        }
        a:hover {
            color: rgba(129, 150, 64, 0.8) !important;
        }
    </style>
""", unsafe_allow_html=True)

#  logo
# st.markdown('<img src="https://www.voyageai.com/logo.svg" class="center-image" width="200">', unsafe_allow_html=True)

# title
st.markdown('<h2 class="center-text">Embedding Benchmark For Retrieval</h2>', unsafe_allow_html=True)

group_name = "$group_name$"

data_engine = st.session_state["data_engine"]

df = data_engine.jsons_to_df()[:]

df = df[df["group_name"] == group_name].sort_values(by="ndcg_at_10", ascending=False)

# setting column config
grid_options = {
    'columnDefs': [
        {
            'headerName': 'Model Name',
            'field': 'model_name',
            'pinned': 'left',
            'sortable': False,
            'headerStyle': HEADER_STYLE,
            'cellStyle': CELL_STYLE,
            'cellRenderer': JsCode("""class CustomHTML {
                init(params) {
                    const link = params.data.reference;
                    this.eGui = document.createElement('div');
                    this.eGui.innerHTML = link ? 
                        `<a href="${link}" target="_blank">${params.value}</a>` : 
                        params.value;
                }

                getGui() {
                    return this.eGui;
                }
            }"""),
        },
        {
            'headerName': 'NDCG@10',
            'field': 'ndcg_at_10',
            'headerStyle': HEADER_STYLE,
            'cellStyle': CELL_STYLE,
        },
        {
            'headerName': 'Data Type',
            'field': 'embd_dtype',
            'headerStyle': HEADER_STYLE,
            'cellStyle': CELL_STYLE,
        },
        {
            'headerName': 'Embd Dim',
            'field': 'embd_dim',
            'headerStyle': HEADER_STYLE,
            'cellStyle': CELL_STYLE,
        },
        {
            'headerName': 'Model Size (# of Parameters)',
            'field': 'num_params',
            'cellDataType': 'number',
            'headerStyle': HEADER_STYLE,
            'cellStyle': CELL_STYLE,
        },
        {
            'headerName': 'Context Length',
            'field': 'max_tokens',
            'headerStyle': HEADER_STYLE,
            'cellStyle': CELL_STYLE,
        },
        {
            'headerName': 'Query Instruction',
            'field': 'query_instruct',
            'headerStyle': HEADER_STYLE,
            'cellStyle': CELL_STYLE,
            'suppressSizeToFit': True,

        },
        {
            'headerName': 'Corpus Instruction',
            'field': 'corpus_instruct',
            'headerStyle': HEADER_STYLE,
            'cellStyle': CELL_STYLE,
            'suppressSizeToFit': True,

        },
    ],
    'defaultColDef': {
        'filter': True,
        'sortable': True,
        'resizable': True
    },
    'autoSizeStrategy': {
        'type': 'fitCellContents'
    }
}

ag = AgGrid(
    df,
    enable_enterprise_modules=False,
    gridOptions=grid_options,
    allow_unsafe_jscode=True,
    columns_auto_size_mode=ColumnsAutoSizeMode.FIT_CONTENTS,
    theme="streamlit",
)