import json import os import requests import pandas as pd def download(filename, url): try: with open(filename) as f: json.load(f) except Exception: os.makedirs(os.path.dirname(filename), exist_ok=True) with open(filename, "wb") as f: r = requests.get(url) f.write(r.content) with open(filename) as f: tmp = json.load(f) return tmp "https://huggingface.co/tner/roberta-large-tweetner7-all/raw/main/eval/metric.test_2021.json" models = [ "tner/roberta-large-tweetner7-all", "tner/roberta-base-tweetner7-all", "tner/twitter-roberta-base-2019-90m-tweetner7-all", "tner/twitter-roberta-base-dec2020-tweetner7-all", "tner/twitter-roberta-base-dec2021-tweetner7-all" "tner/roberta-large-tweetner7-2020", "tner/roberta-base-tweetner7-2020", "tner/twitter-roberta-base-2019-90m-tweetner7-2020", "tner/twitter-roberta-base-dec2020-tweetner7-2020", "tner/twitter-roberta-base-dec2021-tweetner7-2020" ] os.makedirs("metric_files", exist_ok=True) metrics = [] for i in models: model_type = "all (2020 + 2021)" if i.endswith("all") else "2020 only" url = f"https://huggingface.co/{i}/raw/main/metric_summary.json" model_url = f"https://huggingface.co/{i}" metric = download(f"metric_files/{os.path.basename(i)}.json", url) metrics.append({"model": f"[{i}]({model_url})", "training data": model_type, "F1": metric["test/eval_f1"], "F1 (macro)": metric["test/eval_f1_macro"], "Accuracy": metric["test/eval_accuracy"]}) df = pd.DataFrame(metrics) print(df.to_markdown(index=False))