|
import json |
|
import os |
|
from datetime import datetime |
|
|
|
import pandas as pd |
|
|
|
|
|
def generate_request(model_id, precision, model_type, params, index): |
|
data = { |
|
"model": model_id, |
|
"base_model": "", |
|
"revision": "main", |
|
"private": False, |
|
"precision": precision, |
|
"weight_type": "Original", |
|
"status": "FINISHED", |
|
"submitted_time": (datetime.now() + pd.Timedelta(hours=index)).strftime( |
|
"%Y-%m-%dT%H:%M:%SZ" |
|
), |
|
"model_type": f"\ud83d\udfe2 : {model_type} if model_type == 'pretrained' else model_type", |
|
"likes": 0, |
|
"params": params, |
|
"license": "custom", |
|
"architecture": "", |
|
"sender": "mariagrandury", |
|
} |
|
|
|
os.makedirs(f"{model_id}", exist_ok=True) |
|
with open(f"{model_id}_eval_request_False_{precision}_Original.json", "w") as f: |
|
json.dump(data, f) |
|
|
|
|
|
def generate_requests(selection: str): |
|
df = pd.read_csv("scripts/models.csv") |
|
df = df[["model_id", "precision", "model_type", "params", "iberobench"]] |
|
|
|
if selection == "pretrained": |
|
df = df[df["model_type"] == "pretrained"] |
|
elif selection == "pretrained_new": |
|
df = df[df["model_type"] == "pretrained"] |
|
df = df[df["iberobench"] == False] |
|
elif selection == "instruction": |
|
df = df[df["model_type"] == "instruction-tuned"] |
|
|
|
for index, row in df.iterrows(): |
|
model_id, precision, model_type, params, iberobench = row |
|
generate_request( |
|
model_id=model_id, |
|
precision=precision, |
|
model_type=model_type, |
|
params=params, |
|
index=index, |
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
import argparse |
|
|
|
parser = argparse.ArgumentParser(description="Generate model requests.") |
|
parser.add_argument("--pretrained", action="store_true") |
|
parser.add_argument("--pretrained_new", action="store_true") |
|
parser.add_argument("--instruction", action="store_true") |
|
args = parser.parse_args() |
|
|
|
if args.pretrained: |
|
generate_requests("pretrained") |
|
elif args.pretrained_new: |
|
generate_requests("pretrained_new") |
|
elif args.instruction: |
|
generate_requests("instruction") |
|
else: |
|
generate_requests() |
|
|