varun4 commited on
Commit
38f9e2f
1 Parent(s): 0930ba7

updated tabs

Browse files
Files changed (2) hide show
  1. app.py +60 -11
  2. run_mteb.py +0 -0
app.py CHANGED
@@ -1,35 +1,84 @@
1
- # my_table_app_gradio.py
2
-
3
  import gradio as gr
4
  import pandas as pd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  def display_table():
7
  # Create a sample dataframe
8
  data = {
9
  "Model": ["ModelA", "ModelB", "ModelC"],
 
10
  "Score": [0.92, 0.85, 0.89],
11
  "Quantized Score": [0.91, 0.84, 0.88]
12
  }
13
  df = pd.DataFrame(data)
14
 
15
- df.index.name = "Rank"
16
- # Convert the DataFrame to an HTML table string
17
- html_table = df.to_html(classes="wide_table")
18
-
19
 
20
- html_content = f"""
21
  <style>
22
- .wide_table {
23
  width: 100%;
24
- }
25
  </style>
26
  {html_table}
27
  """
28
 
29
- return html_table
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  # Create Gradio interface
32
  iface = gr.Interface(fn=display_table, live=True, inputs=[], outputs="html")
33
 
34
  iface.launch()
35
-
 
 
 
1
  import gradio as gr
2
  import pandas as pd
3
+ import json
4
+ import os
5
+
6
+ # Given list of tasks for clustering and pair classification
7
+ TASKS_CLUSTERING = [
8
+ "ArxivClusteringP2P",
9
+ "ArxivClusteringS2S",
10
+ "BiorxivClusteringP2P",
11
+ "BiorxivClusteringS2S",
12
+ "MedrxivClusteringP2P",
13
+ "MedrxivClusteringS2S",
14
+ "RedditClustering",
15
+ "RedditClusteringP2P",
16
+ "StackExchangeClustering",
17
+ "StackExchangeClusteringP2P",
18
+ "TwentyNewsgroupsClustering",
19
+ ]
20
+
21
+ TASKS_PAIR_CLASSIFICATION = [
22
+ "SprintDuplicateQuestions",
23
+ "TwitterSemEval2015",
24
+ "TwitterURLCorpus",
25
+ ]
26
 
27
  def display_table():
28
  # Create a sample dataframe
29
  data = {
30
  "Model": ["ModelA", "ModelB", "ModelC"],
31
+ "Model Size (MB)": [293, 793, 1000],
32
  "Score": [0.92, 0.85, 0.89],
33
  "Quantized Score": [0.91, 0.84, 0.88]
34
  }
35
  df = pd.DataFrame(data)
36
 
37
+ df.index.name = "Rank"
38
+ html_table = df.to_html()
 
 
39
 
40
+ html_content = f"""
41
  <style>
42
+ .wide_table {{
43
  width: 100%;
44
+ }}
45
  </style>
46
  {html_table}
47
  """
48
 
49
+ return html_content
50
+
51
+
52
+ def compute_model_score(model_name):
53
+ results_dir = "results"
54
+ model_dir = os.path.join(results_dir, model_name)
55
+
56
+ scores = []
57
+
58
+ # Get scores for clustering tasks
59
+ for task in TASKS_CLUSTERING:
60
+ task_file = os.path.join(model_dir, f"{task}.json")
61
+ with open(task_file, 'r') as f:
62
+ data = json.load(f)
63
+ v_measure = data['test']['v_measure']
64
+ scores.append(v_measure)
65
+
66
+ # Get scores for pair classification tasks
67
+ for task in TASKS_PAIR_CLASSIFICATION:
68
+ task_file = os.path.join(model_dir, f"{task}.json")
69
+ with open(task_file, 'r') as f:
70
+ data = json.load(f)
71
+ max_ap = data['test']['max']['ap']
72
+ scores.append(max_ap)
73
+
74
+ # Compute average score
75
+ average_score = sum(scores) / len(scores)
76
+ return average_score
77
+
78
+
79
+ # score = compute_model_score("ModelA")
80
 
81
  # Create Gradio interface
82
  iface = gr.Interface(fn=display_table, live=True, inputs=[], outputs="html")
83
 
84
  iface.launch()
 
run_mteb.py ADDED
File without changes