bigcode-models-leaderboard / src /add_json_csv.py
loubnabnl's picture
loubnabnl HF staff
add refact ai model
f55aa6a
raw
history blame
1.72 kB
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"
}
# JSON Data (replace this with your actual loaded JSON)
json_path = "/fsx/loubna/code/dev/leader/bigcode-evaluation-harness/smallcloudai_Refact-1_6B-fim_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 = "/fsx/loubna/code/dev/leader/bigcode-evaluation-harness/leaderboard/multilingual-code-evals/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)