import json import gradio as gr import pandas as pd from huggingface_hub import HfFileSystem RESULTS_DATASET_ID = "datasets/open-llm-leaderboard/results" fs = HfFileSystem() def fetch_results(): files = fs.glob(f"{RESULTS_DATASET_ID}/**/**/*.json") results = [file[len(RESULTS_DATASET_ID) +1:] for file in files] return results def load_result(result_path) -> pd.DataFrame: with fs.open(f"{RESULTS_DATASET_ID}/{result_path}", "r") as f: data = json.load(f) model_name = data.get("model_name", "Model") df = pd.json_normalize([data]) return df.iloc[0].rename_axis("Parameters").rename(model_name).to_frame() # .reset_index() def render_result_1(result_path, results): result = load_result(result_path) return pd.concat([result, results.iloc[:, [0, 2]].set_index("Parameters")], axis=1).reset_index() def render_result_2(result_path, results): result = load_result(result_path) return pd.concat([results.iloc[:, [0, 1]].set_index("Parameters"), result], axis=1).reset_index() if __name__ == "__main__": results = fetch_results() with gr.Blocks(fill_height=True) as demo: gr.HTML("