Spaces:
Runtime error
Runtime error
Upload openllm.py
Browse files- openllm.py +41 -0
openllm.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import argparse
|
3 |
+
import requests
|
4 |
+
from bs4 import BeautifulSoup
|
5 |
+
import pandas as pd
|
6 |
+
import json
|
7 |
+
|
8 |
+
# Repo: https://github.com/Weyaxi/scrape-open-llm-leaderboard
|
9 |
+
|
10 |
+
def get_json_format_data():
|
11 |
+
url = 'https://huggingfaceh4-open-llm-leaderboard.hf.space/'
|
12 |
+
response = requests.get(url)
|
13 |
+
soup = BeautifulSoup(response.content, 'html.parser')
|
14 |
+
|
15 |
+
script_elements = soup.find_all('script')
|
16 |
+
json_format_data = json.loads(str(script_elements[1])[31:-10])
|
17 |
+
return json_format_data
|
18 |
+
|
19 |
+
|
20 |
+
def get_datas(data):
|
21 |
+
for component_index in range(10, 50, 1): # component_index sometimes changes when they update the space, we can use this "for" loop to avoid changing component index manually
|
22 |
+
try:
|
23 |
+
result_list = []
|
24 |
+
i = 0
|
25 |
+
while True:
|
26 |
+
try:
|
27 |
+
results = data['components'][component_index]['props']['value']['data'][i]
|
28 |
+
type_of_emoji = data['components'][component_index]['props']['value']['data'][i][0]
|
29 |
+
|
30 |
+
try:
|
31 |
+
results_json = {"T": type_of_emoji, "Model": results[-1], "Average ⬆️": results[2], "ARC": results[ 3],"HellaSwag": results[4], "MMLU": results[5], "TruthfulQA": results[6], "Winogrande": results[7], "GSM8K": results[8], "DROP": results[9], "Type": results[10], "Precision": results[11], "Hub License": results[12], "#Params (B)": results[13], "Hub ❤️": results[14], "Model Sha": results[16]}
|
32 |
+
except IndexError: # Wrong component index, so breaking loop to try next component index. (NOTE: More than one component index can give you some results but we must find the right component index to get all results we want.)
|
33 |
+
break
|
34 |
+
result_list.append(results_json)
|
35 |
+
i += 1
|
36 |
+
except IndexError: # No rows to extract so return the list (We know it is the right component index because we didn't break out of loop on the other exception.)
|
37 |
+
return result_list
|
38 |
+
except (KeyError, TypeError):
|
39 |
+
continue
|
40 |
+
|
41 |
+
return result_list
|