Spaces:
Sleeping
Sleeping
1. 평가점수 0 은 평가 없음으로 처리한다. 2. 컬럼정리 및 순번 추가 3. About 페이지
Browse files- app.py +6 -3
- src/about.py +13 -4
- src/display/utils.py +0 -134
- src/leaderboard/read_evals.py +0 -196
app.py
CHANGED
@@ -14,7 +14,12 @@ def get_evaluation():
|
|
14 |
response = requests.get("http://aim100.qinference.com/api/leaderboard/list")
|
15 |
data_json = response.json()
|
16 |
df = pd.DataFrame(data_json)
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
|
20 |
leaderboard = gr.Blocks(css=custom_css)
|
@@ -24,8 +29,6 @@ with leaderboard:
|
|
24 |
|
25 |
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
26 |
with gr.TabItem("🏅 LLM Benchmark", elem_id="llm-benchmark-tab-table", id=0):
|
27 |
-
# df = get_evaluation()
|
28 |
-
# dataList = get_evaluation()
|
29 |
leaderboard_table = gr.components.Dataframe(
|
30 |
value=get_evaluation(),
|
31 |
elem_id="leaderboard-table",
|
|
|
14 |
response = requests.get("http://aim100.qinference.com/api/leaderboard/list")
|
15 |
data_json = response.json()
|
16 |
df = pd.DataFrame(data_json)
|
17 |
+
for col in df.columns:
|
18 |
+
df.loc[df[col] == 0, col] = '-'
|
19 |
+
df.insert(0, 'No', df.reset_index().index + 1)
|
20 |
+
ret = df.drop(columns='nodeSeq').rename(columns={'modelName': 'Model'})
|
21 |
+
ret.columns = [x.capitalize() for x in ret.columns]
|
22 |
+
return ret
|
23 |
|
24 |
|
25 |
leaderboard = gr.Blocks(css=custom_css)
|
|
|
29 |
|
30 |
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
31 |
with gr.TabItem("🏅 LLM Benchmark", elem_id="llm-benchmark-tab-table", id=0):
|
|
|
|
|
32 |
leaderboard_table = gr.components.Dataframe(
|
33 |
value=get_evaluation(),
|
34 |
elem_id="leaderboard-table",
|
src/about.py
CHANGED
@@ -26,15 +26,24 @@ TITLE = """<h1 align="center" id="space-title">AIM100 Leaderboard</h1>"""
|
|
26 |
# What does your leaderboard evaluate?
|
27 |
INTRODUCTION_TEXT = """
|
28 |
Leaderboard of AIM100
|
29 |
-
(AI Model 1 vs 100 Colosseum)
|
30 |
"""
|
31 |
|
32 |
# Which evaluations are you running? how can people reproduce what you have?
|
33 |
LLM_BENCHMARKS_TEXT = f"""
|
34 |
-
##
|
|
|
35 |
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
"""
|
40 |
|
|
|
26 |
# What does your leaderboard evaluate?
|
27 |
INTRODUCTION_TEXT = """
|
28 |
Leaderboard of AIM100
|
|
|
29 |
"""
|
30 |
|
31 |
# Which evaluations are you running? how can people reproduce what you have?
|
32 |
LLM_BENCHMARKS_TEXT = f"""
|
33 |
+
## 🔥 About This Leaderboard
|
34 |
+
This leaderboard is based on evaluations made in **AIM100**.
|
35 |
|
36 |
+
You can play with chatbot colosseum in **AIM100**.
|
37 |
+
|
38 |
+
|
39 |
+
## 🎢 About AIM100 Colosseum
|
40 |
+
http://aim100.qinference.com
|
41 |
+
|
42 |
+
AIM100 is a playground with over 100 LLM chatbot.
|
43 |
+
It is like a colosseum that concept by 1 vs 100 battle.
|
44 |
+
Anyone can play with hundreds chatbots.
|
45 |
+
|
46 |
+
See around and enjoy!
|
47 |
|
48 |
"""
|
49 |
|
src/display/utils.py
DELETED
@@ -1,134 +0,0 @@
|
|
1 |
-
from dataclasses import dataclass, make_dataclass
|
2 |
-
from enum import Enum
|
3 |
-
|
4 |
-
import pandas as pd
|
5 |
-
|
6 |
-
from src.about import Tasks
|
7 |
-
|
8 |
-
|
9 |
-
def fields(raw_class):
|
10 |
-
return [v for k, v in raw_class.__dict__.items() if k[:2] != "__" and k[-2:] != "__"]
|
11 |
-
|
12 |
-
|
13 |
-
# These classes are for user facing column names,
|
14 |
-
# to avoid having to change them all around the code
|
15 |
-
# when a modif is needed
|
16 |
-
@dataclass
|
17 |
-
class ColumnContent:
|
18 |
-
name: str
|
19 |
-
type: str
|
20 |
-
displayed_by_default: bool
|
21 |
-
hidden: bool = False
|
22 |
-
never_hidden: bool = False
|
23 |
-
|
24 |
-
|
25 |
-
## Leaderboard columns
|
26 |
-
auto_eval_column_dict = [["modelName", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)],
|
27 |
-
["total", ColumnContent, ColumnContent("Average ⬆️", "number", True)],
|
28 |
-
["inference", ColumnContent, ColumnContent("Architecture", "str", False)],
|
29 |
-
["grammar", ColumnContent, ColumnContent("Grammar", "number", False, True)],
|
30 |
-
["understanding", ColumnContent, ColumnContent("Understanding", "number", False)],
|
31 |
-
["coding", ColumnContent, ColumnContent("Coding", "number", False)],
|
32 |
-
["math", ColumnContent, ColumnContent("Math", "number", False)],
|
33 |
-
["writing", ColumnContent, ColumnContent("Write", "number", False)],
|
34 |
-
["etc", ColumnContent, ColumnContent("ETC", "number", False)]]
|
35 |
-
# Init
|
36 |
-
|
37 |
-
# We use make dataclass to dynamically fill the scores from Tasks
|
38 |
-
AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
|
39 |
-
|
40 |
-
|
41 |
-
## For the queue columns in the submission tab
|
42 |
-
@dataclass(frozen=True)
|
43 |
-
class EvalQueueColumn: # Queue column
|
44 |
-
model = ColumnContent("model", "markdown", True)
|
45 |
-
revision = ColumnContent("revision", "str", True)
|
46 |
-
private = ColumnContent("private", "bool", True)
|
47 |
-
precision = ColumnContent("precision", "str", True)
|
48 |
-
weight_type = ColumnContent("weight_type", "str", "Original")
|
49 |
-
status = ColumnContent("status", "str", True)
|
50 |
-
|
51 |
-
|
52 |
-
## All the model information that we might need
|
53 |
-
@dataclass
|
54 |
-
class ModelDetails:
|
55 |
-
name: str
|
56 |
-
display_name: str = ""
|
57 |
-
symbol: str = "" # emoji
|
58 |
-
|
59 |
-
|
60 |
-
class ModelType(Enum):
|
61 |
-
PT = ModelDetails(name="pretrained", symbol="🟢")
|
62 |
-
FT = ModelDetails(name="fine-tuned", symbol="🔶")
|
63 |
-
IFT = ModelDetails(name="instruction-tuned", symbol="⭕")
|
64 |
-
RL = ModelDetails(name="RL-tuned", symbol="🟦")
|
65 |
-
Unknown = ModelDetails(name="", symbol="?")
|
66 |
-
|
67 |
-
def to_str(self, separator=" "):
|
68 |
-
return f"{self.value.symbol}{separator}{self.value.name}"
|
69 |
-
|
70 |
-
@staticmethod
|
71 |
-
def from_str(type):
|
72 |
-
if "fine-tuned" in type or "🔶" in type:
|
73 |
-
return ModelType.FT
|
74 |
-
if "pretrained" in type or "🟢" in type:
|
75 |
-
return ModelType.PT
|
76 |
-
if "RL-tuned" in type or "🟦" in type:
|
77 |
-
return ModelType.RL
|
78 |
-
if "instruction-tuned" in type or "⭕" in type:
|
79 |
-
return ModelType.IFT
|
80 |
-
return ModelType.Unknown
|
81 |
-
|
82 |
-
|
83 |
-
class WeightType(Enum):
|
84 |
-
Adapter = ModelDetails("Adapter")
|
85 |
-
Original = ModelDetails("Original")
|
86 |
-
Delta = ModelDetails("Delta")
|
87 |
-
|
88 |
-
|
89 |
-
class Precision(Enum):
|
90 |
-
float16 = ModelDetails("float16")
|
91 |
-
bfloat16 = ModelDetails("bfloat16")
|
92 |
-
float32 = ModelDetails("float32")
|
93 |
-
# qt_8bit = ModelDetails("8bit")
|
94 |
-
# qt_4bit = ModelDetails("4bit")
|
95 |
-
# qt_GPTQ = ModelDetails("GPTQ")
|
96 |
-
Unknown = ModelDetails("?")
|
97 |
-
|
98 |
-
def from_str(precision):
|
99 |
-
if precision in ["torch.float16", "float16"]:
|
100 |
-
return Precision.float16
|
101 |
-
if precision in ["torch.bfloat16", "bfloat16"]:
|
102 |
-
return Precision.bfloat16
|
103 |
-
if precision in ["float32"]:
|
104 |
-
return Precision.float32
|
105 |
-
# if precision in ["8bit"]:
|
106 |
-
# return Precision.qt_8bit
|
107 |
-
# if precision in ["4bit"]:
|
108 |
-
# return Precision.qt_4bit
|
109 |
-
# if precision in ["GPTQ", "None"]:
|
110 |
-
# return Precision.qt_GPTQ
|
111 |
-
return Precision.Unknown
|
112 |
-
|
113 |
-
|
114 |
-
# Column selection
|
115 |
-
COLS = [c.name for c in fields(AutoEvalColumn) if not c.hidden]
|
116 |
-
TYPES = [c.type for c in fields(AutoEvalColumn) if not c.hidden]
|
117 |
-
COLS_LITE = [c.name for c in fields(AutoEvalColumn) if c.displayed_by_default and not c.hidden]
|
118 |
-
TYPES_LITE = [c.type for c in fields(AutoEvalColumn) if c.displayed_by_default and not c.hidden]
|
119 |
-
|
120 |
-
EVAL_COLS = [c.name for c in fields(EvalQueueColumn)]
|
121 |
-
EVAL_TYPES = [c.type for c in fields(EvalQueueColumn)]
|
122 |
-
|
123 |
-
BENCHMARK_COLS = [t.value.col_name for t in Tasks]
|
124 |
-
|
125 |
-
NUMERIC_INTERVALS = {
|
126 |
-
"?": pd.Interval(-1, 0, closed="right"),
|
127 |
-
"~1.5": pd.Interval(0, 2, closed="right"),
|
128 |
-
"~3": pd.Interval(2, 4, closed="right"),
|
129 |
-
"~7": pd.Interval(4, 9, closed="right"),
|
130 |
-
"~13": pd.Interval(9, 20, closed="right"),
|
131 |
-
"~35": pd.Interval(20, 45, closed="right"),
|
132 |
-
"~60": pd.Interval(45, 70, closed="right"),
|
133 |
-
"70+": pd.Interval(70, 10000, closed="right"),
|
134 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/leaderboard/read_evals.py
DELETED
@@ -1,196 +0,0 @@
|
|
1 |
-
import glob
|
2 |
-
import json
|
3 |
-
import math
|
4 |
-
import os
|
5 |
-
from dataclasses import dataclass
|
6 |
-
|
7 |
-
import dateutil
|
8 |
-
import numpy as np
|
9 |
-
|
10 |
-
from src.display.formatting import make_clickable_model
|
11 |
-
from src.display.utils import AutoEvalColumn, ModelType, Tasks, Precision, WeightType
|
12 |
-
from src.submission.check_validity import is_model_on_hub
|
13 |
-
|
14 |
-
|
15 |
-
@dataclass
|
16 |
-
class EvalResult:
|
17 |
-
"""Represents one full evaluation. Built from a combination of the result and request file for a given run.
|
18 |
-
"""
|
19 |
-
eval_name: str # org_model_precision (uid)
|
20 |
-
full_model: str # org/model (path on hub)
|
21 |
-
org: str
|
22 |
-
model: str
|
23 |
-
revision: str # commit hash, "" if main
|
24 |
-
results: dict
|
25 |
-
precision: Precision = Precision.Unknown
|
26 |
-
model_type: ModelType = ModelType.Unknown # Pretrained, fine tuned, ...
|
27 |
-
weight_type: WeightType = WeightType.Original # Original or Adapter
|
28 |
-
architecture: str = "Unknown"
|
29 |
-
license: str = "?"
|
30 |
-
likes: int = 0
|
31 |
-
num_params: int = 0
|
32 |
-
date: str = "" # submission date of request file
|
33 |
-
still_on_hub: bool = False
|
34 |
-
|
35 |
-
@classmethod
|
36 |
-
def init_from_json_file(self, json_filepath):
|
37 |
-
"""Inits the result from the specific model result file"""
|
38 |
-
with open(json_filepath) as fp:
|
39 |
-
data = json.load(fp)
|
40 |
-
|
41 |
-
config = data.get("config")
|
42 |
-
|
43 |
-
# Precision
|
44 |
-
precision = Precision.from_str(config.get("model_dtype"))
|
45 |
-
|
46 |
-
# Get model and org
|
47 |
-
org_and_model = config.get("model_name", config.get("model_args", None))
|
48 |
-
org_and_model = org_and_model.split("/", 1)
|
49 |
-
|
50 |
-
if len(org_and_model) == 1:
|
51 |
-
org = None
|
52 |
-
model = org_and_model[0]
|
53 |
-
result_key = f"{model}_{precision.value.name}"
|
54 |
-
else:
|
55 |
-
org = org_and_model[0]
|
56 |
-
model = org_and_model[1]
|
57 |
-
result_key = f"{org}_{model}_{precision.value.name}"
|
58 |
-
full_model = "/".join(org_and_model)
|
59 |
-
|
60 |
-
still_on_hub, _, model_config = is_model_on_hub(
|
61 |
-
full_model, config.get("model_sha", "main"), trust_remote_code=True, test_tokenizer=False
|
62 |
-
)
|
63 |
-
architecture = "?"
|
64 |
-
if model_config is not None:
|
65 |
-
architectures = getattr(model_config, "architectures", None)
|
66 |
-
if architectures:
|
67 |
-
architecture = ";".join(architectures)
|
68 |
-
|
69 |
-
# Extract results available in this file (some results are split in several files)
|
70 |
-
results = {}
|
71 |
-
for task in Tasks:
|
72 |
-
task = task.value
|
73 |
-
|
74 |
-
# We average all scores of a given metric (not all metrics are present in all files)
|
75 |
-
accs = np.array([v.get(task.metric, None) for k, v in data["results"].items() if task.benchmark == k])
|
76 |
-
if accs.size == 0 or any([acc is None for acc in accs]):
|
77 |
-
continue
|
78 |
-
|
79 |
-
mean_acc = np.mean(accs) * 100.0
|
80 |
-
results[task.benchmark] = mean_acc
|
81 |
-
|
82 |
-
return self(
|
83 |
-
eval_name=result_key,
|
84 |
-
full_model=full_model,
|
85 |
-
org=org,
|
86 |
-
model=model,
|
87 |
-
results=results,
|
88 |
-
precision=precision,
|
89 |
-
revision= config.get("model_sha", ""),
|
90 |
-
still_on_hub=still_on_hub,
|
91 |
-
architecture=architecture
|
92 |
-
)
|
93 |
-
|
94 |
-
def update_with_request_file(self, requests_path):
|
95 |
-
"""Finds the relevant request file for the current model and updates info with it"""
|
96 |
-
request_file = get_request_file_for_model(requests_path, self.full_model, self.precision.value.name)
|
97 |
-
|
98 |
-
try:
|
99 |
-
with open(request_file, "r") as f:
|
100 |
-
request = json.load(f)
|
101 |
-
self.model_type = ModelType.from_str(request.get("model_type", ""))
|
102 |
-
self.weight_type = WeightType[request.get("weight_type", "Original")]
|
103 |
-
self.license = request.get("license", "?")
|
104 |
-
self.likes = request.get("likes", 0)
|
105 |
-
self.num_params = request.get("params", 0)
|
106 |
-
self.date = request.get("submitted_time", "")
|
107 |
-
except Exception:
|
108 |
-
print(f"Could not find request file for {self.org}/{self.model} with precision {self.precision.value.name}")
|
109 |
-
|
110 |
-
def to_dict(self):
|
111 |
-
"""Converts the Eval Result to a dict compatible with our dataframe display"""
|
112 |
-
average = sum([v for v in self.results.values() if v is not None]) / len(Tasks)
|
113 |
-
data_dict = {
|
114 |
-
"eval_name": self.eval_name, # not a column, just a save name,
|
115 |
-
AutoEvalColumn.precision.name: self.precision.value.name,
|
116 |
-
AutoEvalColumn.model_type.name: self.model_type.value.name,
|
117 |
-
AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,
|
118 |
-
AutoEvalColumn.weight_type.name: self.weight_type.value.name,
|
119 |
-
AutoEvalColumn.architecture.name: self.architecture,
|
120 |
-
AutoEvalColumn.model.name: make_clickable_model(self.full_model),
|
121 |
-
AutoEvalColumn.revision.name: self.revision,
|
122 |
-
AutoEvalColumn.average.name: average,
|
123 |
-
AutoEvalColumn.license.name: self.license,
|
124 |
-
AutoEvalColumn.likes.name: self.likes,
|
125 |
-
AutoEvalColumn.params.name: self.num_params,
|
126 |
-
AutoEvalColumn.still_on_hub.name: self.still_on_hub,
|
127 |
-
}
|
128 |
-
|
129 |
-
for task in Tasks:
|
130 |
-
data_dict[task.value.col_name] = self.results[task.value.benchmark]
|
131 |
-
|
132 |
-
return data_dict
|
133 |
-
|
134 |
-
|
135 |
-
def get_request_file_for_model(requests_path, model_name, precision):
|
136 |
-
"""Selects the correct request file for a given model. Only keeps runs tagged as FINISHED"""
|
137 |
-
request_files = os.path.join(
|
138 |
-
requests_path,
|
139 |
-
f"{model_name}_eval_request_*.json",
|
140 |
-
)
|
141 |
-
request_files = glob.glob(request_files)
|
142 |
-
|
143 |
-
# Select correct request file (precision)
|
144 |
-
request_file = ""
|
145 |
-
request_files = sorted(request_files, reverse=True)
|
146 |
-
for tmp_request_file in request_files:
|
147 |
-
with open(tmp_request_file, "r") as f:
|
148 |
-
req_content = json.load(f)
|
149 |
-
if (
|
150 |
-
req_content["status"] in ["FINISHED"]
|
151 |
-
and req_content["precision"] == precision.split(".")[-1]
|
152 |
-
):
|
153 |
-
request_file = tmp_request_file
|
154 |
-
return request_file
|
155 |
-
|
156 |
-
|
157 |
-
def get_raw_eval_results(results_path: str, requests_path: str) -> list[EvalResult]:
|
158 |
-
"""From the path of the results folder root, extract all needed info for results"""
|
159 |
-
model_result_filepaths = []
|
160 |
-
|
161 |
-
for root, _, files in os.walk(results_path):
|
162 |
-
# We should only have json files in model results
|
163 |
-
if len(files) == 0 or any([not f.endswith(".json") for f in files]):
|
164 |
-
continue
|
165 |
-
|
166 |
-
# Sort the files by date
|
167 |
-
try:
|
168 |
-
files.sort(key=lambda x: x.removesuffix(".json").removeprefix("results_")[:-7])
|
169 |
-
except dateutil.parser._parser.ParserError:
|
170 |
-
files = [files[-1]]
|
171 |
-
|
172 |
-
for file in files:
|
173 |
-
model_result_filepaths.append(os.path.join(root, file))
|
174 |
-
|
175 |
-
eval_results = {}
|
176 |
-
for model_result_filepath in model_result_filepaths:
|
177 |
-
# Creation of result
|
178 |
-
eval_result = EvalResult.init_from_json_file(model_result_filepath)
|
179 |
-
eval_result.update_with_request_file(requests_path)
|
180 |
-
|
181 |
-
# Store results of same eval together
|
182 |
-
eval_name = eval_result.eval_name
|
183 |
-
if eval_name in eval_results.keys():
|
184 |
-
eval_results[eval_name].results.update({k: v for k, v in eval_result.results.items() if v is not None})
|
185 |
-
else:
|
186 |
-
eval_results[eval_name] = eval_result
|
187 |
-
|
188 |
-
results = []
|
189 |
-
for v in eval_results.values():
|
190 |
-
try:
|
191 |
-
v.to_dict() # we test if the dict version is complete
|
192 |
-
results.append(v)
|
193 |
-
except KeyError: # not all eval values present
|
194 |
-
continue
|
195 |
-
|
196 |
-
return results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|