pratyushmaini commited on
Commit
61fd7c8
β€’
1 Parent(s): a86b221
Files changed (2) hide show
  1. app.py +86 -31
  2. app_bkp.py +59 -0
app.py CHANGED
@@ -1,9 +1,10 @@
1
  import gradio as gr
2
  import pandas as pd
 
3
 
4
  # Function to load data from a given CSV file
5
  def load_data(version):
6
- file_path = f'versions/{version}.csv' # Assuming filenames are version1.csv, version2.csv, version3.csv
7
  return pd.read_csv(file_path)
8
 
9
  # Function for searching in the leaderboard
@@ -18,42 +19,96 @@ def change_version(version):
18
  new_df = load_data(version)
19
  return new_df
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  # Initialize Gradio app
22
  demo = gr.Blocks()
23
 
24
  with demo:
25
  gr.Markdown("## πŸ₯‡ TOFU Leaderboard")
26
 
27
- with gr.Row():
28
- version_dropdown = gr.Dropdown(
29
- choices=["llama", "phi", "stable-lm"],
30
- label="πŸ”„ Select Base Model",
31
- value="llama",
32
- )
33
-
34
- with gr.Row():
35
- search_bar = gr.Textbox(
36
- placeholder="Search for methods...",
37
- show_label=False,
38
- )
39
-
40
- leaderboard_table = gr.components.Dataframe(
41
- value=load_data("llama"), # Load initial version (version llama)
42
- interactive=True,
43
- visible=True,
44
- )
45
-
46
- version_dropdown.change(
47
- change_version,
48
- inputs=version_dropdown,
49
- outputs=leaderboard_table
50
- )
51
-
52
- search_bar.change(
53
- search_leaderboard,
54
- inputs=[leaderboard_table, search_bar],
55
- outputs=leaderboard_table
56
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
  # Launch the app
59
  demo.launch()
 
1
  import gradio as gr
2
  import pandas as pd
3
+ import matplotlib.pyplot as plt
4
 
5
  # Function to load data from a given CSV file
6
  def load_data(version):
7
+ file_path = f'versions/{version}.csv' # Replace with your file paths
8
  return pd.read_csv(file_path)
9
 
10
  # Function for searching in the leaderboard
 
19
  new_df = load_data(version)
20
  return new_df
21
 
22
+ # Function to create plots
23
+ def create_plots(df, selected_methods):
24
+ if not selected_methods:
25
+ return plt.figure() # Return an empty plot if no method is selected
26
+
27
+ filtered_df = df[df['Method'].isin(selected_methods)]
28
+ fig, ax = plt.subplots()
29
+ for method in selected_methods:
30
+ method_df = filtered_df[filtered_df['Method'] == method]
31
+ ax.plot(method_df['PPL'], label=method) # Example: Plotting PPL, replace with your metrics
32
+
33
+ ax.set_xlabel('Index') # Modify as per your data
34
+ ax.set_ylabel('PPL') # Modify as per your data
35
+ ax.legend()
36
+ return fig
37
+
38
  # Initialize Gradio app
39
  demo = gr.Blocks()
40
 
41
  with demo:
42
  gr.Markdown("## πŸ₯‡ TOFU Leaderboard")
43
 
44
+
45
+
46
+ with gr.Tabs():
47
+ with gr.TabItem("Leaderboard"):
48
+ with gr.Row():
49
+ version_dropdown = gr.Dropdown(
50
+ choices=["llama", "phi", "stable-lm"],
51
+ label="πŸ”„ Select Base Model",
52
+ value="llama",
53
+ )
54
+
55
+ with gr.Row():
56
+ search_bar = gr.Textbox(
57
+ placeholder="Search for methods...",
58
+ show_label=False,
59
+ )
60
+
61
+ leaderboard_table = gr.components.Dataframe(
62
+ value=load_data("llama"),
63
+ interactive=True,
64
+ visible=True,
65
+ )
66
+
67
+ version_dropdown.change(
68
+ change_version,
69
+ inputs=version_dropdown,
70
+ outputs=leaderboard_table
71
+ )
72
+
73
+ search_bar.change(
74
+ search_leaderboard,
75
+ inputs=[leaderboard_table, search_bar],
76
+ outputs=leaderboard_table
77
+ )
78
+
79
+ with gr.TabItem("Plots"):
80
+ version_dropdown_plots = gr.Dropdown(
81
+ choices=["llama", "phi", "stable-lm"],
82
+ label="πŸ”„ Select Base Model",
83
+ value="llama",
84
+ )
85
+
86
+ with gr.Row():
87
+ methods_checkbox = gr.CheckboxGroup(
88
+ label="Select Methods",
89
+ choices=[], # To be populated dynamically
90
+ )
91
+
92
+ plot_output = gr.Plot()
93
+
94
+ # Dynamically update the choices for the methods checkbox
95
+ def update_method_choices(version):
96
+ df = load_data(version)
97
+ methods = df['Method'].unique()
98
+ methods_checkbox.update(choices=methods)
99
+ return df
100
+
101
+ version_dropdown_plots.change(
102
+ update_method_choices,
103
+ inputs=version_dropdown_plots,
104
+ outputs=[methods_checkbox, plot_output]
105
+ )
106
+
107
+ methods_checkbox.change(
108
+ create_plots,
109
+ inputs=[methods_checkbox, leaderboard_table],
110
+ outputs=plot_output
111
+ )
112
 
113
  # Launch the app
114
  demo.launch()
app_bkp.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+
4
+ # Function to load data from a given CSV file
5
+ def load_data(version):
6
+ file_path = f'versions/{version}.csv' # Assuming filenames are version1.csv, version2.csv, version3.csv
7
+ return pd.read_csv(file_path)
8
+
9
+ # Function for searching in the leaderboard
10
+ def search_leaderboard(df, query):
11
+ if query == "":
12
+ return df
13
+ else:
14
+ return df[df['Method'].str.contains(query)]
15
+
16
+ # Function to change the version of the leaderboard
17
+ def change_version(version):
18
+ new_df = load_data(version)
19
+ return new_df
20
+
21
+ # Initialize Gradio app
22
+ demo = gr.Blocks()
23
+
24
+ with demo:
25
+ gr.Markdown("## πŸ₯‡ TOFU Leaderboard")
26
+
27
+ with gr.Row():
28
+ version_dropdown = gr.Dropdown(
29
+ choices=["llama", "phi", "stable-lm"],
30
+ label="πŸ”„ Select Base Model",
31
+ value="llama",
32
+ )
33
+
34
+ with gr.Row():
35
+ search_bar = gr.Textbox(
36
+ placeholder="Search for methods...",
37
+ show_label=False,
38
+ )
39
+
40
+ leaderboard_table = gr.components.Dataframe(
41
+ value=load_data("llama"), # Load initial version (version llama)
42
+ interactive=True,
43
+ visible=True,
44
+ )
45
+
46
+ version_dropdown.change(
47
+ change_version,
48
+ inputs=version_dropdown,
49
+ outputs=leaderboard_table
50
+ )
51
+
52
+ search_bar.change(
53
+ search_leaderboard,
54
+ inputs=[leaderboard_table, search_bar],
55
+ outputs=leaderboard_table
56
+ )
57
+
58
+ # Launch the app
59
+ demo.launch()