ValueError: Unrecognized model in ./trained_model. Should have a `model_type` key in its config.json
Hello everyone,I recently encountered an issue while working with a locally saved finetuned model, and I was hoping to get some guidance. Here’s the situation:I usedtrainer.save_model()to save my finetuned model and was able to use it locally in my Anaconda environment without any problems.Later, I decided to create arequirements.txtfile for my project. However, I noticed that my current environment had too many unnecessary packages.To address this, I deleted the old environment (which, in hindsight, was not the best decision) and created a new, cleaner environment to only install the packages I need.After creating the new environment, I tried to load the saved model, but I keep running into the following error:ValueError: Unrecognized model in ./trained_model. Should have a `model_type` key in its config.json, or contain one of the following strings in its name: albert, align, altclip...Here are the details of my current Anaconda environment:python = 3.11  
cuda version = 12.7  
pytorch-cuda = 12.1I would greatly appreciate any advice or insights on what might be causing this issue and how to resolve it. Thank you in advance for your help!
2025-01-06T11:55:12Z
Hmm, transformers seems the most suspicious…pip install -U transformers accelerate peft huggingface_hubgithub.com/huggingface/transformersValueError: Unrecognized model. Should have a model_type key in its config.jsonopened10:26PM - 24 Aug 24 UTCclosed08:04AM - 02 Oct 24 UTCLujainAlawwadI have trained a custom transformer model as a sequence-to-sequence model, did n…ot finetune an LLM.

My config doesn't specify the model-type, it is as follows:
config = {
  "architecture": "Seq2SeqTransformer",
  "vocab_size": tokenizer.vocab_size,
  "d_model": d_model,
  "num_layers": num_layers,
  "num_heads": num_heads,
  "dim_feedforward": dim_feedforward,
  "save_steps": save_steps
}

But when I try to load it from huggingface, it gives me this error:
**Lu...... Should have a model_type key in its config.json, or contain one of the following strings in its name: albert, align, altclip......**

I do not know which type should be specified.

Please find the layout of my work in this notebook: https://colab.research.google.com/drive/1qwT4mqaTPoVW7HwlWNRKheR7FAzIdR-L#scrollTo=DtU3whBevE31
2025-01-06T12:17:23Z
Thank you so much for your solution—it worked perfectly!I’ve been stuck on this for a while, I truly can’t thank you enough.
2025-01-07T00:17:31Z
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.