Implementation:Huggingface Transformers Add Dates
| Knowledge Sources | |
|---|---|
| Domains | Documentation, Repository_Maintenance |
| Last Updated | 2026-02-13 20:00 GMT |
Overview
Concrete tool for managing release dates, paper links, and copyright headers in model documentation files.
Description
The add_dates.py utility maintains metadata consistency across model documentation markdown files under docs/source/en/model_doc/. It uses git history (git log) to find the first commit date for each model doc file, queries the HuggingFace Hub paper_info API to resolve arXiv paper links, and checks/updates model doc cards to ensure they have correct release dates, paper links with proper formatting, and up-to-date copyright disclaimers. Supports both checking for inconsistencies and auto-fixing them via --fix_and_overwrite.
Usage
Run this utility as part of make check-repo to verify documentation metadata, or with --fix_and_overwrite to auto-correct dates and paper links.
Code Reference
Source Location
- Repository: Huggingface_Transformers
- File: utils/add_dates.py
- Lines: 1-398
Signature
def get_first_commit_date(filepath: str) -> Optional[str]:
"""Get the date of the first git commit that added this file."""
def get_paper_link(model_name: str) -> Optional[str]:
"""Query HuggingFace Hub API for the arXiv paper link."""
def check_missing_dates(files: List[str]) -> List[str]:
"""Check which model doc files are missing release dates."""
def check_incorrect_dates(files: List[str]) -> List[str]:
"""Check which model doc files have incorrect dates."""
Import
python utils/add_dates.py
python utils/add_dates.py --fix_and_overwrite
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| docs/source/en/model_doc/*.md | Markdown files | Yes | Model documentation files to check/update |
| --fix_and_overwrite | flag | No | Auto-fix issues instead of just reporting |
Outputs
| Name | Type | Description |
|---|---|---|
| Error report | stdout | List of files with missing/incorrect dates or paper links |
| Updated files | Markdown files | Modified documentation files (if --fix_and_overwrite) |
Usage Examples
Checking Documentation Dates
# Check for missing or incorrect dates
python utils/add_dates.py
# Auto-fix issues
python utils/add_dates.py --fix_and_overwrite