Joschka Strueber commited on
Commit
7fa11aa
·
1 Parent(s): 74aba7c

[Add] load data from oLLMLv2, drawdown menus

Browse files
Files changed (2) hide show
  1. app.py +42 -23
  2. src/dataloading.py +31 -0
app.py CHANGED
@@ -1,28 +1,47 @@
1
- from datasets import load_dataset
2
- import numpy as np
3
- import matplotlib.pyplot as plt
4
  import gradio as gr
5
 
6
- def compute_similarity(dataset_name):
7
- # Load dataset
8
- #dataset = load_dataset(dataset_name)
9
- # Dummy similarity computation (replace with your metric)
10
- data = np.random.rand(10, 10)
11
- # Create heatmap
12
- fig, ax = plt.subplots()
13
- cax = ax.matshow(data, cmap='viridis')
14
- plt.colorbar(cax)
15
- return fig
16
 
17
- with gr.Blocks() as demo:
18
- dataset_name = gr.Textbox(label="Enter Dataset Name (e.g., 'imdb')")
19
- heatmap_plot = gr.Plot(label="Similarity Heatmap")
20
- compute_button = gr.Button("Compute Similarity")
21
 
22
- compute_button.click(
23
- fn=compute_similarity,
24
- inputs=dataset_name,
25
- outputs=heatmap_plot
26
- )
27
 
28
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
+ from src.dataloading import get_leaderboard_models, get_leaderboard_datasets
 
 
 
 
 
 
 
 
 
4
 
 
 
 
 
5
 
6
+ def create_demo():
7
+ # Fetch data once on startup (cache this in production)
8
+ models = get_leaderboard_models()
9
+ datasets = get_leaderboard_datasets()
 
10
 
11
+ with gr.Blocks(title="LLM Similarity Analyzer") as demo:
12
+ gr.Markdown("## Compare Models/Datasets from Open LLM Leaderboard")
13
+
14
+ with gr.Row():
15
+ model_dropdown = gr.Dropdown(
16
+ choices=models,
17
+ label="Select Model",
18
+ filterable=True,
19
+ interactive=True,
20
+ allow_custom_value=False,
21
+ info="Search models from Open LLM Leaderboard"
22
+ )
23
+
24
+ dataset_dropdown = gr.Dropdown(
25
+ choices=datasets,
26
+ label="Select Dataset",
27
+ filterable=True,
28
+ interactive=True,
29
+ info="Leaderboard benchmark datasets"
30
+ )
31
+
32
+ # Add your similarity computation and visualization components here
33
+ # Example placeholder:
34
+ similarity_output = gr.Textbox(label="Similarity Score")
35
+ compute_btn = gr.Button("Compute Similarity")
36
+
37
+ def compute_similarity(model, dataset):
38
+ # Replace with your actual similarity metric
39
+ return f"Similarity between {model} and {dataset}: {0.85:.2f}"
40
+
41
+ compute_btn.click(
42
+ fn=compute_similarity,
43
+ inputs=[model_dropdown, dataset_dropdown],
44
+ outputs=similarity_output
45
+ )
46
+
47
+ return demo
src/dataloading.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import HfApi
2
+
3
+ def get_leaderboard_models():
4
+ api = HfApi()
5
+
6
+ # List all files in the "open_llm_leaderboard" directory of the Space
7
+ files = api.list_files_info(
8
+ repo_id="open-llm-leaderboard/open_llm_leaderboard",
9
+ path="open_llm_leaderboard",
10
+ repo_type="space"
11
+ )
12
+
13
+ models = []
14
+ for file in files:
15
+ if "-details" in file.path and "__" in file.path:
16
+ # Extract provider and model name from filename
17
+ filename = file.path.split("/")[-1].replace("-details", "")
18
+ provider, model = filename.split("__", 1)
19
+ models.append(f"{provider}/{model}")
20
+
21
+ return sorted(list(set(models))) # Remove duplicates
22
+
23
+ def get_leaderboard_datasets():
24
+ return [
25
+ "ai2_arc",
26
+ "hellaswag",
27
+ "mmlu",
28
+ "truthful_qa",
29
+ "winogrande",
30
+ "gsm8k"
31
+ ]