File size: 1,851 Bytes
a25c626
 
 
1ab1e33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
license: odbl
---
Weekly snapshots of Models, Datasets and Papers on the HF Hub

## Sample code

To query the dataset to see which snapshots are observable, use e.g.:
```python
import json

from datasets import load_dataset
from huggingface_hub import HfApi

REPO_ID = "hfmlsoc/hub_weekly_snapshots"

hf_api = HfApi()
all_files = hf_api.list_repo_files(repo_id=REPO_ID, repo_type="dataset")

repo_type_to_snapshots = {}
for repo_fpath in all_files:
    if ".parquet" in repo_fpath:
        repo_type = repo_fpath.split("/")[0]
        repo_type_to_snapshots[repo_type] = repo_type_to_snapshots.get(repo_type, []) + [repo_fpath]

for repo_type in repo_type_to_snapshots:
    repo_type_to_snapshots[repo_type] = sorted(repo_type_to_snapshots[repo_type], key=lambda x:x.split("/")[1])

repo_type_to_snapshots
```

You can then load a specific snapshot as e.g.:
```python
date = "2025-01-01"
snapshot = load_dataset(REPO_ID, data_files={date.replace("-",""): f"datasets/{date}/datasets.parquet"})
snapshot
```

Returning:
```
DatasetDict({
    20250101: Dataset({
        features: ['_id', 'id', 'author', 'cardData', 'disabled', 'gated', 'lastModified', 'likes', 'trendingScore', 'private', 'sha', 'description', 'downloads', 'tags', 'createdAt', 'key', 'paperswithcode_id', 'citation'],
        num_rows: 276421
    })
})
```

### Sample analysis of top datasets

To look at the 10 most liked datasets as of January 1st 2025, you can then run:
```python
[{
    "id": row['id'],
    "tags": json.loads(row["cardData"]).get("tags", []),
    "tasks": json.loads(row["cardData"]).get("task_categories", []),
    "likes": row['likes'],
} for row in snapshot["20250101"].sort("likes", reverse=True).select(range(10))]
```

Most of the user-maintained metadata for Hub repositories is stored in the cardData field, which is saved as a JSON-formated string