File size: 1,718 Bytes
13ff3a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d242132
e3e355a
c47d747
d242132
13ff3a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b3d762
13ff3a0
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import csv
import json

# Given mapping
mapping = {
    "humaneval": "humaneval-python",
    "multiple-lua": "lua",
    "multiple-java": "java",
    "multiple-jl": "julia",
    "multiple-cpp": "cpp",
    "multiple-rs": "rust",
    "multiple-rkt": "racket",
    "multiple-php": "php",
    "multiple-r": "r",
    "multiple-js": "javascript",
    "multiple-d": "d",
    "multiple-swift": "swift"
}
BASE_PATH = "/fsx/loubna/projects/bigcode-models-leaderboard"
# JSON Data (replace this with your actual loaded JSON)

json_path = f"/fsx/loubna/projects/bigcode-models-leaderboard/community_results/codeqwen/Qwen_CodeQwen1.5-7B-Chat_loubnabnl.json"
with open(json_path, "r") as f:
    json_data = json.load(f)
parsed_data = json_data['results']

# Create a dictionary with column names as keys and empty values
csv_columns = ["Models", "Size (B)", "Throughput (tokens/s)", "Seq_length", "#Languages", "humaneval-python", "java", "javascript", "cpp", "php", "julia", "d", "lua", "r", "racket", "rust", "swift", "Throughput (tokens/s) bs=50", "Peak Memory (MB)"]
row_data = {col: '' for col in csv_columns}

# Fill the dictionary with data from the JSON
for item in parsed_data:
    csv_col = mapping.get(item['task'])
    if csv_col:
        row_data[csv_col] = round(item['pass@1'] * 100, 2)

# Set model name under the 'Models' column
row_data['Models'] = json_data['meta']['model']

# Write to CSV
csv_file = f"{BASE_PATH}/data/raw_scores.csv"
with open(csv_file, 'a', newline='') as csvfile:
    writer = csv.DictWriter(csvfile, fieldnames=row_data.keys())
    writer.writerow(row_data)

# print last 3 rows in csv
with open(csv_file, 'r') as f:
    lines = f.readlines()
    for line in lines[-3:]:
        print(line)