To download these specific files, the best tool is the official huggingface_hub Python library. It handles the connection, caching, and local file management efficiently.I have assumed these files are hosted in a Dataset repository given the .json extension (as opposed to a Model or Space), but I have added a comment on how to change that if necessary.PrerequisitesYou will need the Hugging Face Hub library installed:Bashpip install huggingface_hub
Python Download ScriptYou will need to replace "YOUR_TARGET_REPO_ID" with the actual repository name (e.g., stanfordnlp/shp or username/repo-name).Pythonimport os
from huggingface_hub import hf_hub_download
from huggingface_hub.utils import EntryNotFoundError, RepositoryNotFoundError
--- CONFIGURATION ---
REPLACE THIS with the actual Repo ID (e.g., "author/dataset_name")
REPO_ID = "YOUR_TARGET_REPO_ID"
Set to "dataset", "model", or "space"
REPO_TYPE = "dataset"
Where you want the files saved locally
OUTPUT_DIR = "./downloaded_data"
The list provided
files_to_download = [
"share_lm_formatted.json",
"share_lm_formatted_04_anon.json",
"collective_cognition_formatted.json",
"hh_rlhf_formatted_part0.json",
"hh_rlhf_formatted_part50000.json",
"hh_rlhf_XXX.json",
"hh_rlhf_XXX.json",
"hh_rlhf_XXX.json",
"hh_rlhf_XXX.json",
"babi_formatted.json",
"self_feeding_formatted.json",
"prism_formatted.json",
"pippa_formatted.json",
"gpt_role_play_vanilla_formatted.json",
"gpt_role_play_classmate_formatted.json",
"gpt_role_play_boss_formatted.json",
"you_tell_me_formatted.json"
]
--- DOWNLOAD LOOP ---
print(f"Starting download from {REPO_ID} into '{OUTPUT_DIR}'...\n")
for filename in files_to_download:
try:
print(f"Downloading: {filename}...")
file_path = hf_hub_download(
repo_id=REPO_ID,
filename=filename,
repo_type=REPO_TYPE,
local_dir=OUTPUT_DIR,
local_dir_use_symlinks=False # False ensures actual files are created, not symlinks
)
print(f" -> Success! Saved at: {file_path}")
except EntryNotFoundError:
print(f" -> ERROR: File '{filename}' not found in repo '{REPO_ID}'.")
except RepositoryNotFoundError:
print(f" -> ERROR: Repository '{REPO_ID}' not found.")
break # Stop if the repo itself doesn't exist
except Exception as e:
print(f" -> ERROR: An unexpected error occurred: {e}")
print("\nDownload process finished.")
Key Detailslocal_dir_use_symlinks=False: I set this to False. By default, Hugging Face caches files in a hidden folder and creates "shortcuts" (symlinks) in your project folder. Setting this to False ensures you get the actual independent files in your folder.Authentication: If the repository is private or requires user access (like Llama 3 or gated datasets), you must log in first. Run huggingface-cli login in your terminal or pass token="YOUR_HF_TOKEN" into the hf_hub_download function.Would you like me to help you identify the specific REPO_ID if you aren't sure which repository these files belong to?