Clémentine commited on
Commit
28ee758
1 Parent(s): 4ccfada

upgrade file updater

Browse files
src/display/about.py CHANGED
@@ -1,6 +1,6 @@
1
  from src.display.utils import ModelType
2
 
3
- TITLE = """<h1 style="text-align:left;float:left; id="space-title">🤗 Open LLM Leaderboard</h1> Track, rank and evaluate open LLMs and chatbots"""
4
 
5
  INTRODUCTION_TEXT = """
6
  """
 
1
  from src.display.utils import ModelType
2
 
3
+ TITLE = """<h1 style="text-align:left;float:left; id="space-title">🤗 Open LLM Leaderboard</h1> <h3 style="text-align:left;float:left;> Track, rank and evaluate open LLMs and chatbots </h3>"""
4
 
5
  INTRODUCTION_TEXT = """
6
  """
src/scripts/update_all_request_files.py CHANGED
@@ -2,55 +2,89 @@ from huggingface_hub import ModelFilter, snapshot_download
2
  from huggingface_hub import ModelCard
3
 
4
  import json
 
5
  import time
6
 
7
  from src.submission.check_validity import is_model_on_hub, check_model_card, get_model_tags
8
- from src.envs import DYNAMIC_INFO_REPO, DYNAMIC_INFO_PATH, DYNAMIC_INFO_FILE_PATH, API, H4_TOKEN
9
-
10
- def update_models(file_path, models):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  """
12
  Search through all JSON files in the specified root folder and its subfolders,
13
  and update the likes key in JSON dict from value of input dict
14
  """
 
15
  with open(file_path, "r") as f:
16
  model_infos = json.load(f)
17
- for model_id, data in model_infos.items():
18
- if model_id not in models:
19
- data['still_on_hub'] = False
20
- data['likes'] = 0
21
- data['downloads'] = 0
22
- data['created_at'] = ""
23
- continue
24
-
25
- model_cfg = models[model_id]
26
- data['likes'] = model_cfg.likes
27
- data['downloads'] = model_cfg.downloads
28
- data['created_at'] = str(model_cfg.created_at)
29
- #data['params'] = get_model_size(model_cfg, data['precision'])
30
- data['license'] = model_cfg.card_data.license if model_cfg.card_data is not None else ""
31
-
32
- # Is the model still on the hub?
33
- model_name = model_id
34
- if model_cfg.card_data is not None and model_cfg.card_data.base_model is not None:
35
- if isinstance(model_cfg.card_data.base_model, str):
36
- model_name = model_cfg.card_data.base_model # for adapters, we look at the parent model
37
- still_on_hub, _, _ = is_model_on_hub(
38
- model_name=model_name, revision=data.get("revision"), trust_remote_code=True, test_tokenizer=False, token=H4_TOKEN
 
 
 
 
 
 
39
  )
40
- # If the model doesn't have a model card or a license, we consider it's deleted
41
- if still_on_hub:
42
- try:
43
- status, _, model_card = check_model_card(model_id)
44
- if status is False:
45
- still_on_hub = False
46
- except Exception:
47
- model_card = None
48
- still_on_hub = False
49
- data['still_on_hub'] = still_on_hub
50
-
51
- tags = get_model_tags(model_card, model_id) if still_on_hub else []
52
-
53
- data["tags"] = tags
54
 
55
  with open(file_path, 'w') as f:
56
  json.dump(model_infos, f, indent=2)
 
2
  from huggingface_hub import ModelCard
3
 
4
  import json
5
+ import os
6
  import time
7
 
8
  from src.submission.check_validity import is_model_on_hub, check_model_card, get_model_tags
9
+ from src.envs import QUEUE_REPO, EVAL_REQUESTS_PATH, DYNAMIC_INFO_REPO, DYNAMIC_INFO_PATH, DYNAMIC_INFO_FILE_PATH, API, H4_TOKEN
10
+
11
+ def update_one_model(model_id, data, models_on_the_hub):
12
+ # Model no longer on the hub at all
13
+ if model_id not in models_on_the_hub:
14
+ data['still_on_hub'] = False
15
+ data['likes'] = 0
16
+ data['downloads'] = 0
17
+ data['created_at'] = ""
18
+ return data
19
+
20
+ # Grabbing model parameters
21
+ model_cfg = models_on_the_hub[model_id]
22
+ data['likes'] = model_cfg.likes
23
+ data['downloads'] = model_cfg.downloads
24
+ data['created_at'] = str(model_cfg.created_at)
25
+ data['license'] = model_cfg.card_data.license if model_cfg.card_data is not None else ""
26
+
27
+ # Grabbing model details
28
+ model_name = model_id
29
+ if model_cfg.card_data is not None and model_cfg.card_data.base_model is not None:
30
+ if isinstance(model_cfg.card_data.base_model, str):
31
+ model_name = model_cfg.card_data.base_model # for adapters, we look at the parent model
32
+ still_on_hub, _, _ = is_model_on_hub(
33
+ model_name=model_name, revision=data.get("revision"), trust_remote_code=True, test_tokenizer=False, token=H4_TOKEN
34
+ )
35
+ # If the model doesn't have a model card or a license, we consider it's deleted
36
+ if still_on_hub:
37
+ try:
38
+ status, _, model_card = check_model_card(model_id)
39
+ if status is False:
40
+ still_on_hub = False
41
+ except Exception:
42
+ model_card = None
43
+ still_on_hub = False
44
+ data['still_on_hub'] = still_on_hub
45
+
46
+ tags = get_model_tags(model_card, model_id) if still_on_hub else []
47
+
48
+ data["tags"] = tags
49
+ return data
50
+
51
+ def update_models(file_path, models_on_the_hub):
52
  """
53
  Search through all JSON files in the specified root folder and its subfolders,
54
  and update the likes key in JSON dict from value of input dict
55
  """
56
+ seen_models = []
57
  with open(file_path, "r") as f:
58
  model_infos = json.load(f)
59
+ for model_id in model_infos.keys():
60
+ seen_models.append(model_id)
61
+ model_infos[model_id] = update_one_model(
62
+ model_id = model_id,
63
+ data=model_infos[model_id],
64
+ models_on_the_hub=models_on_the_hub
65
+ )
66
+
67
+ # If new requests files have been created since we started all this
68
+ # we grab them
69
+ all_models = []
70
+ try:
71
+ for ix, (root, _, files) in enumerate(os.walk(EVAL_REQUESTS_PATH)):
72
+ if ix == 0: continue
73
+ for file in files:
74
+ if "eval_request" in file:
75
+ path = root.split("/")[-1] + "/" + file.split("_eval_request")[0]
76
+ all_models.append(path)
77
+ except Exception as e:
78
+ print(e)
79
+ pass
80
+
81
+ for model_id in all_models:
82
+ if model_id not in seen_models:
83
+ model_infos[model_id] = update_one_model(
84
+ model_id = model_id,
85
+ data={},
86
+ models_on_the_hub=models_on_the_hub
87
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
 
89
  with open(file_path, 'w') as f:
90
  json.dump(model_infos, f, indent=2)