Cannot load labels from old models
# ❓ Questions & Help

If I load a model from 2.8 or older in 2.9 o newer, the labels from my model are changed automatically so all the tests in my code start to fail because instead of predicting `I-PER` it predicts `LABEL_2`.

After reading the source code I think I found what happens but I'm not quite sure.  I think it all started here in #3967

https://github.com/huggingface/transformers/blob/e7cfc1a313cc928e962bb8699868f5dcf46f11eb/src/transformers/configuration_utils.py#L123

In the code above you can see that the labels dicts are modified if we set `num_labels`. I couldn't find the place in the code where that is done, but it definetly modifies 2 attributes from the class. I don't really think that a setter for attribute A, should change attributes B and C.

Am I missing something when loading my models?

Thanks you so much for reading and for the library, we all love it <3

I think I see where that could be a problem, indeed. Do you mind sharing your model configuration file so that I may take a closer look?<|||||>Here it is:

```
{
  "architectures": [
    "BertForTokenClassification"
  ],
  "attention_probs_dropout_prob": 0.3,
  "bos_token_id": 0,
  "do_sample": false,
  "eos_token_ids": 0,
  "finetuning_task": null,
  "hidden_act": "gelu",
  "hidden_dropout_prob": 0.3,
  "hidden_size": 768,
  "id2label": {
    "0": "I-MISC",
    "1": "B-MISC",
    "2": "O",
    "3": "I-LOC",
    "4": "I-ORG",
    "5": "B-LOC",
    "6": "B-ORG",
    "7": "I-PER",
    "8": "B-PER"
  },
  "initializer_range": 0.02,
  "intermediate_size": 3072,
  "is_decoder": false,
  "label2id": {
    "I-MISC": 0,
    "B-MISC": 1,
    "O": 2,
    "I-LOC": 3,
    "I-ORG": 4,
    "B-LOC": 5,
    "B-ORG": 6,
    "I-PER": 7,
    "B-PER": 8
  },
  "layer_norm_eps": 1e-12,
  "length_penalty": 1.0,
  "max_length": 20,
  "max_position_embeddings": 512,
  "model_type": "bert",
  "num_attention_heads": 12,
  "num_beams": 1,
  "num_hidden_layers": 12,
  "num_labels": 9,
  "num_return_sequences": 1,
  "output_attentions": false,
  "output_hidden_states": false,
  "output_past": true,
  "pad_token_id": 0,
  "pruned_heads": {},
  "repetition_penalty": 1.0,
  "temperature": 1.0,
  "top_k": 50,
  "top_p": 1.0,
  "torchscript": false,
  "type_vocab_size": 2,
  "use_bfloat16": false,
  "vocab_size": 28996
}
```
<|||||>@GuillemGSubies Thanks for reporting, I can reproduce this issue.

To fix it on your side while we push a fix, you can just remove the `num_labels` attribute from your config.json, it's not needed anymore. Let me know if this solves your issue.<|||||>Thanks you very much. I will do that :heart: <|||||>Should also be fixed on master by 751a1e08904fda197366e4b0033bdfb8b10d256c