Automated tools for working with the Model Openness Framework (MOF), including scraping model information from HuggingFace and identifying missing models.
Generates draft YAML files for individual models by scraping HuggingFace. Accepts both model IDs and full URLs.
Identifies popular HuggingFace models that are not yet in the MOT database.
These tools automate data collection and gap analysis for model evaluation by:
- Fetching model metadata from HuggingFace API
- Analyzing repository contents to detect available MOF components
- Identifying license information
- Generating MOF-compliant YAML files with confidence scores
- Finding missing models that should be added to MOT
- Flagging areas requiring manual review
- Python 3.8 or higher
- pip package manager
- Navigate to the tools-py directory:
cd tools-py- Install dependencies:
pip install -r requirements.txtScrape a model from HuggingFace using either a model ID or full URL:
python model_scraper.py <model_id_or_url>Examples:
# Using model ID
python model_scraper.py meta-llama/Llama-3-8B
# Using full URL (copy-paste from browser)
python model_scraper.py https://huggingface.co/meta-llama/Llama-3-8BSpecify output directory:
python model_scraper.py https://huggingface.co/meta-llama/Llama-3-8B --output-dir ../modelsUse HuggingFace token for gated models:
python model_scraper.py https://huggingface.co/meta-llama/Llama-3-8B --hf-token YOUR_TOKENFind missing models with default settings (min 1000 downloads):
python find_missing_models.pySet minimum download threshold:
python find_missing_models.py --min-downloads 10000Limit number of models to check:
python find_missing_models.py --limit 500Save report to file:
python find_missing_models.py --output missing_models_report.txtFilter by model type:
python find_missing_models.py --model-type text-generation--min-downloads: Minimum number of downloads to consider (default: 1000)--limit: Maximum number of models to fetch from HuggingFace (default: 1000)--models-dir: Path to MOT models directory (default: ../models)--output: Output file for report (default: print to console)--model-type: Filter by model type (e.g., text-generation, image-to-text)
Option A: Manual Workflow (Selective)
- Find missing high-priority models:
python find_missing_models.py --min-downloads 50000 --output report.txt-
Review the report and identify models to add
-
Scrape the identified models:
python model_scraper.py meta-llama/Llama-3-8B
python model_scraper.py mistralai/Mistral-7B-v0.1-
Review and validate the generated YAML files
-
Submit PRs to add models to MOT
Option B: Batch Processing (Automated)
Use the batch script to automatically find and scrape missing models:
./batch_scrape_missing.shThis will:
- Find missing models (default: 50k+ downloads)
- Extract model IDs from the report
- Prompt for confirmation
- Scrape first 20 models automatically
- Generate summary with success/failure counts
Customize batch processing:
# Set minimum downloads threshold
MIN_DOWNLOADS=100000 ./batch_scrape_missing.sh
# Process more models (default is 20)
MAX_MODELS=50 ./batch_scrape_missing.sh
# Process ALL missing models (use with caution!)
MAX_MODELS=999 ./batch_scrape_missing.sh
# Use HuggingFace token for gated models
HF_TOKEN=your_token ./batch_scrape_missing.sh
# Change output directory
OUTPUT_DIR=./draft_models ./batch_scrape_missing.sh
# Combine multiple options
MIN_DOWNLOADS=100000 MAX_MODELS=50 HF_TOKEN=your_token ./batch_scrape_missing.shEnvironment Variables:
MIN_DOWNLOADS: Minimum download threshold (default: 50000)LIMIT: Max models to check in HuggingFace (default: 1000)MAX_MODELS: Max models to scrape in one batch (default: 20)OUTPUT_DIR: Output directory for YAML files (default: ../models)HF_TOKEN: HuggingFace API token for gated models (optional)
Note: The default limit of 20 models is a safety measure. Each model takes ~2-5 seconds to scrape, so 20 models = ~1-2 minutes. Increase MAX_MODELS carefully based on your needs.
Specify output directory:
python model_scraper.py meta-llama/Llama-3-8B --output-dir ../modelsUse HuggingFace token for gated models:
python model_scraper.py meta-llama/Llama-3-8B --hf-token YOUR_TOKENmodel_id(required): HuggingFace model ID or full URL- Model ID format:
meta-llama/Llama-3-8B - Full URL format:
https://huggingface.co/meta-llama/Llama-3-8B
- Model ID format:
--output-dir: Output directory for YAML files (default:../models)--hf-token: HuggingFace API token for accessing gated models
- Fetches model metadata from HuggingFace API
- Downloads and parses model card (README.md)
- Lists repository files to detect available components
- Extracts license information
The scraper automatically detects the following MOF components:
Code Components:
- Model parameters (Final) - Detects
.bin,.safetensors,.pt,.pth,.ckptfiles - Model metadata - Detects
config.json,model_config.json - Model architecture - Detects Python files with modeling code
- Inference code - Detects files with inference/generation keywords
Data Components:
- Training dataset - Detects references in model card
Documentation Components:
- Model card - Detects README.md
- Technical report - Detects references in model card
- Research paper - Detects paper/arxiv references
- Evaluation results - Detects benchmark/performance mentions
- Extracts license from HuggingFace model metadata
- Uses the main model license as the global default for all components
- Checks for LICENSE files in repository
- Defaults to "unlicensed" when uncertain (requires manual review)
- Extracts the actual model name from the model card (YAML frontmatter, title, or first heading)
- Falls back to the model ID if name not found in card
- Ensures proper capitalization (e.g., "Polyglot-Ko-12.8B" instead of "polyglot-ko-12.8b")
- Uses extracted name for the YAML filename
The scraper automatically detects GitHub repositories using multiple strategies with confidence scoring:
Detection Methods (in priority order):
-
Model Card Parsing (70-90% confidence)
- Searches the model card (README.md) for GitHub URLs
- Filters for the most relevant repository (matching model/organization name)
- Higher confidence when repository name closely matches model name
- Example: Found
https://github.com/bigscience-workshop/bigsciencefor BLOOM model
-
Pattern-Based Inference (60-65% confidence)
- Attempts direct mapping:
organization/model→github.com/organization/model - Validates repository existence via HTTP HEAD request
- Example:
mistralai/Mistral-7B-v0.1→github.com/mistralai/Mistral-7B-v0.1
- Attempts direct mapping:
-
Name Variations (60% confidence)
- Tries base model names without version suffixes
- Tests multiple naming patterns (e.g.,
Mistral-7B-v0.1→Mistral) - Validates each attempt before accepting
Output Format:
# Repository detected: 70% confidence
release:
repository: https://github.com/bigscience-workshop/bigscienceWhen No Repository Found:
- Repository field left empty (requires manual addition)
- Common for models without public code repositories
- May indicate closed-source or proprietary models
Manual Review Required:
- Verify detected repository is correct and official
- Check if repository contains actual model code/weights
- Some models may have multiple repositories (training vs. inference)
Each detected component includes a confidence score:
- 95%: High confidence (e.g., model parameters detected via file extensions)
- 80-90%: Good confidence (e.g., config files, model card)
- 60-75%: Medium confidence (e.g., references in documentation)
- 50%: Low confidence (requires verification)
Generated YAML files include:
- MOF framework metadata
- Model release information (name, version, date, producer)
- Detected components with descriptions and licenses
- Confidence scores in comments
- Links to HuggingFace repository
Example output structure:
# AUTO-GENERATED DRAFT - REQUIRES MANUAL REVIEW
# Generated by Model Openness Tool scraper
# Source: HuggingFace model meta-llama/Llama-3-8B
#
# Component confidence scores:
# - Model parameters (Final): 95% confidence
# - Model card: 95% confidence
#
framework:
name: Model Openness Framework
version: '1.0'
date: '2024-12-15'
release:
name: Llama-3-8B
version: 8B
date: '2024-10-03'
license: {}
type: language
architecture: transformer decoder
origin: llama-3-8b
producer: Meta
contact: ''
huggingface: https://huggingface.co/meta-llama/Llama-3-8B
components:
- name: Model parameters (Final)
description: Trained model parameters, weights and biases
license: llama-3After generating a YAML file, you must review and verify:
- Verify model name and version
- Confirm producer/organization
- Check release date accuracy
- Validate model type (language, vision, multimodal, etc.)
- Verify architecture classification
- Confirm all detected components are actually available
- Add any missing components not detected by scraper
- Verify component descriptions are accurate
- Update component locations/URLs if needed
- Critical: Verify all license information
- Check if licenses are correctly identified as open/closed
- Add license file paths where available
- Replace "unlicensed" with actual license names
- Ensure license compatibility across components
- Add contact information if available
- Add GitHub repository URL if different from HuggingFace
- Include paper URLs (arXiv, conference proceedings)
- Add any special notes or caveats
After manual review, validate the YAML file:
cd ..
php scripts/validate-model.php models/Your-Model.ymlThe validation script checks:
- Schema compliance with
schema/mof_schema.json - Required fields are present
- Data types are correct
- Enum values are valid
- Generate draft: Run the scraper
- Manual review: Edit the generated YAML file
- Validate: Run validation script
- Test locally: Import into local MOT instance
- Submit PR: Create pull request to add model to MOT
See CONTRIBUTING.md for detailed submission instructions.
- Only supports HuggingFace as a data source
- Cannot access gated models without API token
- License detection is basic (requires manual verification)
- Cannot determine if training code/data is actually available
- May miss components not clearly documented
- Cannot validate license openness automatically
- Some model cards use non-standard formats
- License information may be incomplete or ambiguous
- Component availability may be overstated
- Confidence scores are heuristic-based
Potential improvements:
- Support for additional sources (GitHub, Papers with Code, etc.)
- LLM-powered content analysis for better component detection
- Automated license file parsing and classification
- Integration with license databases (SPDX, OSI)
- Batch processing for multiple models
- Interactive mode for guided review
- Comparison with existing MOT entries
- GitHub API integration for repository analysis
"Failed to scrape model data"
- Check model ID is correct (format:
organization/model-name) - Verify internet connection
- For gated models, provide HuggingFace token with
--hf-token
"Model not found"
- Ensure model exists on HuggingFace
- Check for typos in model ID
- Some models may be private or deleted
"Permission denied"
- Gated models require authentication
- Get HuggingFace token from https://huggingface.co/settings/tokens
- Use
--hf-tokenargument
Low confidence scores
- Normal for models with minimal documentation
- Requires more thorough manual review
- Consider contacting model producer for clarification
To improve the scraper:
- Fork the repository
- Make your changes
- Test with various models
- Submit a pull request
See CONTRIBUTING.md for guidelines.
This scraper is part of the Model Openness Tool, licensed under MIT.
For issues or questions:
- File an issue on GitHub
- Check existing issues for solutions
- Consult the main MOT documentation
This scraper was developed to accelerate the MOT model evaluation process while maintaining the quality and accuracy standards of the Model Openness Framework.