zaher-m's picture
download
raw
2.4 kB
"""Build the candidate table for MODEL_SELECTION.md from the shortlist and card files.
Writes results/model_search/candidates_table.md and results/model_search/family_table.md.
"""
import csv
from pathlib import Path
DIR = Path("results/model_search")
IMAGE_TASKS = {"image-text-to-text", "any-to-any"}
def read(name):
with open(DIR / name, encoding="utf-8") as f:
return list(csv.DictReader(f))
def arabic_cell(card):
if card["card_status"] != "read":
return card["card_status"]
named = card["card_language_list_has_ar"] == "True" or card["card_text_mentions_arabic"] == "True"
return "yes" if named else "no"
def architecture_cell(card):
if not card["model_type"]:
return "config requires login"
if card["text_model_type"]:
return f"{card['model_type']} ({card['text_model_type']})"
return card["model_type"]
def candidates_table():
cards = {c["repo_id"]: c for c in read("hub_card_languages.csv")}
kept = [r for r in read("hub_shortlist.csv") if not r["excluded_because"]]
kept.sort(key=lambda r: -int(r["params"]))
lines = ["| Model | Parameters | Created on the Hub | Architecture (text part) | Image input | Arabic named in card | Languages claimed in card | Downloads, last 30 days |",
"|---|---|---|---|---|---|---|---|"]
for r in kept:
c = cards[r["repo_id"]]
image = "yes" if r["pipeline_tag"] in IMAGE_TASKS or c["config_has_vision"] == "True" else "no"
lines.append(f"| {r['repo_id']} | {int(r['params']):,} | {r['created']} | {architecture_cell(c)} | {image} | "
f"{arabic_cell(c)} | {c['largest_language_count_claim'] or ''} | {int(r['downloads_30d']):,} |")
return "\n".join(lines) + "\n"
def family_table():
lines = ["| Family | Largest original model on the Hub | Parameters |", "|---|---|---|"]
for r in read("family_sizes.csv"):
params = f"{int(r['largest_params']):,}" if r["largest_params"] else r["note"]
lines.append(f"| {r['family']} | {r['largest_repo']} | {params} |")
return "\n".join(lines) + "\n"
def main():
(DIR / "candidates_table.md").write_text(candidates_table(), encoding="utf-8")
(DIR / "family_table.md").write_text(family_table(), encoding="utf-8")
print("wrote", DIR / "candidates_table.md", "and", DIR / "family_table.md")
if __name__ == "__main__":
main()

Xet Storage Details

Size:
2.4 kB
·
Xet hash:
ec7122a92355766b0b11f60e5f0b47aa3290234574832d560b68980d23b0b119

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.