ValueError: Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' 'truncation=True' to have batched tensors with the same length,medalpaca & lora

dnovak232
Tue, 09 Jan 2024 15:08:54 +0000

Federic:

==0.4.7

Does not work for mistral

KeyError Traceback (most recent call last)
Cell In[15], line 13
4 compute_dtype = getattr(torch, bnb_4bit_compute_dtype)
6 bnb_config = BitsAndBytesConfig(
7 load_in_4bit=use_4bit,
8 bnb_4bit_quant_type=bnb_4bit_quant_type,
9 bnb_4bit_compute_dtype=compute_dtype,
10 bnb_4bit_use_double_quant=use_nested_quant,
11 )
—> 13 base_model = AutoModelForCausalLM.from_pretrained(
14 model_name,
15 quantization_config=bnb_config,
16 device_map={“”: 0}
17 )
19 base_model.config.use_cache = False
20 base_model.config.pretraining_tp = 1

File /opt/conda/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py:461, in _BaseAutoModelClass.from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
458 if kwargs.get(“torch_dtype”, None) == “auto”:
459 _ = kwargs.pop(“torch_dtype”)
→ 461 config, kwargs = AutoConfig.from_pretrained(
462 pretrained_model_name_or_path,
463 return_unused_kwargs=True,
464 trust_remote_code=trust_remote_code,
465 **hub_kwargs,
466 **kwargs,
467 )
469 # if torch_dtype=auto was passed here, ensure to pass it on
470 if kwargs_orig.get(“torch_dtype”, None) == “auto”:

File /opt/conda/lib/python3.10/site-packages/transformers/models/auto/configuration_auto.py:998, in AutoConfig.from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
996 return config_class.from_pretrained(pretrained_model_name_or_path, **kwargs)
997 elif “model_type” in config_dict:
→ 998 config_class = CONFIG_MAPPING[config_dict[“model_type”]]
999 return config_class.from_dict(config_dict, **unused_kwargs)
1000 else:
1001 # Fallback: use pattern matching on the string.
1002 # We go from longer names to shorter names to catch roberta before bert (for instance)

File /opt/conda/lib/python3.10/site-packages/transformers/models/auto/configuration_auto.py:710, in _LazyConfigMapping.getitem(self, key)
708 return self._extra_content[key]
709 if key not in self._mapping:
→ 710 raise KeyError(key)
711 value = self._mapping[key]
712 module_name = model_type_to_module_name(key)

KeyError: ‘mistral’