# Model loading in Colab but not Jupyterlab?!

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodel-loading-in-colab-but-not-jupyterlab%2F154082%3E%5C
**Category:** Spaces\
**Created:** [May 8, 2025, 8:37am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodel-loading-in-colab-but-not-jupyterlab%2F154082 "2025-05-08T08:37:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dagriffpatchfan](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@Dagriffpatchfan](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FDagriffpatchfan)%5C
**Post date:** [May 8, 2025, 8:37am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodel-loading-in-colab-but-not-jupyterlab%2F154082%2F1 "2025-05-08T08:37:41Z")

</div>

Hi,  
I just finetuned Tiny-Llama as tiny-sajar, a little experiment to test finetuning. Running the following code in google colab:

```auto
from transformers import AutoModelForCausalLM, AutoTokenizer

# Replace with your model's path on the Hub
model = AutoModelForCausalLM.from_pretrained("Dagriffpatchfan/tiny-sajar")
tokenizer = AutoTokenizer.from_pretrained("Dagriffpatchfan/tiny-sajar")

```

Worked perfectly, loading the model. I was then able to run the following code:

```auto
questions = [
    "Questions here",
]

for question in questions:
    prompt = f"{question}"
    inputs = tokenizer(prompt, return_tensors="pt")
    outputs = model.generate(
        inputs.input_ids,
        max_length=100, # Maximum number of tokens to generate
        num_return_sequences=1, # Number of separate completions to generate
        temperature=0.7, # Sampling temperature (lower is more focused, higher is more random)
        top_p=0.9, # Nucleus sampling
        do_sample=True # Enable sampling
    )

    # Decode the generated text
    generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
    print(f" **{question}** \n{generated_text}\n")

```

Which generated text as expected. I went to try this in a jupyterlab space and to my complete surprise I got the following error when I tried to load the model:  
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[7], line 4 1 from transformers import AutoModelForCausalLM, AutoTokenizer 3 # Replace with your model’s path on the Hub ----\> 4 model = AutoModelForCausalLM.from\_pretrained(“Dagriffpatchfan/tiny-sajar”) 5 tokenizer = AutoTokenizer.from\_pretrained(“Dagriffpatchfan/tiny-sajar”) 7 questions = [8 “Who are you, and what is your role in the story?”, 9 “How did you come to know David and the Avengers?”, (…) 17 “If you had to pick one person to go on a mission with, who would it be and why?” 18] File [~/miniconda/lib/python3.9/site-packages/transformers/models/auto/auto\_factory.py:531](https://dagriffpatchfan-jupyterlab.hf.space/lab/tree/~/miniconda/lib/python3.9/site-packages/transformers/models/auto/auto_factory.py#line=530), in \_BaseAutoModelClass.from\_pretrained(cls, pretrained\_model\_name\_or\_path, \*model\_args, \*\*kwargs) 528 if kwargs.get(“quantization\_config”, None) is not None: 529 \_ = kwargs.pop(“quantization\_config”) → 531 config, kwargs = AutoConfig.from\_pretrained( 532 pretrained\_model\_name\_or\_path, 533 return\_unused\_kwargs=True, 534 trust\_remote\_code=trust\_remote\_code, 535 code\_revision=code\_revision, 536 \_commit\_hash=commit\_hash, 537 \*\*hub\_kwargs, 538 \*\*kwargs, 539 ) 541 # if torch\_dtype=auto was passed here, ensure to pass it on 542 if kwargs\_orig.get(“torch\_dtype”, None) == “auto”: File [~/miniconda/lib/python3.9/site-packages/transformers/models/auto/configuration\_auto.py:1151](https://dagriffpatchfan-jupyterlab.hf.space/lab/tree/~/miniconda/lib/python3.9/site-packages/transformers/models/auto/configuration_auto.py#line=1150), in AutoConfig.from\_pretrained(cls, pretrained\_model\_name\_or\_path, \*\*kwargs) 1148 if pattern in str(pretrained\_model\_name\_or\_path): 1149 return CONFIG\_MAPPING[pattern].from\_dict(config\_dict, \*\*unused\_kwargs) → 1151 raise ValueError( 1152 f"Unrecognized model in {pretrained\_model\_name\_or\_path}. " 1153 f"Should have a `model_type` key in its {CONFIG\_NAME}, or contain one of the following strings " 1154 f"in its name: {', '.join(CONFIG\_MAPPING.keys())}" 1155 ) ValueError: Unrecognized model in Dagriffpatchfan/tiny-sajar. Should have a `model_type` key in its config.json, or contain one of the following strings in its name: albert, align, altclip, aria, aria\_text, audio-spectrogram-transformer, autoformer, aya\_vision, bamba, bark, bart, beit, bert, bert-generation, big\_bird, bigbird\_pegasus, biogpt, bit, blenderbot, blenderbot-small, blip, blip-2, bloom, bridgetower, bros, camembert, canine, chameleon, chinese\_clip, chinese\_clip\_vision\_model, clap, clip, clip\_text\_model, clip\_vision\_model, clipseg, clvp, code\_llama, codegen, cohere, cohere2, colpali, conditional\_detr, convbert, convnext, convnextv2, cpmant, ctrl, cvt, dab-detr, dac, data2vec-audio, data2vec-text, data2vec-vision, dbrx, deberta, deberta-v2, decision\_transformer, deepseek\_v3, deformable\_detr, deit, depth\_anything, depth\_pro, deta, detr, diffllama, dinat, dinov2, dinov2\_with\_registers, distilbert, donut-swin, dpr, dpt, efficientformer, efficientnet, electra, emu3, encodec, encoder-decoder, ernie, ernie\_m, esm, falcon, falcon\_mamba, fastspeech2\_conformer, flaubert, flava, fnet, focalnet, fsmt, funnel, fuyu, gemma, gemma2, gemma3, gemma3\_text, git, glm, glm4, glpn, got\_ocr2, gpt-sw3, gpt2, gpt\_bigcode, gpt\_neo, gpt\_neox, gpt\_neox\_japanese, gptj, gptsan-japanese, granite, granitemoe, granitemoeshared, granitevision, graphormer, grounding-dino, groupvit, helium, hiera, hubert, ibert, idefics, idefics2, idefics3, idefics3\_vision, ijepa, imagegpt, informer, instructblip, instructblipvideo, jamba, jetmoe, jukebox, kosmos-2, layoutlm, layoutlmv2, layoutlmv3, led, levit, lilt, llama, llama4, llama4\_text, llava, llava\_next, llava\_next\_video, llava\_onevision, longformer, longt5, luke, lxmert, m2m\_100, mamba, mamba2, marian, markuplm, mask2former, maskformer, maskformer-swin, mbart, mctct, mega, megatron-bert, mgp-str, mimi, mistral, mistral3, mixtral, mllama, mobilebert, mobilenet\_v1, mobilenet\_v2, mobilevit, mobilevitv2, modernbert, moonshine, moshi, mpnet, mpt, mra, mt5, musicgen, musicgen\_melody, mvp, nat, nemotron, nezha, nllb-moe, nougat, nystromformer, olmo, olmo2, olmoe, omdet-turbo, oneformer, open-llama, openai-gpt, opt, owlv2, owlvit, paligemma, patchtsmixer, patchtst, pegasus, pegasus\_x, perceiver, persimmon, phi, phi3, phi4\_multimodal, phimoe, pix2struct, pixtral, plbart, poolformer, pop2piano, prompt\_depth\_anything, prophetnet, pvt, pvt\_v2, qdqbert, qwen2, qwen2\_5\_vl, qwen2\_audio, qwen2\_audio\_encoder, qwen2\_moe, qwen2\_vl, qwen3, qwen3\_moe, rag, realm, recurrent\_gemma, reformer, regnet, rembert, resnet, retribert, roberta, roberta-prelayernorm, roc\_bert, roformer, rt\_detr, rt\_detr\_resnet, rt\_detr\_v2, rwkv, sam, sam\_vision\_model, seamless\_m4t, seamless\_m4t\_v2, segformer, seggpt, sew, sew-d, shieldgemma2, siglip, siglip2, siglip\_vision\_model, smolvlm, smolvlm\_vision, speech-encoder-decoder, speech\_to\_text, speech\_to\_text\_2, speecht5, splinter, squeezebert, stablelm, starcoder2, superglue, superpoint, swiftformer, swin, swin2sr, swinv2, switch\_transformers, t5, table-transformer, tapas, textnet, time\_series\_transformer, timesformer, timm\_backbone, timm\_wrapper, trajectory\_transformer, transfo-xl, trocr, tvlt, tvp, udop, umt5, unispeech, unispeech-sat, univnet, upernet, van, video\_llava, videomae, vilt, vipllava, vision-encoder-decoder, vision-text-dual-encoder, visual\_bert, vit, vit\_hybrid, vit\_mae, vit\_msn, vitdet, vitmatte, vitpose, vitpose\_backbone, vits, vivit, wav2vec2, wav2vec2-bert, wav2vec2-conformer, wavlm, whisper, xclip, xglm, xlm, xlm-prophetnet, xlm-roberta, xlm-roberta-xl, xlnet, xmod, yolos, yoso, zamba, zamba2, zoedepth

I found this very confusing…does anyone know what I am experiencing?

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [May 8, 2025, 11:55pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodel-loading-in-colab-but-not-jupyterlab%2F154082%2F2 "2025-05-08T23:55:50Z")

</div>

Since it includes models close to the latest ones such as Gemma 3, the Transoformers version is likely to be almost the latest. In fact, even older Transoformers models should work with the Llama architecture. This is indeed a strange error. The cause is probably not the code or the model itself.

There seems to be a possibility of errors occurring in hf\_transfer related to Jupyter. In other words, there may be an error in the download.

> [@AutoTokenizer.from\_pretrained() suddenly raises an error](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fautotokenizer-from-pretrained-suddenly-raises-an-error%2F153809%2F4)%3A
>
> OK since this was an EnvironmentError I checked everything and I think I have found the culprit. In my bashrc, I had export HF\_HUB\_ENABLE\_HF\_TRANSFER=1 set which means the problem might have something to do with an inconsistency with the hf-transfer package. Reading Hugging Face’s [Environment Variable documentation](https://huggingface.co/docs/huggingface_hub/v0.31.0/package_reference/environment_variables) gave the clue about the possibility of such incidents and undefined behavior HF\_HUB\_ENABLE\_HF\_TRANSFER Set to True to download files from the Hub using hf\_transfer. It’s a Rust-bas…

---

<div class="post-metadata">

**Author:** ![Dagriffpatchfan](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@Dagriffpatchfan](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FDagriffpatchfan)%5C
**Post date:** [May 11, 2025, 10:21pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodel-loading-in-colab-but-not-jupyterlab%2F154082%2F3 "2025-05-11T22:21:32Z")

</div>

So I should set  
`export HF_HUB_ENABLE_HF_TRANSFER=1`  
to 0 instead of 1?

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [May 11, 2025, 11:28pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodel-loading-in-colab-but-not-jupyterlab%2F154082%2F4 "2025-05-11T23:28:05Z")

</div>

Yea. Or maybe try reinstalling `hf_transfer`. If that’s the cause.

```auto
pip install -U hf_transfer hf_xet

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsystem)%5C
**Post date:** [May 15, 2025, 11:33pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodel-loading-in-colab-but-not-jupyterlab%2F154082%2F5 "2025-05-15T23:33:42Z")

</div>

Closed on May 15, 2025, 11:33pm UTC

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
