Spaces:
Sleeping
Sleeping
File size: 17,778 Bytes
296ef9e |
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 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
# import streamlit as st
# import pandas as pd
# from PIL import Image
# import base64
# from io import BytesIO
# # Set up page config
# st.set_page_config(
# page_title="VeriFact Leaderboard",
# layout="wide"
# )
# # load header
# with open("_header.md", "r") as f:
# HEADER_MD = f.read()
# # Load the image
# image = Image.open("test.png")
# logo_image = Image.open("./factrbench.png")
# # Custom CSS for the page
# st.markdown(
# """
# <style>
# @import url('https://fonts.googleapis.com/css2?family=Courier+Prime:wght@400&display=swap');
# html, body, [class*="css"] {
# font-family: 'Arial', sans-serif; /* or use a similar sans-serif font */
# background-color: #f9f9f9; /* Light grey background */
# }
# .title {
# font-size: 42px;
# font-weight: bold;
# text-align: center;
# color: #333;
# margin-bottom: 5px;
# }
# .description {
# font-size: 22px;
# text-align: center;
# margin-bottom: 30px;
# color: #555;
# }
# .header, .metric {
# align-items: left;
# font-family: 'Arial', sans-serif; /* or use a similar sans-serif font */
# margin-bottom: 20px;
# }
# .container {
# max-width: 1000px;
# margin: 0 auto;
# padding: 5px;
# }
# table {
# width: 100%;
# border-collapse: collapse;
# border-radius: 10px;
# overflow: hidden;
# }
# th, td {
# padding: 8px;
# text-align: center;
# border: 1px solid #ddd;
# font-family: 'Arial', sans-serif; /* or use a similar sans-serif font */
# font-size: 16px;
# transition: background-color 0.3s;
# }
# th {
# background-color: #f2f2f2;
# font-weight: bold;
# }
# td:hover {
# background-color: #eaeaea;
# }
# </style>
# """,
# unsafe_allow_html=True
# )
# # Display title and description
# st.markdown('<div class="container">', unsafe_allow_html=True)
# # st.image(logo_image, output_format="PNG", width=200)
# # Convert the image to base64
# buffered = BytesIO()
# logo_image.save(buffered, format="PNG")
# img_data = base64.b64encode(buffered.getvalue()).decode("utf-8")
# st.markdown(
# f"""
# <style>
# .logo-container {{
# display: flex;
# justify-content: flex-start; /* Aligns to the left */
# }}
# .logo-container img {{
# width: 50%; /* Adjust this to control the width, e.g., 50% of container width */
# margin: 0 auto;
# max-width: 700px; /* Set a maximum width */
# background-color: transparent;
# }}
# </style>
# <div class="logo-container">
# <img src="data:image/png;base64,{img_data}" alt="VeriFact Leaderboard Logo">
# </div>
# """,
# unsafe_allow_html=True
# )
# # header_md_text = HEADER_MD # make some parameters later
# # gr.Markdown(header_md_text, elem_classes="markdown-text")
# st.markdown(
# '''
# <div class="header">
# <br/>
# <p style="font-size:22px;">
# VERIFACT: Enhancing Long-Form Factuality Evaluation with Refined Fact Extraction and Reference Facts
# </p>
# <p style="font-size:20px;">
# # 📑 <a href="">Paper</a> | 💻 <a href="">GitHub</a> | 🤗 <a href="">HuggingFace</a>
# ⚙️ <strong>Version</strong>: <strong>V1</strong> | <strong># Models</strong>: 8 | Updated: <strong>???</strong>
# </p>
# </div>
# ''',
# unsafe_allow_html=True
# )
# # st.markdown('<div class="title">VeriFact Leaderboard</div>',
# # unsafe_allow_html=True)
# # st.markdown('<div class="description">Long-Form Factuality Evaluation with Refined Fact Extraction and Reference Facts</div>', unsafe_allow_html=True)
# st.markdown('</div>', unsafe_allow_html=True)
# # Load the data
# data_path = "verifact_data.csv"
# df = pd.read_csv(data_path)
# # Assign ranks within each tier based on factuality_score
# df['rank'] = df.groupby('tier')['Overall'].rank(
# ascending=False, method='min').astype(int)
# # Replace NaN values with '-'
# df.fillna('-', inplace=True)
# df['original_order'] = df.groupby('tier').cumcount()
# # Create tabs
# st.markdown("""
# <style>
# .stTabs [data-baseweb="tab-list"] button [data-testid="stMarkdownContainer"] p {
# font-size: 20px;
# }
# </style>
# """, unsafe_allow_html=True)
# tab1, tab2 = st.tabs(["Leaderboard", "Benchmark Details"])
# # Tab 1: Leaderboard
# with tab1:
# # df['original_order'] = df.groupby('tier').cumcount()
# # print(df['original_order'])
# # st.markdown('<div class="title">Leaderboard</div>', unsafe_allow_html=True)
# st.markdown('<div class="tab-content">', unsafe_allow_html=True)
# st.markdown("""
# <div class="metric" style="font-size:20px; font-weight: bold;">
# Metrics Explanation
# </div>
# """, unsafe_allow_html=True)
# st.markdown("""
# <div class="metric" style="font-size:16px;">
# <br/>
# <p>
# <strong> 🎯 Factual Precision </strong> measures the ratio of supported units divided by all units averaged over model responses. <strong> 🌀 Hallucination Score </strong> quantifies the incorrect or inconclusive contents within a model response, as described in the paper. We also provide statistics on the average length of the response in terms of the number of tokens, the average verifiable units existing in the model responses (<strong>Avg. # Units</strong>), the average number of units labelled as undecidable (<strong>Avg. # Undecidable</strong>), and the average number of units labelled as unsupported (<strong>Avg. # Unsupported</strong>).
# </p>
# <p>
# 🔒 for closed LLMs; 🔑 for open-weights LLMs; 🚨 for newly added models
# </p>
# </div>
# """,
# unsafe_allow_html=True
# )
# st.markdown("""
# <style>
# /* Selectbox text */
# div[data-baseweb="select"] > div {
# font-size: 20px;
# }
# /* Dropdown options */
# div[role="listbox"] ul li {
# font-size: 20px !important;
# }
# /* Checkbox label */
# .stCheckbox label p {
# font-size: 20px !important;
# }
# /* Selectbox label */
# .stSelectbox label p {
# font-size: 20px !important;
# }
# </style>
# """, unsafe_allow_html=True)
# # Dropdown menu to filter tiers
# tiers = ['All Metrics', 'Precision', 'Recall', 'F1']
# selected_tier = st.selectbox('Select metric:', tiers)
# # Filter the data based on the selected tier
# if selected_tier != 'All Metrics':
# filtered_df = df[df['tier'] == selected_tier]
# else:
# filtered_df = df
# sort_by_factuality = st.checkbox('Sort by overall score')
# # Sort the dataframe based on Factuality Score if the checkbox is selected
# if sort_by_factuality:
# updated_filtered_df = filtered_df.sort_values(
# by=['tier', 'Overall'], ascending=[True, False]
# )
# else:
# updated_filtered_df = filtered_df.sort_values(
# by=['tier', 'original_order']
# )
# # Create HTML for the table
# if selected_tier == 'All Metrics':
# html = '''
# <table>
# <thead>
# <tr>
# <th>Metric</th>
# <th>Rank</th>
# <th>Model</th>
# <th>Factbench</th>
# <th>Reddit</th>
# <th>Overall</th>
# </tr>
# </thead>
# <tbody>
# '''
# else:
# html = '''
# <table>
# <thead>
# <tr>
# <th>Rank</th>
# <th>Model</th>
# <th>Factbench</th>
# <th>Reddit</th>
# <th>Overall</th>
# </tr>
# </thead>
# <tbody>
# '''
# # Generate the rows of the table
# current_tier = None
# for i, row in updated_filtered_df.iterrows():
# html += '<tr>'
# # Only display the 'Tier' column if 'All Tiers' is selected
# if selected_tier == 'All Metrics':
# if row['tier'] != current_tier:
# current_tier = row['tier']
# html += f'<td rowspan="8" style="vertical-align: middle;">{current_tier}</td>'
# # Fill in model and scores
# html += f'''
# <td>{row['rank']}</td>
# <td>{row['model']}</td>
# <td>{row['FactBench']}</td>
# <td>{row['Reddit']}</td>
# <td>{row['Overall']}</td>
# </tr>
# '''
# # Close the table
# html += '''
# </table>
# '''
# # Display the table
# st.markdown(html, unsafe_allow_html=True)
# st.markdown('</div>', unsafe_allow_html=True)
# # Tab 2: Details
# with tab2:
# st.markdown('<div class="tab-content">', unsafe_allow_html=True)
# # st.markdown('<div class="title"></div>',
# # unsafe_allow_html=True)
# st.image(image, use_column_width=True)
# st.markdown('### VERIFY: A Pipeline for Factuality Evaluation')
# st.write(
# "Language models (LMs) are widely used by an increasing number of users, "
# "underscoring the challenge of maintaining factual accuracy across a broad range of topics. "
# "We present VERIFY (Verification and Evidence Retrieval for Factuality evaluation), "
# "a pipeline to evaluate LMs' factual accuracy in real-world user interactions."
# )
# st.markdown('### Content Categorization')
# st.write(
# "VERIFY considers the verifiability of LM-generated content and categorizes content units as "
# "`supported`, `unsupported`, or `undecidable` based on the retrieved web evidence. "
# "Importantly, VERIFY's factuality judgments correlate better with human evaluations than existing methods."
# )
# st.markdown('### Hallucination Prompts & FactBench Dataset')
# st.write(
# "Using VERIFY, we identify 'hallucination prompts' across diverse topics—those eliciting the highest rates of "
# "incorrect or unverifiable LM responses. These prompts form FactBench, a dataset of 985 prompts across 213 "
# "fine-grained topics. Our dataset captures emerging factuality challenges in real-world LM interactions and is "
# "regularly updated with new prompts."
# )
# st.markdown('</div>', unsafe_allow_html=True)
# # # Tab 3: Links
# # with tab3:
# # st.markdown('<div class="tab-content">', unsafe_allow_html=True)
# # st.markdown('<div class="title">Submit your model information on our Github</div>',
# # unsafe_allow_html=True)
# # st.markdown(
# # '[Test your model locally!](https://github.com/FarimaFatahi/FactEval)')
# # st.markdown(
# # '[Submit results or issues!](https://github.com/FarimaFatahi/FactEval/issues/new)')
# # st.markdown('</div>', unsafe_allow_html=True)
import streamlit as st
import pandas as pd
from PIL import Image
import base64
from io import BytesIO
# Set up page config
st.set_page_config(
page_title="VeriFact Leaderboard",
layout="wide"
)
# load header
with open("_header.md", "r") as f:
HEADER_MD = f.read()
# Load the image
image = Image.open("test.png")
logo_image = Image.open("./factrbench.png")
# Custom CSS for the page
st.markdown(
"""
<style>
@import url('https://fonts.googleapis.com/css2?family=Courier+Prime:wght@400&display=swap');
html, body, [class*="css"] {
font-family: 'Arial', sans-serif;
background-color: #f9f9f9;
}
.title {
font-size: 42px;
font-weight: bold;
text-align: center;
color: #333;
margin-bottom: 5px;
}
.description {
font-size: 22px;
text-align: center;
margin-bottom: 30px;
color: #555;
}
.header, .metric {
align-items: left;
margin-bottom: 20px;
}
.container {
max-width: 1000px;
margin: 0 auto;
padding: 5px;
}
table {
width: 100%;
border-collapse: collapse;
border-radius: 10px;
overflow: hidden;
}
th, td {
padding: 8px;
text-align: center;
border: 1px solid #ddd;
font-size: 16px;
transition: background-color 0.3s;
}
th {
background-color: #f2f2f2;
font-weight: bold;
}
td:hover {
background-color: #eaeaea;
}
</style>
""",
unsafe_allow_html=True
)
# Display logo
buffered = BytesIO()
logo_image.save(buffered, format="PNG")
img_data = base64.b64encode(buffered.getvalue()).decode("utf-8")
st.markdown(
f"""
<div class="logo-container" style="display:flex; justify-content: flex-start;">
<img src="data:image/png;base64,{img_data}" style="width:50%; max-width:700px;"/>
</div>
""",
unsafe_allow_html=True
)
st.markdown(
'''
<div class="header">
<br/>
<p style="font-size:22px;">
VERIFACT: Enhancing Long-Form Factuality Evaluation with Refined Fact Extraction and Reference Facts
</p>
<p style="font-size:20px;">
# 📑 <a href="">Paper</a> | 💻 <a href="">GitHub</a> | 🤗 <a href="">HuggingFace</a>
⚙️ <strong>Version</strong>: <strong>V1</strong> | <strong># Models</strong>: 8 | Updated: <strong>???</strong>
</p>
</div>
''',
unsafe_allow_html=True
)
# Load the data
data_path = "verifact_data.csv"
df = pd.read_csv(data_path)
# Assign ranks within each tier
df['rank'] = df.groupby('tier')['Overall'].rank(
ascending=False, method='min').astype(int)
df.fillna('-', inplace=True)
df['original_order'] = df.groupby('tier').cumcount()
# Tabs
tab1, tab2 = st.tabs(["Leaderboard", "Benchmark Details"])
# Tab 1: Leaderboard
with tab1:
st.markdown('<div class="metric" style="font-size:20px; font-weight: bold;">Metrics Explanation</div>', unsafe_allow_html=True)
st.markdown("""
<div class="metric" style="font-size:16px;">
<p>
<strong> 🎯 Factual Precision </strong>, <strong> 🌀 Hallucination Score </strong> and other statistics are described in the paper.
🔒 for closed LLMs; 🔑 for open-weights LLMs; 🚨 for newly added models
</p>
</div>
""", unsafe_allow_html=True)
tiers = ['All Metrics', 'Precision', 'Recall', 'F1']
selected_tier = st.selectbox('Select metric:', tiers)
if selected_tier != 'All Metrics':
filtered_df = df[df['tier'] == selected_tier]
else:
filtered_df = df
sort_by_factuality = st.checkbox('Sort by overall score')
if sort_by_factuality:
updated_filtered_df = filtered_df.sort_values(by=['tier', 'Overall'], ascending=[True, False])
else:
updated_filtered_df = filtered_df.sort_values(by=['tier', 'original_order'])
# 缩小表格:用容器包裹并限制最大宽度
html = '<div style="max-width: 1000px; margin: 0 auto;"><table>'
html += """<thead><tr>""" + ("<th>Metric</th>" if selected_tier == 'All Metrics' else "") + "<th>Rank</th><th>Model</th><th>Factbench</th><th>Reddit</th><th>Overall</th></tr></thead><tbody>"
current_tier = None
for _, row in updated_filtered_df.iterrows():
html += '<tr>'
if selected_tier == 'All Metrics' and row['tier'] != current_tier:
current_tier = row['tier']
html += f'<td rowspan="8" style="vertical-align: middle;">{current_tier}</td>'
html += f'<td>{row["rank"]}</td><td>{row["model"]}</td><td>{row["FactBench"]}</td><td>{row["Reddit"]}</td><td>{row["Overall"]}</td></tr>'
html += '</tbody></table></div>'
st.markdown(html, unsafe_allow_html=True)
# Tab 2: Benchmark Details
with tab2:
# 图片剧中显示
buffered_img = BytesIO()
image.save(buffered_img, format="PNG")
image_data = base64.b64encode(buffered_img.getvalue()).decode("utf-8")
st.markdown(f'''<div style="text-align:center;">
<img src="data:image/png;base64,{image_data}" style="max-width:800px; width:100%; height:auto;" />
</div>''', unsafe_allow_html=True)
st.markdown('### VERIFY: A Pipeline for Factuality Evaluation')
st.write("Language models (LMs) are widely used by an increasing number of users, underscoring the challenge of maintaining factual accuracy across a broad range of topics. We present VERIFY (Verification and Evidence Retrieval for Factuality evaluation), a pipeline to evaluate LMs' factual accuracy in real-world user interactions.")
st.markdown('### Content Categorization')
st.write("VERIFY considers the verifiability of LM-generated content and categorizes content units as `supported`, `unsupported`, or `undecidable` based on the retrieved web evidence. Importantly, VERIFY's factuality judgments correlate better with human evaluations than existing methods.")
st.markdown('### Hallucination Prompts & FactBench Dataset')
st.write("Using VERIFY, we identify 'hallucination prompts' across diverse topics—those eliciting the highest rates of incorrect or unverifiable LM responses. These prompts form FactBench, a dataset of 985 prompts across 213 fine-grained topics. Our dataset captures emerging factuality challenges in real-world LM interactions and is regularly updated with new prompts.")
|