Spaces:
Sleeping
Sleeping
sheza munir
commited on
Upload 2 files
Browse files- app.py +157 -0
- requirements.py +3 -0
app.py
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
# Set up page config for a better look
|
5 |
+
st.set_page_config(
|
6 |
+
page_title="FactBench Leaderboard",
|
7 |
+
layout="centered",
|
8 |
+
)
|
9 |
+
|
10 |
+
st.markdown(
|
11 |
+
"""
|
12 |
+
<style>
|
13 |
+
@import url('https://fonts.googleapis.com/css2?family=Courier+Prime:wght@400&display=swap');
|
14 |
+
|
15 |
+
html, body, [class*="css"] {
|
16 |
+
font-family: 'Courier Prime', monospace; /* Command-line font */
|
17 |
+
}
|
18 |
+
|
19 |
+
.title {
|
20 |
+
font-size: 42px;
|
21 |
+
font-weight: bold;
|
22 |
+
text-align: center;
|
23 |
+
color: #333;
|
24 |
+
margin-bottom: 5px;
|
25 |
+
}
|
26 |
+
|
27 |
+
.description {
|
28 |
+
font-size: 22px;
|
29 |
+
text-align: center;
|
30 |
+
margin-bottom: 30px;
|
31 |
+
color: #555;
|
32 |
+
}
|
33 |
+
|
34 |
+
.table-container {
|
35 |
+
margin-top: 20px;
|
36 |
+
}
|
37 |
+
|
38 |
+
table {
|
39 |
+
width: 100%; /* Set table to fill width */
|
40 |
+
border-collapse: collapse; /* Merge cells neatly */
|
41 |
+
border-radius: 10px; /* Rounded edges */
|
42 |
+
overflow: hidden; /* Ensure rounded edges are visible */
|
43 |
+
}
|
44 |
+
|
45 |
+
th, td {
|
46 |
+
padding: 8px; /* Reduced padding for smaller font */
|
47 |
+
text-align: center; /* Center-align text */
|
48 |
+
border: 1px solid #ddd; /* Add borders */
|
49 |
+
font-size: 14px; /* Smaller font size */
|
50 |
+
}
|
51 |
+
|
52 |
+
th {
|
53 |
+
background-color: #f2f2f2; /* Light gray background for header */
|
54 |
+
font-weight: bold; /* Bold font for headers */
|
55 |
+
}
|
56 |
+
|
57 |
+
/* Specific column widths */
|
58 |
+
td:nth-child(2), th:nth-child(2) { /* Wider Model column */
|
59 |
+
width: 30%; /* Increased width for model column */
|
60 |
+
}
|
61 |
+
|
62 |
+
td:nth-child(3), th:nth-child(3),
|
63 |
+
td:nth-child(4), th:nth-child(4),
|
64 |
+
td:nth-child(5), th:nth-child(5),
|
65 |
+
td:nth-child(6), th:nth-child(6) {
|
66 |
+
width: 17.5%; /* Equal width for the rest */
|
67 |
+
}
|
68 |
+
|
69 |
+
/* Hover effect for table rows */
|
70 |
+
tr:hover {
|
71 |
+
background-color: #eaeaea; /* Light grey on hover */
|
72 |
+
}
|
73 |
+
|
74 |
+
</style>
|
75 |
+
""",
|
76 |
+
unsafe_allow_html=True
|
77 |
+
)
|
78 |
+
|
79 |
+
# Add title and description
|
80 |
+
st.markdown('<div class="title">FactBench Leaderboard</div>',
|
81 |
+
unsafe_allow_html=True)
|
82 |
+
st.markdown('<div class="description">Benchmark for LM Factuality Evaluation</div>',
|
83 |
+
unsafe_allow_html=True)
|
84 |
+
|
85 |
+
# Data for all tiers combined
|
86 |
+
data = {
|
87 |
+
'Tier': ['Easy', 'Easy', 'Easy', 'Easy',
|
88 |
+
'Moderate', 'Moderate', 'Moderate', 'Moderate',
|
89 |
+
'Hard', 'Hard', 'Hard', 'Hard'],
|
90 |
+
'Model': ['GPT4-o', 'Gemini1.5-Pro', 'Llama3.1-70B-Instruct', 'Llama3.1-405B-Instruct',
|
91 |
+
'GPT4-o', 'Gemini1.5-Pro', 'Llama3.1-70B-Instruct', 'Llama3.1-405B-Instruct',
|
92 |
+
'GPT4-o', 'Gemini1.5-Pro', 'Llama3.1-70B-Instruct', 'Llama3.1-405B-Instruct'],
|
93 |
+
'FactScore': [53.19, 51.79, 52.49, 53.22, 54.76, 52.62, 52.53, 53.48, 69.44, 66.05, 69.85, 70.04],
|
94 |
+
'SAFE': [63.31, 61.24, 61.29, 61.63, 65.01, 62.68, 62.64, 63.29, 76.17, 75.69, 77.55, 77.01],
|
95 |
+
'Factcheck-GPT': [86.4, 83.45, 83.48, 83.57, 89.39, 87.44, 85.16, 86.37, 94.25, 91.09, 92.89, 93.64],
|
96 |
+
'VERIFY': [71.58, 69.38, 67.27, 64.94, 76.02, 74.24, 72.01, 70.25, 90.58, 87.82, 86.63, 85.79]
|
97 |
+
}
|
98 |
+
|
99 |
+
# Convert the data to a DataFrame
|
100 |
+
df = pd.DataFrame(data)
|
101 |
+
|
102 |
+
# Dropdown menu to filter tiers
|
103 |
+
tiers = ['All Tiers', 'Easy', 'Moderate', 'Hard']
|
104 |
+
selected_tier = st.selectbox('Select Tier:', tiers)
|
105 |
+
|
106 |
+
# Filter the data based on the selected tier
|
107 |
+
if selected_tier != 'All Tiers':
|
108 |
+
filtered_df = df[df['Tier'] == selected_tier]
|
109 |
+
else:
|
110 |
+
filtered_df = df
|
111 |
+
|
112 |
+
# Create HTML for the table
|
113 |
+
html = '''
|
114 |
+
<table>
|
115 |
+
<thead>
|
116 |
+
<tr>
|
117 |
+
<th>Tier</th>
|
118 |
+
<th>Model</th>
|
119 |
+
<th>FactScore</th>
|
120 |
+
<th>SAFE</th>
|
121 |
+
<th>Factcheck-GPT</th>
|
122 |
+
<th>VERIFY</th>
|
123 |
+
</tr>
|
124 |
+
</thead>
|
125 |
+
<tbody>
|
126 |
+
'''
|
127 |
+
|
128 |
+
# Generate the rows of the table
|
129 |
+
current_tier = None
|
130 |
+
for i, row in filtered_df.iterrows():
|
131 |
+
if row['Tier'] != current_tier:
|
132 |
+
if current_tier is not None:
|
133 |
+
# Close the previous tier row
|
134 |
+
html += ' </tr>'
|
135 |
+
current_tier = row['Tier']
|
136 |
+
html += f' <tr><td rowspan="4" style="vertical-align: middle;">{current_tier}</td>'
|
137 |
+
else:
|
138 |
+
html += ' <tr>'
|
139 |
+
|
140 |
+
# Fill in model and scores
|
141 |
+
html += f'''
|
142 |
+
<td>{row['Model']}</td>
|
143 |
+
<td>{row['FactScore']:.2f}</td>
|
144 |
+
<td>{row['SAFE']:.2f}</td>
|
145 |
+
<td>{row['Factcheck-GPT']:.2f}</td>
|
146 |
+
<td>{row['VERIFY']:.2f}</td>
|
147 |
+
</tr>
|
148 |
+
'''
|
149 |
+
|
150 |
+
# Close the last row and table tags
|
151 |
+
html += '''
|
152 |
+
|
153 |
+
</table>
|
154 |
+
'''
|
155 |
+
|
156 |
+
# Display
|
157 |
+
st.markdown(html, unsafe_allow_html=True)
|
requirements.py
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
pandas
|
2 |
+
streamlit
|
3 |
+
scikit-learn == 1.0.2
|