Spaces:
Running
Running
Download checks_overview.py from vibe-check/vibecheck: direct link, hf CLI and curl.
- Browser
- Download file 2.21 kB
-
https://huggingface.co/spaces/vibe-check/vibecheck/resolve/main/checks_overview.py
- Command line
-
hf download hf://spaces/vibe-check/vibecheck/checks_overview.py
-
curl -L -o checks_overview.py https://huggingface.co/spaces/vibe-check/vibecheck/resolve/main/checks_overview.py
2.21 kB
| """Compact overview helpers for the General + Training sections. | |
| Two small functions instead of one big gather() so the UI can stream | |
| the fast bit (model_info) before the slow bit (derivative counts). | |
| """ | |
| from huggingface_hub import HfApi | |
| from transformers import AutoConfig | |
| from helpers import HF_TOKEN | |
| from checks_reach import count_derivatives, fmt_date | |
| __all__ = ["format_general", "format_community"] | |
| def _fmt(n) -> str: | |
| return f"{n:,}" if isinstance(n, int) else "β" | |
| def format_general(model_id: str) -> str: | |
| api = HfApi(token=HF_TOKEN) | |
| try: | |
| info = api.model_info(model_id) | |
| except Exception as e: | |
| return f"β Could not fetch model info: `{e}`" | |
| try: | |
| cfg = AutoConfig.from_pretrained(model_id, token=HF_TOKEN, trust_remote_code=True) | |
| arch = (cfg.architectures or ["unknown"])[0] | |
| except Exception: | |
| arch = "β" | |
| downloads = getattr(info, "downloads", None) | |
| likes = getattr(info, "likes", None) | |
| last_mod = fmt_date(getattr(info, "last_modified", None)) | |
| created = fmt_date(getattr(info, "created_at", None)) | |
| return ( | |
| f"### [`{model_id}`](https://huggingface.co/{model_id})\n\n" | |
| f"| Architecture | Downloads (30d) | Likes | Created | Modified |\n" | |
| f"|---|---:|---:|---|---|\n" | |
| f"| `{arch}` | {_fmt(downloads)} | {_fmt(likes)} | {created} | {last_mod} |" | |
| ) | |
| def format_community(model_id: str) -> str: | |
| """Derivative counts (finetune / adapter / quantized / merge). | |
| Finetune count is the headline signal for 'community trains this model'. | |
| """ | |
| api = HfApi(token=HF_TOKEN) | |
| try: | |
| deriv = count_derivatives(api, model_id) | |
| except Exception as e: | |
| return f"β Could not fetch derivatives: `{e}`" | |
| def _line(kind, emoji): | |
| d = deriv.get(kind, {}) | |
| count = d.get("count") | |
| if count is None: | |
| return f"{emoji} **β** {kind}" | |
| suffix = "+" if d.get("capped") else "" | |
| return f"{emoji} **{count:,}{suffix}** {kind}" | |
| return " β’ ".join([ | |
| _line("finetune", "π§¬"), | |
| _line("adapter", "π§©"), | |
| _line("quantized", "π¦"), | |
| _line("merge", "π"), | |
| ]) | |