# Error loading phi3 models

**URL:** <https://discuss.huggingface.co/t/error-loading-phi3-models/146730>\
**Category:** Models\
**Created:** [March 21, 2025, 3:45am UTC](https://discuss.huggingface.co/t/error-loading-phi3-models/146730 "2025-03-21T03:45:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hannahye](https://avatars.discourse-cdn.com/v4/letter/h/f17d59/32.png) [@hannahye](https://discuss.huggingface.co/u/hannahye)\
**Post date:** [March 21, 2025, 3:45am UTC](https://discuss.huggingface.co/t/error-loading-phi3-models/146730/1 "2025-03-21T03:45:47Z")

</div>

Hi,  
I used the basic automodel function to load phi3-mini model. But encountered configuration class error. Full code and error below.

```auto
# Load model directly
from transformers import AutoTokenizer, TFAutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct", trust_remote_code=True)
model = TFAutoModelForCausalLM.from_pretrained("microsoft/Phi-3-mini-4k-instruct", trust_remote_code=True)

```

```auto
ValueError: Unrecognized configuration class <class 'transformers_modules.microsoft.Phi-3-mini-4k-instruct.0a67737cc96d2554230f90338b163bc6380a2a85.configuration_phi3.Phi3Config'> for this kind of AutoModel: TFAutoModelForCausalLM.
Model type should be one of BertConfig, CamembertConfig, CTRLConfig, GPT2Config, GPT2Config, GPTJConfig, MistralConfig, OpenAIGPTConfig, OPTConfig, RemBertConfig, RobertaConfig, RobertaPreLayerNormConfig, RoFormerConfig, TransfoXLConfig, XGLMConfig, XLMConfig, XLMRobertaConfig, XLNetConfig.

```

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [March 21, 2025, 7:30am UTC](https://discuss.huggingface.co/t/error-loading-phi3-models/146730/2 "2025-03-21T07:30:17Z")

</div>

Maybe this will work?

Your code is probably in a state where it is trying to load in TensorFlow format.

```py
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-3-mini-4k-instruct", trust_remote_code=True)

```
