Fix: Replace deprecated cached_path usage with hf_hub_download
#2
by
anon-repair-bot
- opened
Description
The example code in this model card fails due to deprecated APIs in transformers:
from transformers.file_utils import cached_path, hf_bucket_url
# ImportError: cannot import name 'cached_path' from 'transformers.file_utils'
Both cached_path and hf_bucket_url have been removed in recent versions of transformers. Attempting to run the example results in an ImportError.
Changes
Replaced:
from transformers.file_utils import cached_path, hf_bucket_url
...
cached_path(hf_bucket_url(...))
with:
from huggingface_hub import hf_hub_download
...
hf_hub_download(...)
Testing
The code has been successfully tested and runs without error.
Note
This contribution is part of an ongoing research initiative to systematically identify and correct faulty example code in Hugging Face Model Cards.
We would appreciate a timely review and integration of this patch to support code reliability and enhance reproducibility for downstream users.