ValueError: 'cohere' is already used by a Transformers config, pick another name.
Author: Ronnie-Leon76
Pull request: no

### System Info

- `transformers` version: 4.39.0.dev0
- Platform: Linux-6.1.58+-x86_64-with-glibc2.35
- Python version: 3.10.12
- Huggingface_hub version: 0.20.3
- Safetensors version: 0.4.2
- Accelerate version: 0.28.0
- Accelerate config: 	not found
- PyTorch version (GPU?): 2.2.0+cu121 (True)
- Tensorflow version (GPU?): 2.15.0 (True)
- Flax version (CPU?/GPU?/TPU?): 0.8.1 (cpu)
- Jax version: 0.4.23
- JaxLib version: 0.4.23
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

### Who can help?

@ArthurZucker and @younes

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

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

### Reproduction

!pip install transformers bitsandbytes accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig

bnb_config = BitsAndBytesConfig(load_in_8bit=True)

model_id = "CohereForAI/c4ai-command-r-v01"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True, quantization_config=bnb_config)


![Screenshot from 2024-03-16 20-18-24](https://github.com/huggingface/transformers/assets/60542881/46f2ed34-ec4c-4057-9092-2acf66244ad8)


### Expected behavior

![Screenshot from 2024-03-16 20-18-24](https://github.com/huggingface/transformers/assets/60542881/5efbc088-0d0d-4739-a7dd-d73c6707d667)
 
Error
ValueError: 'cohere' is already used by a Transformers config, pick another name.

Comments:
Looks like you're on transformers dev version, which already supports cohere. Do not use `trust_remote_code`.

Thanks. Let me modify it accordingly.


On Sun, Mar 17, 2024 at 8:52 AM AlpinDale ***@***.***> wrote:

> Looks like you're on transformers dev version, which already supports
> cohere. Do not use trust_remote_code.
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/transformers/issues/29692#issuecomment-2002321303>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AON47IJAIZP73SBNDKDRTW3YYUVR5AVCNFSM6AAAAABEZPM742VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBSGMZDCMZQGM>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>


Thanks @AlpinDale +: 
```python 
model_id = "CohereForAI/c4ai-command-r-v01"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=bnb_config)
```
should now work. Closing as completed

@ArthurZucker Sorry I have some questions but I use transformers version 4.39.3 but I still have this problem，`ValueError: 'cohere' is already used by a Transformers config, pick another name.`  I don't understand. How should I solve it?

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
根据上面已经将trust_remote_code删除但是仍报错如下
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
Traceback (most recent call last):
  File "D:\WH\Project\User_work\LLM\llm\command.py", line 19, in <module>
    model = AutoModelForCausalLM.from_pretrained(model_id)
  File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\site-packages\transformers\models\auto\auto_factory.py", line 563, in from_pretrained
    return model_class.from_pretrained(
  File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\site-packages\transformers\modeling_utils.py", line 3039, in from_pretrained
    config.quantization_config = AutoHfQuantizer.merge_quantization_configs(
  File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\site-packages\transformers\quantizers\auto.py", line 149, in merge_quantization_configs
    quantization_config = AutoQuantizationConfig.from_dict(quantization_config)
  File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\site-packages\transformers\quantizers\auto.py", line 79, in from_dict
    return target_cls.from_dict(quantization_config_dict)
  File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\site-packages\transformers\utils\quantization_config.py", line 94, in from_dict
    config = cls(**config_dict)
  File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\site-packages\transformers\utils\quantization_config.py", line 281, in __init__
    self.post_init()
  File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\site-packages\transformers\utils\quantization_config.py", line 327, in post_init
    if self.load_in_4bit and not version.parse(importlib.metadata.version("bitsandbytes")) >= version.parse(
  File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\importlib\metadata.py", line 569, in version
    return distribution(distribution_name).version
  File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\importlib\metadata.py", line 542, in distribution
    return Distribution.from_name(distribution_name)
  File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\importlib\metadata.py", line 196, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: bitsandbytes

> tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained(model_id) 根据上面已经将trust_remote_code删除但是仍报错如下 Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained. Traceback (most recent call last): File "D:\WH\Project\User_work\LLM\llm\command.py", line 19, in model = AutoModelForCausalLM.from_pretrained(model_id) File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\site-packages\transformers\models\auto\auto_factory.py", line 563, in from_pretrained return model_class.from_pretrained( File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\site-packages\transformers\modeling_utils.py", line 3039, in from_pretrained config.quantization_config = AutoHfQuantizer.merge_quantization_configs( File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\site-packages\transformers\quantizers\auto.py", line 149, in merge_quantization_configs quantization_config = AutoQuantizationConfig.from_dict(quantization_config) File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\site-packages\transformers\quantizers\auto.py", line 79, in from_dict return target_cls.from_dict(quantization_config_dict) File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\site-packages\transformers\utils\quantization_config.py", line 94, in from_dict config = cls(**config_dict) File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\site-packages\transformers\utils\quantization_config.py", line 281, in **init** self.post_init() File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\site-packages\transformers\utils\quantization_config.py", line 327, in post_init if self.load_in_4bit and not version.parse(importlib.metadata.version("bitsandbytes")) >= version.parse( File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\importlib\metadata.py", line 569, in version return distribution(distribution_name).version File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\importlib\metadata.py", line 542, in distribution return Distribution.from_name(distribution_name) File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\importlib\metadata.py", line 196, in from_name raise PackageNotFoundError(name) importlib.metadata.PackageNotFoundError: bitsandbytes

解决：
https://github.com/huggingface/transformers/issues/25210
【
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, low_cpu_mem_usage = True)
】

再次报错：
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
Loading checkpoint shards:  60%|██████    | 3/5 [00:05<00:03,  1.95s/it]
Traceback (most recent call last):
  File "D:\WH\Project\User_work\LLM\llm\command.py", line 19, in <module>
    model = AutoModelForCausalLM.from_pretrained(model_id, low_cpu_mem_usage = True)
  File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\site-packages\transformers\models\auto\auto_factory.py", line 563, in from_pretrained
    return model_class.from_pretrained(
  File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\site-packages\transformers\modeling_utils.py", line 3531, in from_pretrained
    ) = cls._load_pretrained_model(
  File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\site-packages\transformers\modeling_utils.py", line 3938, in _load_pretrained_model
    state_dict = load_state_dict(shard_file, is_quantized=is_quantized)
  File "D:\JY\anaconda3\envs\Langchain-Chatchat\lib\site-packages\transformers\modeling_utils.py", line 506, in load_state_dict
    with safe_open(checkpoint_file, framework="pt") as f:
safetensors_rust.SafetensorError: Error while deserializing header: MetadataIncompleteBuffer

> @ArthurZucker Sorry I have some questions but I use transformers version 4.39.3 but I still have this problem，`ValueError: 'cohere' is already used by a Transformers config, pick another name.` I don't understand. How should I solve it?
`remove the trust_remote_code=True, I work well`


Just don't use `trust_remote_code=True` 

`safetensors_rust.SafetensorError: Error while deserializing header: MetadataIncompleteBuffer` bit weird the download may be conrrupted / space issues