I am trying to run a GitHub project on my computer.
GitHub Repo that I am trying to run
This is the code snippet that is causing errors.
Steps I took for replicating the project are:
- Cloned the repository.
- Generated the Hugging Face access token
- Added
offload_folderandoffload_dict_stateafter reading the Hugging Face guide to load huge models.
def load_llm():
"""
Load the LLM
"""
# Model ID
repo_id = 'meta-llama/Llama-2-7b-chat-hf'
login(token="hf_xxxxxxxx")
# Load the model
model = AutoModelForCausalLM.from_pretrained(
repo_id,
device_map='auto',
load_in_4bit=False,
token = True,
offload_folder = r"C:\Users\DHRUV\Desktop\New folder\Law-GPT",
offload_state_dict = True
)
# Load the tokenizer
tokenizer = AutoTokenizer.from_pretrained(
repo_id,
use_fast=True
)
# Create pipeline
pipe = pipeline(
'text-generation',
model=model,
tokenizer=tokenizer,
max_length=512
)
# Load the LLM
llm = HuggingFacePipeline(pipeline=pipe)
return llm
The Error I am facing, Please help:
Token will not been saved to git credential helper. Pass `add_to_git_credential=True` if you want to set the git credential as well.
Token is valid (permission: read).
Your token has been saved to C:\Users\DHRUV\.cache\huggingface\token
Login successful
Loading checkpoint shards: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<?, ?it/s]
Traceback (most recent call last):
File "C:\Users\DHRUV\Desktop\New folder\Law-GPT\app.py", line 5, in <module>
chain = qa_pipeline()
File "C:\Users\DHRUV\Desktop\New folder\Law-GPT\utils.py", line 100, in qa_pipeline
llm = load_llm()
File "C:\Users\DHRUV\Desktop\New folder\Law-GPT\utils.py", line 44, in load_llm
model = AutoModelForCausalLM.from_pretrained(
File "C:\Users\DHRUV\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\transformers\models\auto\auto_factory.py", line 566, in from_pretrained
return model_class.from_pretrained(
File "C:\Users\DHRUV\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\transformers\modeling_utils.py", line 3773, in from_pretrained
dispatch_model(model, **device_map_kwargs)
File "C:\Users\DHRUV\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\accelerate\big_modeling.py", line 438, in dispatch_model
raise ValueError(
ValueError: You are trying to offload the whole model to the disk. Please use the `disk_offload` function instead.