CultriX commited on
Commit
c581f25
·
verified ·
1 Parent(s): c56b33e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -78
app.py CHANGED
@@ -1,22 +1,11 @@
1
-
2
- ## Comprehensive Model Performance Analysis
3
-
4
- ### Importing Required Libraries
5
  import pandas as pd
6
  import matplotlib.pyplot as plt
7
  import seaborn as sns
8
  import gradio as gr
9
  import requests
10
  from bs4 import BeautifulSoup
11
- import io
12
- import os
13
- import base64
14
- import zipfile
15
- from PIL import Image
16
- from io import BytesIO
17
 
18
- ### Input Data
19
- # Data with links to Hugging Face repositories
20
  data_full = [
21
  ['CultriX/Qwen2.5-14B-SLERPv7', 'https://huggingface.co/CultriX/Qwen2.5-14B-SLERPv7', 0.7205, 0.8272, 0.7541, 0.6581, 0.5, 0.729],
22
  ['djuna/Q2.5-Veltha-14B-0.5', 'https://huggingface.co/djuna/Q2.5-Veltha-14B-0.5', 0.7492, 0.8386, 0.7305, 0.598, 0.43, 0.7817],
@@ -44,79 +33,57 @@ data_full = [
44
  ['CultriX/Qwen2.5-14B-Wernickev7', 'https://huggingface.co/CultriX/Qwen2.5-14B-Wernickev7', 0.7147, 0.7599, 0.6097, 0.7056, 0.57, 0.7164],
45
  ['CultriX/Qwen2.5-14B-FinalMerge-tmp2', 'https://huggingface.co/CultriX/Qwen2.5-14B-FinalMerge-tmp2', 0.7255, 0.8192, 0.7535, 0.6671, 0.5, 0.7612],
46
  ]
 
47
  columns = ["Model Configuration", "Model Link", "tinyArc", "tinyHellaswag", "tinyMMLU", "tinyTruthfulQA", "tinyTruthfulQA_mc1", "tinyWinogrande"]
48
  df_full = pd.DataFrame(data_full, columns=columns)
49
 
50
- ### Visualization and Analytics Functions
 
 
 
 
 
 
 
 
 
 
51
 
52
- # 1. Plot Average Scores
53
- def plot_average_scores():
54
- df_full["Average Score"] = df_full.iloc[:, 2:].mean(axis=1)
55
- df_avg_sorted = df_full.sort_values(by="Average Score", ascending=False)
56
- plt.figure(figsize=(12, 8))
57
- plt.barh(df_avg_sorted["Model Configuration"], df_avg_sorted["Average Score"])
58
- plt.title("Average Performance of Models Across Tasks", fontsize=16)
59
- plt.xlabel("Average Score", fontsize=14)
60
- plt.ylabel("Model Configuration", fontsize=14)
61
- plt.gca().invert_yaxis()
62
- plt.grid(axis='x', linestyle='--', alpha=0.7)
63
- plt.tight_layout()
64
- plt.show()
65
 
66
- # 2. Plot Task Performance
67
- def plot_task_performance():
68
- df_full_melted = df_full.melt(id_vars=["Model Configuration", "Model Link"], var_name="Task", value_name="Score")
69
- plt.figure(figsize=(14, 10))
70
- for model in df_full["Model Configuration"]:
71
- model_data = df_full_melted[df_full_melted["Model Configuration"] == model]
72
- plt.plot(model_data["Task"], model_data["Score"], marker="o", label=model)
73
- plt.title("Performance of All Models Across Tasks", fontsize=16)
74
- plt.xlabel("Task", fontsize=14)
75
- plt.ylabel("Score", fontsize=14)
76
- plt.xticks(rotation=45)
77
- plt.legend(bbox_to_anchor=(1.05, 1), loc='upper left', fontsize=9)
78
- plt.grid(axis='y', linestyle='--', alpha=0.7)
79
- plt.tight_layout()
80
- plt.show()
81
 
82
- # 3. Plot Task-Specific Top Models
83
- def plot_task_specific_top_models():
84
- top_models = df_full.iloc[:, 2:].idxmax()
85
- top_scores = df_full.iloc[:, 2:].max()
86
- results = pd.DataFrame({"Top Model": top_models, "Score": top_scores}).reset_index().rename(columns={"index": "Task"})
87
- plt.figure(figsize=(12, 6))
88
- plt.bar(results["Task"], results["Score"])
89
- plt.title("Task-Specific Top Models", fontsize=16)
90
- plt.xlabel("Task", fontsize=14)
91
- plt.ylabel("Score", fontsize=14)
92
- plt.grid(axis="y", linestyle="--", alpha=0.7)
93
- plt.tight_layout()
94
- plt.show()
95
 
96
- ### YAML Configuration and Scraping Utilities
97
- # 1. Scrape MergeKit Configuration
98
- def scrape_mergekit_config(model_name):
99
- model_link = df_full.loc[df_full["Model Configuration"] == model_name, "Model Link"].values[0]
100
- response = requests.get(model_link)
101
- if response.status_code != 200:
102
- return f"Failed to fetch model page for {model_name}. Please check the link."
103
- soup = BeautifulSoup(response.text, "html.parser")
104
- yaml_config = soup.find("pre")
105
- return yaml_config.text.strip() if yaml_config else f"No YAML configuration found for {model_name}."
106
 
107
- ### Performance Heatmap
108
- def plot_heatmap():
109
- plt.figure(figsize=(12, 8))
110
- sns.heatmap(df_full.iloc[:, 2:], annot=True, cmap="YlGnBu", xticklabels=columns[2:], yticklabels=df_full["Model Configuration"])
111
- plt.title("Performance Heatmap", fontsize=16)
112
- plt.tight_layout()
113
- plt.show()
114
 
115
- ### Gradio App
116
- # Building the Interface
117
  with gr.Blocks() as demo:
118
- gr.Markdown("# Comprehensive Model Performance Analysis")
119
- gr.Image(type="pil", label="Average Performance Plot")
120
- gr.Image(type="pil", label="Task Performance Plot")
121
- gr.Image(type="pil", label="Task-Specific Top Models")
122
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import pandas as pd
2
  import matplotlib.pyplot as plt
3
  import seaborn as sns
4
  import gradio as gr
5
  import requests
6
  from bs4 import BeautifulSoup
 
 
 
 
 
 
7
 
8
+ # Local dataset (optional, for pre-loaded data)
 
9
  data_full = [
10
  ['CultriX/Qwen2.5-14B-SLERPv7', 'https://huggingface.co/CultriX/Qwen2.5-14B-SLERPv7', 0.7205, 0.8272, 0.7541, 0.6581, 0.5, 0.729],
11
  ['djuna/Q2.5-Veltha-14B-0.5', 'https://huggingface.co/djuna/Q2.5-Veltha-14B-0.5', 0.7492, 0.8386, 0.7305, 0.598, 0.43, 0.7817],
 
33
  ['CultriX/Qwen2.5-14B-Wernickev7', 'https://huggingface.co/CultriX/Qwen2.5-14B-Wernickev7', 0.7147, 0.7599, 0.6097, 0.7056, 0.57, 0.7164],
34
  ['CultriX/Qwen2.5-14B-FinalMerge-tmp2', 'https://huggingface.co/CultriX/Qwen2.5-14B-FinalMerge-tmp2', 0.7255, 0.8192, 0.7535, 0.6671, 0.5, 0.7612],
35
  ]
36
+
37
  columns = ["Model Configuration", "Model Link", "tinyArc", "tinyHellaswag", "tinyMMLU", "tinyTruthfulQA", "tinyTruthfulQA_mc1", "tinyWinogrande"]
38
  df_full = pd.DataFrame(data_full, columns=columns)
39
 
40
+ def scrape_model_page(model_url):
41
+ """
42
+ Scrapes the Hugging Face model page for YAML configuration and other details.
43
+ """
44
+ try:
45
+ # Fetch the model page
46
+ response = requests.get(model_url)
47
+ if response.status_code != 200:
48
+ return f"Error: Unable to fetch the page (Status Code: {response.status_code})"
49
+
50
+ soup = BeautifulSoup(response.text, "html.parser")
51
 
52
+ # Extract YAML configuration (usually inside <pre> tags)
53
+ yaml_config = soup.find("pre")
54
+ yaml_text = yaml_config.text.strip() if yaml_config else "No YAML configuration found."
 
 
 
 
 
 
 
 
 
 
55
 
56
+ # Extract additional metadata or performance (if available)
57
+ metadata_section = soup.find("div", class_="metadata")
58
+ metadata_text = metadata_section.text.strip() if metadata_section else "No metadata found."
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
+ # Return the scraped details
61
+ return f"**YAML Configuration:**\n{yaml_text}\n\n**Metadata:**\n{metadata_text}"
 
 
 
 
 
 
 
 
 
 
 
62
 
63
+ except Exception as e:
64
+ return f"Error: {str(e)}"
 
 
 
 
 
 
 
 
65
 
66
+ def display_scraped_model_data(model_url):
67
+ """
68
+ Displays YAML configuration and metadata for a given model URL.
69
+ """
70
+ return scrape_model_page(model_url)
 
 
71
 
 
 
72
  with gr.Blocks() as demo:
73
+ gr.Markdown("# Model Performance Analysis with Live Scraping")
74
+
75
+ # Pre-loaded dataset features
76
+ with gr.Row():
77
+ btn1 = gr.Button("Show Summary Statistics")
78
+ stats_output = gr.Dataframe()
79
+ btn1.click(lambda: df_full.describe().T, outputs=stats_output)
80
+
81
+ # Live scraping feature
82
+ gr.Markdown("## Live Scraping Features")
83
+ with gr.Row():
84
+ url_input = gr.Textbox(label="Enter Hugging Face Model URL", placeholder="https://huggingface.co/<model>")
85
+ scrape_btn = gr.Button("Scrape Model Page")
86
+ scrape_output = gr.Textbox(label="Scraped Data", lines=15)
87
+ scrape_btn.click(display_scraped_model_data, inputs=url_input, outputs=scrape_output)
88
+
89
+ demo.launch()