Download code/06_extra.py from akilhassane/open-model-lineage: direct link, hf CLI and curl.
- Browser
- Download file 2.03 kB
-
https://huggingface.co/datasets/akilhassane/open-model-lineage/resolve/main/code/06_extra.py
- Command line
-
hf download hf://datasets/akilhassane/open-model-lineage/code/06_extra.py
-
curl -L -o 06_extra.py https://huggingface.co/datasets/akilhassane/open-model-lineage/resolve/main/code/06_extra.py
2.03 kB
| """Extra numbers quoted in the text (results/extra.json).""" | |
| import json, re | |
| import pandas as pd | |
| N = pd.read_csv("data/nodes.csv.gz", low_memory=False); N["id"] = N.id.astype(str) | |
| R = pd.read_csv("data/roots_of.csv.gz", low_memory=False, dtype={"id": str, "root": str}, keep_default_na=False) | |
| E = pd.read_csv("data/edges.csv.gz") | |
| X = {} | |
| N["year"] = N.created.str[:4] | |
| X["models_by_year"] = N.year.value_counts().sort_index().to_dict() | |
| d = R[R.depth > 0].drop_duplicates("id").merge(N[["id", "year", "downloads"]], on="id") | |
| X["derivatives_by_year"] = d.year.value_counts().sort_index().to_dict() | |
| X["derivative_share_by_year"] = (d.year.value_counts() / N.year.value_counts()).dropna().round(3).to_dict() | |
| deep = R.sort_values("depth", ascending=False).drop_duplicates("id").head(5)[["id", "depth", "root"]] | |
| X["deepest"] = deep.to_dict(orient="records") | |
| X["depth_hist"] = R[R.depth > 0].drop_duplicates("id").depth.clip(upper=10).value_counts().sort_index().to_dict() | |
| X["edges_by_relation"] = E.relation.value_counts().to_dict() | |
| X["children_with_multiple_parents"] = int((N.n_parents > 1).sum()) | |
| X["roots_in_listing_share"] = float(R[R.depth > 0].root_in_listing.mean()) if "root_in_listing" in R else None | |
| # Qwen alone | |
| q = R[(R.depth > 0)].merge(N[["id", "year", "downloads"]], on="id") | |
| q["qwen"] = q.root.str.lower().str.contains(r"^qwen/|qwen|qwq") | |
| for y in ("2024", "2025", "2026"): | |
| t = q[q.year == y]; X[f"qwen_rooted_share_{y}"] = float(t.loc[t.qwen, "weight"].sum() / t.weight.sum()) | |
| t = q.assign(dl=q.weight * q.downloads); X["qwen_rooted_download_share_30d"] = float(t.loc[t.qwen, "dl"].sum() / t.dl.sum()) | |
| # roots: most downloaded root models themselves and the derivative downloads they anchor | |
| X["pipeline_of_derivatives"] = N[N.n_parents > 0].pipeline.value_counts(normalize=True).head(8).round(3).to_dict() | |
| X["library_gguf_share_of_derivatives"] = float((N[N.n_parents > 0].library == "gguf").mean()) | |
| json.dump(X, open("results/extra.json", "w"), indent=1, default=str) | |
| print(json.dumps(X, indent=1, default=str)) | |