import gradio as gr import pandas as pd import numpy as np import json import requests # URLs for the two JSON files FILE_URL_1 = "https://raw.githubusercontent.com/EleutherAI/lm-evaluation-harness/master/results/llama/llama-30B/llama-30B_mmlu_5-shot.json" FILE_URL_2 = "https://raw.githubusercontent.com/EleutherAI/lm-evaluation-harness/master/results/llama/llama-13B/llama-13B_mmlu_5-shot.json" # Derive column names from the URLs column_name_1 = FILE_URL_1.split('/')[-1].split('_')[0] # 'llama-30B' column_name_2 = FILE_URL_2.split('/')[-1].split('_')[0] # 'llama-13B' # Load data from both URLs response1 = requests.get(FILE_URL_1) data1 = response1.json() response2 = requests.get(FILE_URL_2) data2 = response2.json() # Convert data from both URLs into DataFrames data1_df = pd.DataFrame(data1['results']).T data2_df = pd.DataFrame(data2['results']).T # Rename 'acc' column to respective file names data1_df = data1_df.rename(columns={'acc': column_name_1}) data2_df = data2_df.rename(columns={'acc': column_name_2}) # Remove 'hendrycksTest-' from the index of both dataframes data1_df.index = data1_df.index.str.replace('hendrycksTest-', '') data2_df.index = data2_df.index.str.replace('hendrycksTest-', '') # Merge the dataframes on index (Here index is the sub-test names) data = pd.merge(data1_df[column_name_1], data2_df[column_name_2], left_index=True, right_index=True) def show_leaderboard(): # Convert dataframe to html so that it can be displayed properly in Gradio return data.to_html() iface = gr.Interface(fn=show_leaderboard, inputs=[], outputs="html") # Run the interface. # Note: you don't need to use .launch() in Hugging Face Spaces, this is for local testing. iface.launch()