saladday1 commited on
Commit
55c820f
·
verified ·
1 Parent(s): 6e42356

code: tile wording, daily keyed by kind

Browse files
Files changed (2) hide show
  1. code/hfeco/metrics.py +4 -4
  2. code/space/index.html +4 -2
code/hfeco/metrics.py CHANGED
@@ -53,10 +53,10 @@ def build(raw, labels, hf_tree_counts, fam):
53
  tools = sub[(sub.kind == "model") & sub.relation.isin(["tool", "no-weights"])]
54
  off = cur[cur.repo_id == base]
55
  # daily series by relation
56
- d = dd.merge(models[["repo_id", "relation"]], on="repo_id")
57
  daily = (d.dropna(subset=["daily"]).groupby(["day", "relation"]).daily.sum()
58
  .round().astype(int).reset_index())
59
- off_daily = dd[(dd.repo_id == base)].dropna(subset=["daily"])
60
  # growth by creation date (real history)
61
  cr = models.assign(month=models.created_at.str[:10]).groupby(["month", "relation"]).size()
62
  growth = [{"date": k[0], "relation": k[1], "n": int(v)} for k, v in cr.items()]
@@ -90,7 +90,7 @@ def build(raw, labels, hf_tree_counts, fam):
90
 
91
  # Repo table: every family repo plus repos HF counts under a family base but we reject.
92
  rows = []
93
- last = dd[dd.day == today].set_index("repo_id").daily.to_dict()
94
  hf_base_children = {}
95
  for r in cur.itertuples():
96
  for p in r.hf_parents:
@@ -101,7 +101,7 @@ def build(raw, labels, hf_tree_counts, fam):
101
  rows.append({
102
  "id": r.repo_id, "kind": r.kind, "lineage": r.lineage, "relation": r.relation,
103
  "conf": r.confidence, "dl30": _i(r.downloads_30d), "dlall": _i(r.downloads_all_time),
104
- "d1": None if pd.isna(last.get(r.repo_id)) else int(round(last.get(r.repo_id))),
105
  "likes": _i(r.likes), "created": (r.created_at or "")[:10],
106
  "declared": r.declared_status if isinstance(r.declared_status, str) else None,
107
  "hf_under": hf_base_children.get(r.repo_id),
 
53
  tools = sub[(sub.kind == "model") & sub.relation.isin(["tool", "no-weights"])]
54
  off = cur[cur.repo_id == base]
55
  # daily series by relation
56
+ d = dd[dd.kind == "model"].merge(models[["repo_id", "relation"]], on="repo_id")
57
  daily = (d.dropna(subset=["daily"]).groupby(["day", "relation"]).daily.sum()
58
  .round().astype(int).reset_index())
59
+ off_daily = dd[(dd.kind == "model") & (dd.repo_id == base)].dropna(subset=["daily"])
60
  # growth by creation date (real history)
61
  cr = models.assign(month=models.created_at.str[:10]).groupby(["month", "relation"]).size()
62
  growth = [{"date": k[0], "relation": k[1], "n": int(v)} for k, v in cr.items()]
 
90
 
91
  # Repo table: every family repo plus repos HF counts under a family base but we reject.
92
  rows = []
93
+ last = dd[dd.day == today].set_index(["kind", "repo_id"]).daily.to_dict()
94
  hf_base_children = {}
95
  for r in cur.itertuples():
96
  for p in r.hf_parents:
 
101
  rows.append({
102
  "id": r.repo_id, "kind": r.kind, "lineage": r.lineage, "relation": r.relation,
103
  "conf": r.confidence, "dl30": _i(r.downloads_30d), "dlall": _i(r.downloads_all_time),
104
+ "d1": None if pd.isna(last.get((r.kind, r.repo_id))) else int(round(last.get((r.kind, r.repo_id)))),
105
  "likes": _i(r.likes), "created": (r.created_at or "")[:10],
106
  "declared": r.declared_status if isinstance(r.declared_status, str) else None,
107
  "hf_under": hf_base_children.get(r.repo_id),
code/space/index.html CHANGED
@@ -220,12 +220,14 @@ function L() { return D.lineages[lineage]; }
220
  function renderTiles() {
221
  const l = L(), hf = Object.values(l.hf_tree).reduce((a, b) => a + b, 0);
222
  const miss = (l.declared.missing || 0) + (l.declared.wrong_base || 0);
 
 
223
  const tiles = [
224
- {label: "衍生模型", value: full(l.n_models), note: `HF Model tree 只显示 ${full(hf)} 个`, hero: true},
225
  {label: "衍生模型近 30 天下载", value: fmt(l.dl30), note: `官方仓库 ${fmt(l.official.dl30)}`},
226
  {label: "衍生模型累计下载", value: fmt(l.dlall), note: `官方仓库 ${fmt(l.official.dlall)}`},
227
  {label: "用到它的 Space", value: full(l.n_spaces), note: `另有数据集 ${l.n_datasets} 个、周边工具 ${l.n_tools} 个`},
228
- {label: "base_model 没写或写错", value: full(miss), note: `占衍生模型的 ${l.n_models ? Math.round(miss / l.n_models * 100) : 0}%,可以提 PR 补上`},
229
  ];
230
  document.getElementById("tiles").innerHTML = tiles.map(t => `<div class="tile${t.hero ? " hero" : ""}"><div class="label">${t.label}</div><div class="value">${t.value}</div><div class="note">${t.note}</div></div>`).join("");
231
  }
 
220
  function renderTiles() {
221
  const l = L(), hf = Object.values(l.hf_tree).reduce((a, b) => a + b, 0);
222
  const miss = (l.declared.missing || 0) + (l.declared.wrong_base || 0);
223
+ // Compare like with like: HF's tree only has these four relations.
224
+ const four = ["adapter", "finetune", "quantized", "merge"].reduce((a, r) => a + ((l.by_relation[r] || {}).n || 0), 0);
225
  const tiles = [
226
+ {label: "衍生模型", value: full(l.n_models), note: `其中适配器/微调/量化/融合 ${full(four)} 个,HF Model tree 这四类显示 ${full(hf)} 个`, hero: true},
227
  {label: "衍生模型近 30 天下载", value: fmt(l.dl30), note: `官方仓库 ${fmt(l.official.dl30)}`},
228
  {label: "衍生模型累计下载", value: fmt(l.dlall), note: `官方仓库 ${fmt(l.official.dlall)}`},
229
  {label: "用到它的 Space", value: full(l.n_spaces), note: `另有数据集 ${l.n_datasets} 个、周边工具 ${l.n_tools} 个`},
230
+ {label: "base_model 没写或写错", value: full(miss), note: `占衍生模型的 ${l.n_models ? Math.round(miss / l.n_models * 100) : 0}%`},
231
  ];
232
  document.getElementById("tiles").innerHTML = tiles.map(t => `<div class="tile${t.hero ? " hero" : ""}"><div class="label">${t.label}</div><div class="value">${t.value}</div><div class="note">${t.note}</div></div>`).join("");
233
  }