| | --- |
| | 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 |
| |
|