Error in downloading and loading the model

#11
by ibibek - opened

Hello,
Thank you so much for the great release. I am using the below code and facing some issues.
The same code works great for Llama-Guard-2

#What I did?

from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-Guard-3-8B")
model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-Guard-3-8B")

Error that I am getting:

`---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[5], line 6
3 from transformers import AutoTokenizer, AutoModelForCausalLM
5 tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-Guard-3-8B")
----> 6 model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-Guard-3-8B")

File ~/anaconda3/envs/attentionratio/lib/python3.12/site-packages/transformers/models/auto/auto_factory.py:523, in _BaseAutoModelClass.from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
520 if kwargs.get("quantization_config", None) is not None:
521 _ = kwargs.pop("quantization_config")
--> 523 config, kwargs = AutoConfig.from_pretrained(
524 pretrained_model_name_or_path,
525 return_unused_kwargs=True,
526 trust_remote_code=trust_remote_code,
527 code_revision=code_revision,
528 _commit_hash=commit_hash,
529 **hub_kwargs,
530 **kwargs,
531 )
533 # if torch_dtype=auto was passed here, ensure to pass it on
534 if kwargs_orig.get("torch_dtype", None) == "auto":

File ~/anaconda3/envs/attentionratio/lib/python3.12/site-packages/transformers/models/auto/configuration_auto.py:952, in AutoConfig.from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
946 except KeyError:
947 raise ValueError(
948 f"The checkpoint you are trying to load has model type {config_dict['model_type']} "
949 "but Transformers does not recognize this architecture. This could be because of an "
950 "issue with the checkpoint, or because your version of Transformers is out of date."
951 )
--> 952 return config_class.from_dict(config_dict, **unused_kwargs)
953 else:
954 # Fallback: use pattern matching on the string.
955 # We go from longer names to shorter names to catch roberta before bert (for instance)
956 for pattern in sorted(CONFIG_MAPPING.keys(), key=len, reverse=True):

File ~/anaconda3/envs/attentionratio/lib/python3.12/site-packages/transformers/configuration_utils.py:761, in PretrainedConfig.from_dict(cls, config_dict, **kwargs)
758 # We remove it from kwargs so that it does not appear in return_unused_kwargs.
759 config_dict["attn_implementation"] = kwargs.pop("attn_implementation", None)
--> 761 config = cls(**config_dict)
763 if hasattr(config, "pruned_heads"):
764 config.pruned_heads = {int(key): value for key, value in config.pruned_heads.items()}

File ~/anaconda3/envs/attentionratio/lib/python3.12/site-packages/transformers/models/llama/configuration_llama.py:161, in LlamaConfig.init(self, vocab_size, hidden_size, intermediate_size, num_hidden_layers, num_attention_heads, num_key_value_heads, hidden_act, max_position_embeddings, initializer_range, rms_norm_eps, use_cache, pad_token_id, bos_token_id, eos_token_id, pretraining_tp, tie_word_embeddings, rope_theta, rope_scaling, attention_bias, attention_dropout, **kwargs)
159 self.rope_theta = rope_theta
160 self.rope_scaling = rope_scaling
--> 161 self._rope_scaling_validation()
162 self.attention_bias = attention_bias
163 self.attention_dropout = attention_dropout

File ~/anaconda3/envs/attentionratio/lib/python3.12/site-packages/transformers/models/llama/configuration_llama.py:181, in LlamaConfig._rope_scaling_validation(self)
178 return
180 if not isinstance(self.rope_scaling, dict) or len(self.rope_scaling) != 2:
--> 181 raise ValueError(
182 "rope_scaling must be a dictionary with two fields, type and factor, " f"got {self.rope_scaling}"
183 )
184 rope_scaling_type = self.rope_scaling.get("type", None)
185 rope_scaling_factor = self.rope_scaling.get("factor", None)

ValueError: rope_scaling must be a dictionary with two fields, type and factor, got {'factor': 8.0, 'low_freq_factor': 1.0, 'high_freq_factor': 4.0, 'original_max_position_embeddings': 8192, 'rope_type': 'llama3'}

Meta Llama org

Hi, please update the transformers lib to the latest version (currently 4.43.1), that should solve this.

Sign up or log in to comment