Spaces:
Running
on
Zero
Running
on
Zero
Update arena_elo/elo_rating/clean_battle_data.py
Browse files
arena_elo/elo_rating/clean_battle_data.py
CHANGED
|
@@ -21,42 +21,6 @@ from .basic_stats import get_log_files, NUM_SERVERS, LOG_ROOT_DIR
|
|
| 21 |
from .utils import detect_language, get_time_stamp_from_date
|
| 22 |
|
| 23 |
VOTES = ["tievote", "leftvote", "rightvote", "bothbad_vote"]
|
| 24 |
-
IDENTITY_WORDS = [
|
| 25 |
-
"vicuna",
|
| 26 |
-
"lmsys",
|
| 27 |
-
"koala",
|
| 28 |
-
"uc berkeley",
|
| 29 |
-
"open assistant",
|
| 30 |
-
"laion",
|
| 31 |
-
"chatglm",
|
| 32 |
-
"chatgpt",
|
| 33 |
-
"gpt-4",
|
| 34 |
-
"openai",
|
| 35 |
-
"anthropic",
|
| 36 |
-
"claude",
|
| 37 |
-
"bard",
|
| 38 |
-
"palm",
|
| 39 |
-
"lamda",
|
| 40 |
-
"google",
|
| 41 |
-
"llama",
|
| 42 |
-
"qianwan",
|
| 43 |
-
"alibaba",
|
| 44 |
-
"mistral",
|
| 45 |
-
"zhipu",
|
| 46 |
-
"KEG lab",
|
| 47 |
-
"01.AI",
|
| 48 |
-
"AI2",
|
| 49 |
-
"Tülu",
|
| 50 |
-
"Tulu",
|
| 51 |
-
"NETWORK ERROR DUE TO HIGH TRAFFIC. PLEASE REGENERATE OR REFRESH THIS PAGE.",
|
| 52 |
-
"$MODERATION$ YOUR INPUT VIOLATES OUR CONTENT MODERATION GUIDELINES.",
|
| 53 |
-
"API REQUEST ERROR. Please increase the number of max tokens.",
|
| 54 |
-
"**API REQUEST ERROR** Reason: The response was blocked.",
|
| 55 |
-
"**API REQUEST ERROR**",
|
| 56 |
-
]
|
| 57 |
-
|
| 58 |
-
for i in range(len(IDENTITY_WORDS)):
|
| 59 |
-
IDENTITY_WORDS[i] = IDENTITY_WORDS[i].lower()
|
| 60 |
|
| 61 |
def parse_model_name(model_name):
|
| 62 |
return NotImplementedError()
|
|
@@ -79,23 +43,12 @@ def to_openai_format(messages):
|
|
| 79 |
|
| 80 |
|
| 81 |
def replace_model_name(old_name, tstamp):
|
| 82 |
-
|
| 83 |
replace_dict = {
|
| 84 |
-
"bard": "palm-2",
|
| 85 |
-
"claude-v1": "claude-1",
|
| 86 |
-
"claude-instant-v1": "claude-instant-1",
|
| 87 |
-
"oasst-sft-1-pythia-12b": "oasst-pythia-12b",
|
| 88 |
-
"claude-2": "claude-2.0",
|
| 89 |
"PlayGroundV2": "PlayGround V2",
|
| 90 |
"PlayGroundV2.5": "PlayGround V2.5",
|
| 91 |
"FluxTimestep": "FLUX1schnell",
|
| 92 |
"FluxGuidance": "FLUX1dev"
|
| 93 |
}
|
| 94 |
-
if old_name in ["gpt-4", "gpt-3.5-turbo"]:
|
| 95 |
-
if tstamp > 1687849200:
|
| 96 |
-
old_name += "-0613"
|
| 97 |
-
else:
|
| 98 |
-
old_name += "-0314"
|
| 99 |
if old_name in replace_dict:
|
| 100 |
old_name = replace_dict[old_name]
|
| 101 |
if "Flux" in old_name:
|
|
@@ -198,32 +151,6 @@ def clean_battle_data(
|
|
| 198 |
print(f"Model names mismatch: {models_public} vs {models_hidden}")
|
| 199 |
ct_invalid += 1
|
| 200 |
continue
|
| 201 |
-
|
| 202 |
-
# # Detect langauge
|
| 203 |
-
# state = row["states"][0]
|
| 204 |
-
# if state["offset"] >= len(state["messages"]):
|
| 205 |
-
# ct_invalid += 1
|
| 206 |
-
# continue
|
| 207 |
-
# lang_code = detect_language(state["messages"][state["offset"]][1])
|
| 208 |
-
|
| 209 |
-
# # Drop conversations if the model names are leaked
|
| 210 |
-
# leaked_identity = False
|
| 211 |
-
# messages = ""
|
| 212 |
-
# for i in range(2):
|
| 213 |
-
# state = row["states"][i]
|
| 214 |
-
# for turn_idx, (role, msg) in enumerate(
|
| 215 |
-
# state["messages"][state["offset"] :]
|
| 216 |
-
# ):
|
| 217 |
-
# if msg:
|
| 218 |
-
# messages += msg.lower()
|
| 219 |
-
# for word in IDENTITY_WORDS:
|
| 220 |
-
# if word in messages:
|
| 221 |
-
# leaked_identity = True
|
| 222 |
-
# break
|
| 223 |
-
|
| 224 |
-
# if leaked_identity:
|
| 225 |
-
# ct_leaked_identity += 1
|
| 226 |
-
# continue
|
| 227 |
|
| 228 |
def preprocess_model_name(m):
|
| 229 |
if m == "Playground v2":
|
|
@@ -239,7 +166,6 @@ def clean_battle_data(
|
|
| 239 |
for _model in models:
|
| 240 |
try:
|
| 241 |
platform, model_name, task = _model.split("_")
|
| 242 |
-
#platform, model_name, task = parse_model_name(_model)
|
| 243 |
except ValueError:
|
| 244 |
valid = False
|
| 245 |
break
|
|
@@ -251,21 +177,13 @@ def clean_battle_data(
|
|
| 251 |
continue
|
| 252 |
for i, _model in enumerate(models):
|
| 253 |
platform, model_name, task = _model.split("_")
|
| 254 |
-
#platform, model_name, task = parse_model_name(_model)
|
| 255 |
models[i] = model_name
|
| 256 |
-
|
| 257 |
-
# if not all(x.startswith("imagenhub_") and x.endswith("_edition") for x in models):
|
| 258 |
-
# # print(f"Invalid model names: {models}")
|
| 259 |
-
# ct_invalid += 1
|
| 260 |
-
# continue
|
| 261 |
-
|
| 262 |
-
# models = [x[len("imagenhub_"):-len("_edition")] for x in models]
|
| 263 |
elif task_name == "t2i_generation":
|
| 264 |
valid = True
|
| 265 |
for _model in models:
|
| 266 |
try:
|
| 267 |
platform, model_name, task = _model.split("_")
|
| 268 |
-
#platform, model_name, task = parse_model_name(_model)
|
| 269 |
except ValueError:
|
| 270 |
valid = False
|
| 271 |
break
|
|
@@ -277,24 +195,13 @@ def clean_battle_data(
|
|
| 277 |
continue
|
| 278 |
for i, _model in enumerate(models):
|
| 279 |
platform, model_name, task = _model.split("_")
|
| 280 |
-
#platform, model_name, task = parse_model_name(_model)
|
| 281 |
models[i] = model_name
|
| 282 |
-
# if not all("playground" in x.lower() or (x.startswith("imagenhub_") and x.endswith("_generation")) for x in models):
|
| 283 |
-
# print(f"Invalid model names: {models}")
|
| 284 |
-
# ct_invalid += 1
|
| 285 |
-
# continue
|
| 286 |
-
# models = [x[len("imagenhub_"):-len("_generation")] for x in models]
|
| 287 |
-
# for i, model_name in enumerate(models):
|
| 288 |
-
# mode
|
| 289 |
-
# if model_name.startswith("imagenhub_"):
|
| 290 |
-
# models[i] = model_name[len("imagenhub_"):-len("_generation")]
|
| 291 |
|
| 292 |
elif task_name == "video_generation":
|
| 293 |
valid = True
|
| 294 |
for _model in models:
|
| 295 |
try:
|
| 296 |
platform, model_name, task = _model.split("_")
|
| 297 |
-
#platform, model_name, task = parse_model_name(_model)
|
| 298 |
except ValueError:
|
| 299 |
valid = False
|
| 300 |
break
|
|
@@ -306,32 +213,17 @@ def clean_battle_data(
|
|
| 306 |
continue
|
| 307 |
for i, _model in enumerate(models):
|
| 308 |
platform, model_name, task = _model.split("_")
|
| 309 |
-
#platform, model_name, task = parse_model_name(_model)
|
| 310 |
models[i] = model_name
|
| 311 |
|
| 312 |
else:
|
| 313 |
raise ValueError(f"Invalid task_name: {task_name}")
|
| 314 |
|
| 315 |
-
# if "Flux" in models[0] or "Flux" in models[1]:
|
| 316 |
-
# print(f"Invalid model names: {models}")
|
| 317 |
-
# exit(1)
|
| 318 |
models = [replace_model_name(m, row["tstamp"]) for m in models]
|
| 319 |
|
| 320 |
# Exclude certain models
|
| 321 |
if exclude_model_names and any(x in exclude_model_names for x in models):
|
| 322 |
ct_invalid += 1
|
| 323 |
continue
|
| 324 |
-
|
| 325 |
-
# if models[0] not in model_infos or models[1] not in model_infos:
|
| 326 |
-
# continue
|
| 327 |
-
|
| 328 |
-
# # Exclude votes before the starting date
|
| 329 |
-
# if model_infos and (model_infos[models[0]]["starting_from"] > row["tstamp"] or model_infos[models[1]]["starting_from"] > row["tstamp"]):
|
| 330 |
-
# print(f"Invalid vote before the valid starting date for {models[0]} and {models[1]}")
|
| 331 |
-
# ct_invalid += 1
|
| 332 |
-
# continue
|
| 333 |
-
|
| 334 |
-
|
| 335 |
|
| 336 |
if mode == "conv_release":
|
| 337 |
# assert the two images are the same
|
|
@@ -357,12 +249,6 @@ def clean_battle_data(
|
|
| 357 |
|
| 358 |
|
| 359 |
question_id = row["states"][0]["conv_id"]
|
| 360 |
-
# conversation_a = to_openai_format(
|
| 361 |
-
# row["states"][0]["messages"][row["states"][0]["offset"] :]
|
| 362 |
-
# )
|
| 363 |
-
# conversation_b = to_openai_format(
|
| 364 |
-
# row["states"][1]["messages"][row["states"][1]["offset"] :]
|
| 365 |
-
# )
|
| 366 |
|
| 367 |
ip = row["ip"]
|
| 368 |
if ip not in all_ips:
|
|
@@ -386,11 +272,7 @@ def clean_battle_data(
|
|
| 386 |
model_b=models[1],
|
| 387 |
winner=convert_type[row["type"]],
|
| 388 |
judge=f"arena_user_{user_id}",
|
| 389 |
-
# conversation_a=conversation_a,
|
| 390 |
-
# conversation_b=conversation_b,
|
| 391 |
-
# turn=len(conversation_a) // 2,
|
| 392 |
anony=anony,
|
| 393 |
-
# language=lang_code,
|
| 394 |
tstamp=row["tstamp"],
|
| 395 |
)
|
| 396 |
)
|
|
@@ -458,14 +340,6 @@ if __name__ == "__main__":
|
|
| 458 |
print(battles[i])
|
| 459 |
output = f"clean_battle_{args.task_name}_{cutoff_date}.json"
|
| 460 |
elif args.mode == "conv_release":
|
| 461 |
-
# new_battles = []
|
| 462 |
-
# for x in battles:
|
| 463 |
-
# if not x["anony"]:
|
| 464 |
-
# continue
|
| 465 |
-
# for key in []:
|
| 466 |
-
# del x[key]
|
| 467 |
-
# new_battles.append(x)
|
| 468 |
-
# battles = new_battles
|
| 469 |
output = f"clean_battle_{args.task_name}_conv_{cutoff_date}.json"
|
| 470 |
|
| 471 |
with open(output, "w") as fout:
|
|
|
|
| 21 |
from .utils import detect_language, get_time_stamp_from_date
|
| 22 |
|
| 23 |
VOTES = ["tievote", "leftvote", "rightvote", "bothbad_vote"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
def parse_model_name(model_name):
|
| 26 |
return NotImplementedError()
|
|
|
|
| 43 |
|
| 44 |
|
| 45 |
def replace_model_name(old_name, tstamp):
|
|
|
|
| 46 |
replace_dict = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
"PlayGroundV2": "PlayGround V2",
|
| 48 |
"PlayGroundV2.5": "PlayGround V2.5",
|
| 49 |
"FluxTimestep": "FLUX1schnell",
|
| 50 |
"FluxGuidance": "FLUX1dev"
|
| 51 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
if old_name in replace_dict:
|
| 53 |
old_name = replace_dict[old_name]
|
| 54 |
if "Flux" in old_name:
|
|
|
|
| 151 |
print(f"Model names mismatch: {models_public} vs {models_hidden}")
|
| 152 |
ct_invalid += 1
|
| 153 |
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
|
| 155 |
def preprocess_model_name(m):
|
| 156 |
if m == "Playground v2":
|
|
|
|
| 166 |
for _model in models:
|
| 167 |
try:
|
| 168 |
platform, model_name, task = _model.split("_")
|
|
|
|
| 169 |
except ValueError:
|
| 170 |
valid = False
|
| 171 |
break
|
|
|
|
| 177 |
continue
|
| 178 |
for i, _model in enumerate(models):
|
| 179 |
platform, model_name, task = _model.split("_")
|
|
|
|
| 180 |
models[i] = model_name
|
| 181 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
elif task_name == "t2i_generation":
|
| 183 |
valid = True
|
| 184 |
for _model in models:
|
| 185 |
try:
|
| 186 |
platform, model_name, task = _model.split("_")
|
|
|
|
| 187 |
except ValueError:
|
| 188 |
valid = False
|
| 189 |
break
|
|
|
|
| 195 |
continue
|
| 196 |
for i, _model in enumerate(models):
|
| 197 |
platform, model_name, task = _model.split("_")
|
|
|
|
| 198 |
models[i] = model_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
elif task_name == "video_generation":
|
| 201 |
valid = True
|
| 202 |
for _model in models:
|
| 203 |
try:
|
| 204 |
platform, model_name, task = _model.split("_")
|
|
|
|
| 205 |
except ValueError:
|
| 206 |
valid = False
|
| 207 |
break
|
|
|
|
| 213 |
continue
|
| 214 |
for i, _model in enumerate(models):
|
| 215 |
platform, model_name, task = _model.split("_")
|
|
|
|
| 216 |
models[i] = model_name
|
| 217 |
|
| 218 |
else:
|
| 219 |
raise ValueError(f"Invalid task_name: {task_name}")
|
| 220 |
|
|
|
|
|
|
|
|
|
|
| 221 |
models = [replace_model_name(m, row["tstamp"]) for m in models]
|
| 222 |
|
| 223 |
# Exclude certain models
|
| 224 |
if exclude_model_names and any(x in exclude_model_names for x in models):
|
| 225 |
ct_invalid += 1
|
| 226 |
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
|
| 228 |
if mode == "conv_release":
|
| 229 |
# assert the two images are the same
|
|
|
|
| 249 |
|
| 250 |
|
| 251 |
question_id = row["states"][0]["conv_id"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
ip = row["ip"]
|
| 254 |
if ip not in all_ips:
|
|
|
|
| 272 |
model_b=models[1],
|
| 273 |
winner=convert_type[row["type"]],
|
| 274 |
judge=f"arena_user_{user_id}",
|
|
|
|
|
|
|
|
|
|
| 275 |
anony=anony,
|
|
|
|
| 276 |
tstamp=row["tstamp"],
|
| 277 |
)
|
| 278 |
)
|
|
|
|
| 340 |
print(battles[i])
|
| 341 |
output = f"clean_battle_{args.task_name}_{cutoff_date}.json"
|
| 342 |
elif args.mode == "conv_release":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
output = f"clean_battle_{args.task_name}_conv_{cutoff_date}.json"
|
| 344 |
|
| 345 |
with open(output, "w") as fout:
|