yjernite HF Staff commited on
Commit
1ab1e33
·
verified ·
1 Parent(s): 4460661

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +58 -1
README.md CHANGED
@@ -1,4 +1,61 @@
1
  ---
2
  license: odbl
3
  ---
4
- Weekly snapshots of Models, Datasets and Papers on the HF Hub
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: odbl
3
  ---
4
+ Weekly snapshots of Models, Datasets and Papers on the HF Hub
5
+
6
+ ## Sample code
7
+
8
+ To query the dataset to see which snapshots are observable, use e.g.:
9
+ ```python
10
+ import json
11
+
12
+ from datasets import load_dataset
13
+ from huggingface_hub import HfApi
14
+
15
+ REPO_ID = "hfmlsoc/hub_weekly_snapshots"
16
+
17
+ hf_api = HfApi()
18
+ all_files = hf_api.list_repo_files(repo_id=REPO_ID, repo_type="dataset")
19
+
20
+ repo_type_to_snapshots = {}
21
+ for repo_fpath in all_files:
22
+ if ".parquet" in repo_fpath:
23
+ repo_type = repo_fpath.split("/")[0]
24
+ repo_type_to_snapshots[repo_type] = repo_type_to_snapshots.get(repo_type, []) + [repo_fpath]
25
+
26
+ for repo_type in repo_type_to_snapshots:
27
+ repo_type_to_snapshots[repo_type] = sorted(repo_type_to_snapshots[repo_type], key=lambda x:x.split("/")[1])
28
+
29
+ repo_type_to_snapshots
30
+ ```
31
+
32
+ You can then load a specific snapshot as e.g.:
33
+ ```python
34
+ date = "2025-01-01"
35
+ snapshot = load_dataset(REPO_ID, data_files={date.replace("-",""): f"datasets/{date}/datasets.parquet"})
36
+ snapshot
37
+ ```
38
+
39
+ Returning:
40
+ ```
41
+ DatasetDict({
42
+ 20250101: Dataset({
43
+ features: ['_id', 'id', 'author', 'cardData', 'disabled', 'gated', 'lastModified', 'likes', 'trendingScore', 'private', 'sha', 'description', 'downloads', 'tags', 'createdAt', 'key', 'paperswithcode_id', 'citation'],
44
+ num_rows: 276421
45
+ })
46
+ })
47
+ ```
48
+
49
+ ### Sample analysis of top datasets
50
+
51
+ To look at the 10 most liked datasets as of January 1st 2025, you can then run:
52
+ ```python
53
+ [{
54
+ "id": row['id'],
55
+ "tags": json.loads(row["cardData"]).get("tags", []),
56
+ "tasks": json.loads(row["cardData"]).get("task_categories", []),
57
+ "likes": row['likes'],
58
+ } for row in snapshot["20250101"].sort("likes", reverse=True).select(range(10))]
59
+ ```
60
+
61
+ Most of the user-maintained metadata for Hub repositories is stored in the cardData field, which is saved as a JSON-formated string