At HuggingFace, if a model has weights stored in .safetensors file(s), must there also…
- User
At HuggingFace, if a model has weights stored in .safetensors file(s), must there also be a config.json file present?
- Assistant
As of my last update in January 2023, for models at Hugging Face (primarily used with the transformers library), the presence of a
.config.jsonfile is typically necessary alongside the model weights, which might be stored in a.safetensorsfile or other formats (like PyTorch's.binfiles).The
config.jsonfile in the Hugging Face model repository contains all the necessary configuration parameters needed for a model. This includes settings like the model architecture, size, number of layers, activation functions, vocabulary size, and other model-specific parameters. The configuration file allows users to understand and replicate the model settings without needing to manually define these parameters in their code.In the scenario where a model's weights are stored in
.safetensorsformat, a correspondingconfig.jsonfile should be present to provide the necessary configuration for effectively loading and utilizing the model weights. Without the configuration file, you typically can't instantiate the model architecture correctly into which the weights would be loaded.