Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"use_safetensors" not enforced with "local_files_only", loads bin file #31649

Open
4 tasks
troy-baker-aumni opened this issue Jun 26, 2024 · 0 comments
Open
4 tasks
Labels
Core: Modeling Internals of the library; Models.

Comments

@troy-baker-aumni
Copy link

troy-baker-aumni commented Jun 26, 2024

System Info

  • transformers version: 4.41.2
  • Platform: macOS-14.5-arm64-arm-64bit
  • Python version: 3.11.7
  • Huggingface_hub version: 0.23.1
  • Safetensors version: 0.4.3
  • Accelerate version: not installed
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.3.0 (False)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using GPU in script?: no
  • Using distributed or parallel set-up in script?: no

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

  1. clone model repo (flan-t5-large)
  2. remove model.safetensors from target directory
  3. run code
from transformers import AutoModelForSeq2SeqLM

model = AutoModelForSeq2SeqLM.from_pretrained(
    pretrained_model_name_or_path="path/to/flan-t5-large",
    local_files_only=True,
    use_safetensors=True
)
  1. observe from_pretrained falls back to the pytorch_model.bin file and loads the model

Expected behavior

from_pretrained function should raise an error since no safetensors file is present in the target. If this is the target behavior, perhaps this is a feature request rather than a bug, but I find this to be misleading at best or unsafe at worst. Additionally, it is unclear how to manually direct the from_pretrained function to only load models with a specific name and extension, or to do so with a file loaded using the safetensors library. It is unclear to the user how a model file is chosen from the dir, so at the very minimum, a user should be able to declare the safetensors file themselves as the model file.

@amyeroberts amyeroberts added the Core: Modeling Internals of the library; Models. label Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core: Modeling Internals of the library; Models.
Projects
None yet
Development

No branches or pull requests

2 participants