A Python library and CLI tool to search for models and datasets on the Hugging Face Hub.
Install from PyPI:
pip install hfsearchOr install from source:
git clone https://github.com/yourusername/hfsearch.git
cd hfsearch
pip install -e .from hfsearch import search_models, search_datasets, export_to_csv
# Search for models
results = search_models(query="bert", limit=10)
print(f"Found {len(results)} models")
for model in results:
print(f"{model['id']} - {model['author']}")
# Search for datasets
datasets = search_datasets(query="sentiment", limit=5)
for dataset in datasets:
print(f"{dataset['id']} - Downloads: {dataset['downloads']}")
# Export results
export_to_csv(results, "Model", "results.csv")After installation, use the hfsearch command:
# Search for models
hfsearch models --query "bert"
# Search with filters
hfsearch models --query "translation" --limit 20 --author "google"
# Search datasets
hfsearch datasets --query "sentiment" --limit 15
# Export results
hfsearch models --query "bert" --export
hfsearch models --query "bert" --export --export-format txt- Search Models: Find models by keywords, author, tags, or task
- Search Datasets: Find datasets by keywords, author, or tags
- Export Results: Export search results to CSV or TXT files
- Beautiful Output: Formatted terminal output with Rich
- Python API: Use as a library in your Python projects
# Search by keyword
hfsearch models --query "bert"
# Search with limit
hfsearch models --query "translation" --limit 20
# Filter by author
hfsearch models --author "google" --limit 5
# Filter by tags
hfsearch models --tags "text-classification" "pytorch"
# Filter by task
hfsearch models --task "text-classification"
# Combine filters
hfsearch models --query "bert" --author "google" --limit 10# Search by keyword
hfsearch datasets --query "sentiment"
# Filter by tags
hfsearch datasets --tags "text-classification" --limit 15
# Filter by author
hfsearch datasets --author "huggingface"# Export to CSV (default)
hfsearch models --query "bert" --export
# Export to TXT
hfsearch models --query "bert" --export --export-format txtSearch for models on Hugging Face Hub.
Parameters:
query(str, optional): Search query/keywordslimit(int): Maximum number of results (default: 10)author(str, optional): Filter by author/organizationtags(list, optional): Filter by tagstask(str, optional): Filter by task (e.g., "text-classification")
Returns:
- List of dictionaries with keys:
id,author,downloads,likes,tags
Search for datasets on Hugging Face Hub.
Parameters:
query(str, optional): Search query/keywordslimit(int): Maximum number of results (default: 10)author(str, optional): Filter by author/organizationtags(list, optional): Filter by tags
Returns:
- List of dictionaries with keys:
id,author,downloads,likes,tags
Export results to a CSV file.
Parameters:
results(list): List of result dictionariesresult_type(str): "Model" or "Dataset"filename(str): Output filename
Export results to a text file.
Parameters:
results(list): List of result dictionariesresult_type(str): "Model" or "Dataset"filename(str): Output filename
- Python 3.7+
huggingface_hub>=0.20.0- For accessing Hugging Face Hub APIrich>=13.0.0- For beautiful terminal output
- The tool uses the Hugging Face Hub API, so you need an internet connection
- For downloading models, use the official
huggingface-cli downloadcommand - Authentication is optional but recommended for private models/datasets
MIT
Contributions are welcome! Please feel free to submit a Pull Request.