Clémentine commited on
Commit
a33e66d
1 Parent(s): 1b7afb7

look at model info if not in request file

Browse files
src/auto_leaderboard/model_metadata_type.py CHANGED
@@ -12,18 +12,13 @@ class ModelInfo:
12
  name: str
13
  symbol: str # emoji
14
 
15
- model_type_symbols = {
16
- "fine-tuned": "🔶",
17
- "pretrained": "🟢",
18
- "RL-tuned": "🟦",
19
- "instruction-tuned": "⭕",
20
- }
21
 
22
  class ModelType(Enum):
23
  PT = ModelInfo(name="pretrained", symbol="🟢")
24
  FT = ModelInfo(name="fine-tuned", symbol="🔶")
25
  IFT = ModelInfo(name="instruction-tuned", symbol="⭕")
26
  RL = ModelInfo(name="RL-tuned", symbol="🟦")
 
27
 
28
  def to_str(self, separator = " "):
29
  return f"{self.value.symbol}{separator}{self.value.name}"
@@ -547,20 +542,39 @@ TYPE_METADATA: Dict[str, ModelType] = {
547
  }
548
 
549
 
 
 
 
 
 
 
 
 
 
 
 
 
550
  def get_model_type(leaderboard_data: List[dict]):
551
  for model_data in leaderboard_data:
552
- # Todo @clefourrier once requests are connected with results
553
- # Stored information
554
- request_file = os.path.join("eval-queue", model_data["model_name_for_query"] + "_eval_request_*" + ".json")
555
- request_file = glob.glob(request_file)
556
 
557
- if len(request_file) == 0:
 
 
 
 
 
 
 
 
 
 
 
558
  model_data[AutoEvalColumn.model_type.name] = ""
559
  model_data[AutoEvalColumn.model_type_symbol.name] = ""
560
  continue
561
 
562
- request_file = request_file[0]
563
-
564
  try:
565
  with open(request_file, "r") as f:
566
  request = json.load(f)
@@ -571,9 +585,13 @@ def get_model_type(leaderboard_data: List[dict]):
571
  try:
572
  with open(request_file, "r") as f:
573
  request = json.load(f)
574
- model_type = request["model_type"]
575
- model_data[AutoEvalColumn.model_type.name] = model_type
576
- model_data[AutoEvalColumn.model_type_symbol.name] = model_type_symbols[model_type] + ("🔺" if is_delta else "")
577
- except Exception:
578
- model_data[AutoEvalColumn.model_type.name] = "Unknown, add type to request file!"
579
- model_data[AutoEvalColumn.model_type_symbol.name] = "?"
 
 
 
 
 
12
  name: str
13
  symbol: str # emoji
14
 
 
 
 
 
 
 
15
 
16
  class ModelType(Enum):
17
  PT = ModelInfo(name="pretrained", symbol="🟢")
18
  FT = ModelInfo(name="fine-tuned", symbol="🔶")
19
  IFT = ModelInfo(name="instruction-tuned", symbol="⭕")
20
  RL = ModelInfo(name="RL-tuned", symbol="🟦")
21
+ Unknown = ModelInfo(name="Unknown, add type to request file!", symbol="?")
22
 
23
  def to_str(self, separator = " "):
24
  return f"{self.value.symbol}{separator}{self.value.name}"
 
542
  }
543
 
544
 
545
+ def model_type_from_str(type):
546
+ if "fine-tuned" in type or "🔶" in type:
547
+ return ModelType.FT
548
+ if "pretrained" in type or "🟢" in type:
549
+ return ModelType.PT
550
+ if "RL-tuned" in type or "🟦" in type:
551
+ return ModelType.RL
552
+ if "instruction-tuned" in type or "⭕" in type:
553
+ return ModelType.IFT
554
+ return ModelType.Unknown
555
+
556
+
557
  def get_model_type(leaderboard_data: List[dict]):
558
  for model_data in leaderboard_data:
559
+ request_files = os.path.join("eval-queue", model_data["model_name_for_query"] + "_eval_request_*" + ".json")
560
+ request_files = glob.glob(request_files)
 
 
561
 
562
+ request_file = ""
563
+ if len(request_files) == 1:
564
+ request_file = request_files[0]
565
+ elif len(request_files) > 1:
566
+ request_files = sorted(request_files, reverse=True)
567
+ for tmp_request_file in request_files:
568
+ with open(tmp_request_file, "r") as f:
569
+ req_content = json.load(f)
570
+ if req_content["status"] == "FINISHED" and req_content["precision"] == model_data["Precision"].split(".")[-1]:
571
+ request_file = tmp_request_file
572
+
573
+ if request_file == "":
574
  model_data[AutoEvalColumn.model_type.name] = ""
575
  model_data[AutoEvalColumn.model_type_symbol.name] = ""
576
  continue
577
 
 
 
578
  try:
579
  with open(request_file, "r") as f:
580
  request = json.load(f)
 
585
  try:
586
  with open(request_file, "r") as f:
587
  request = json.load(f)
588
+ model_type = model_type_from_str(request["model_type"])
589
+ model_data[AutoEvalColumn.model_type.name] = model_type.value.name
590
+ model_data[AutoEvalColumn.model_type_symbol.name] = model_type.value.symbol + ("🔺" if is_delta else "")
591
+ except KeyError:
592
+ if model_data["model_name_for_query"] in TYPE_METADATA:
593
+ model_data[AutoEvalColumn.model_type.name] = TYPE_METADATA[model_data["model_name_for_query"]].value.name
594
+ model_data[AutoEvalColumn.model_type_symbol.name] = TYPE_METADATA[model_data["model_name_for_query"]].value.symbol + ("🔺" if is_delta else "")
595
+ else:
596
+ model_data[AutoEvalColumn.model_type.name] = ModelType.Unknown.value.name
597
+ model_data[AutoEvalColumn.model_type_symbol.name] = ModelType.Unknown.value.symbol