# OSError When Trying to Load Model from Local Disk (Offline)

**URL:** <https://discuss.huggingface.co/t/oserror-when-trying-to-load-model-from-local-disk-offline/86308>\
**Category:** Models\
**Created:** [May 12, 2024, 5:28am UTC](https://discuss.huggingface.co/t/oserror-when-trying-to-load-model-from-local-disk-offline/86308 "2024-05-12T05:28:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![master-pc9845x](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/master-pc9845x/32/26876_2.png) [@master-pc9845x](https://discuss.huggingface.co/u/master-pc9845x)\
**Post date:** [May 12, 2024, 5:28am UTC](https://discuss.huggingface.co/t/oserror-when-trying-to-load-model-from-local-disk-offline/86308/1 "2024-05-12T05:28:54Z")

</div>

So I want to load the hugging face from my local folder and train my model with it.

However, I get this error:

```auto
OSError: Incorrect path_or_model_id: '/distilgpt2'. Please provide either the path to a local folder or the repo_id of a model on the Hub.

```

```auto
# https://www.linkedin.com/advice/1/how-do-you-use-hugging-face-natural-language-processing-q4gve

# Models
# microsoft/phi-1_5
# distilbert/distilbert-base-uncased
# google-t5/t5-base
# deberta-v3-base

import pandas as pd
import torch
import transformers as tm #import BertLMHeadModel, AutoModelForMaskedLM, AutoModelForSeq2SeqLM, AutoModelForCausalLM, AutoModel, AutoModelForSequenceClassification, GPT2LMHeadModel,PhiForCausalLM, GPT2Tokenizer, AutoTokenizer, GPT2TokenizerFast
import os
import datasets as ds
from trl import SFTTrainer
import json

parent = os.path.dirname(os.getcwd())
fileName=parent+'\\amazon-kdd-cup-2024-starter-kit\data\development.json'
# fileName="./dev/data.json"
file=open(fileName)
# myData = ds.load_dataset("json", data_files=fileName, split="train")
myData=pd.read_json(fileName, lines=True)

testInput=myData["input_field"]
testMCQ=myData["is_multiple_choice"]

for i in range(len(myData)):
    tuple=list(zip(testInput, testMCQ))
    testData=pd.DataFrame(tuple, columns=['input_field', 'is_multiple_choice'])

 
testDataSet=ds.Dataset.from_pandas(testData)
print(testDataSet["input_field"])
print(testDataSet["is_multiple_choice"])

model_name="/distilgpt2"
model = tm.AutoModelForCausalLM.from_pretrained(model_name) # for phi-1_5
tokenizer = tm.AutoModelForCausalLM.from_pretrained(model_name, use_fast=False)

training_args = tm.TrainingArguments(
            output_dir="./",
            per_device_train_batch_size=16,
            learning_rate=2e-4,
            lr_scheduler_type="cosine",
            num_train_epochs=3,
            gradient_accumulation_steps=2, # simulate larger batch sizes
)

trainer = SFTTrainer(
    model,
    train_dataset=testDataSet,
    dataset_text_field="input_field",
    max_seq_length=3,
)

trainer.train()

```

How exactly should I specify the local folder name?

---

<div class="post-metadata">

**Author:** ![AyoubEtters](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@AyoubEtters](https://discuss.huggingface.co/u/AyoubEtters)\
**Post date:** [June 18, 2024, 1:13am UTC](https://discuss.huggingface.co/t/oserror-when-trying-to-load-model-from-local-disk-offline/86308/2 "2024-06-18T01:13:14Z")

</div>

I have the same error, if you were able to fix it plz can you share it with us.  
this in advance

---

<div class="post-metadata">

**Author:** ![catqaq](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@catqaq](https://discuss.huggingface.co/u/catqaq)\
**Post date:** [August 28, 2024, 11:45am UTC](https://discuss.huggingface.co/t/oserror-when-trying-to-load-model-from-local-disk-offline/86308/3 "2024-08-28T11:45:59Z")

</div>

same idea…
