Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| # 假设你的数据存储在一个CSV文件中,我们将从这个文件中读取数据 | |
| def load_data(): | |
| return pd.read_csv("benchmark_data.csv") | |
| # 不区分大小写的搜索功能 | |
| def case_insensitive_search(data, query, column): | |
| if query: # 如果用户输入了搜索词 | |
| return data[data[column].str.lower().str.contains(query.lower())] | |
| return data | |
| # 创建一个带有滚动条的表格显示函数 | |
| def display_table(data, rows_per_page=20): | |
| # 使用 Streamlit 的 container 来创建滚动效果 | |
| container = st.container() | |
| with container: | |
| # 设置表格高度,基于每行的大致高度估算 | |
| height = min(40 + rows_per_page * 38, 800) # 最大高度为800像素 | |
| st.dataframe(data, height=height) | |
| # 页面布局和功能 | |
| def main(): | |
| st.title("Multihop-RAG Benchmark Space") | |
| data = load_data() | |
| # 添加搜索框 | |
| st.sidebar.header("Search Options") | |
| chat_model_query = st.sidebar.text_input("Search by Chat Model") | |
| embedding_model_query = st.sidebar.text_input("Search by Embedding Model") | |
| chunk_query = st.sidebar.text_input("Search by Chunk") # 新增按 Chunk 搜索 | |
| # 根据输入执行搜索 | |
| if chat_model_query: | |
| data = case_insensitive_search(data, chat_model_query, 'chat_model') | |
| if embedding_model_query: | |
| data = case_insensitive_search(data, embedding_model_query, 'embedding_model') | |
| if chunk_query: # 新增 Chunk 的筛选 | |
| data = case_insensitive_search(data, chunk_query, 'chunk') | |
| # 显示数据 | |
| st.header("Benchmark Results") | |
| st.write("Displaying results for MRR@10, Hit@10, and Accuracy across different frameworks, embedding models, chat models, and chunks.") | |
| display_table(data) # 使用自定义的表格显示函数 | |
| # 数据统计和图表 | |
| if st.sidebar.checkbox("Show Metrics Distribution"): | |
| st.subheader("Metrics Distribution") | |
| st.bar_chart(data[['MRR@10', 'Hit@10', 'Accuracy']]) # 添加Accuracy到图表中 | |
| if __name__ == "__main__": | |
| main() |