Can not find adapter_config.json using PeftConfig.from_pretrained

I have a huggingface spaces streamlit file
https://huggingface.co/spaces/foobar8675/bloom-7b1-lora-tagger/blob/main/app.py
which is throwing an error

ValueError: Can't find 'adapter_config.json' at 'foobar8675/bloom-7b1-lora-tagger'
Traceback:
File "/home/user/.local/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)
File "/home/user/app/app.py", line 23, in <module>
    config = PeftConfig.from_pretrained(peft_model_id)
File "/home/user/.local/lib/python3.10/site-packages/peft/utils/config.py", line 108, in from_pretrained
    raise ValueError(f"Can't find '{CONFIG_NAME}' at '{pretrained_model_name_or_pa

on this line

peft_model_id = "foobar8675/bloom-7b1-lora-tagger"
config = PeftConfig.from_pretrained(peft_model_id)

the model at foobar8675/bloom-7b1-lora-tagger is public and I verified the adapter_config.json is on the model. i’m quite confused as to why this is happening and any help is appreciated.

1 Like

Hi, I have the same problem with the model bofenghuang/vigogne-chat-7b. While exporting it, it throws an ValueError: Can’t find ‘adapter_config.json’ even if the file exists.

i have the same issue for inference.
ValueError: Can’t find ‘adapter_config.json’ at ‘kirilzilla/alpaca-SGD’

i have the same problem using the file “generate.py” of alpaca-lora repository (GitHub) which calls a file in Peft repository.

I have the same issue as well. Can any one help?

Hey all,

For me the issue was authentication. Running through the stacktrace, if you see something like “Invalid username and password” just after a link to the adapter_config.json file, it’s likely you have the same issue too.

To fix, you’ll need to login to the hub, which can be done programatically using the following snippet:

from huggingface_hub import login
import os

access_token = os.environ["HUGGING_FACE_HUB_TOKEN"]
login(token=access_token)

Hope this helps!

1 Like

use this

model.config.to_json_file(“adapter_config.json”)

then
model.push_to_hub(“model name”)

2 Likes

For whom having this issue while doing SFT, in my case it was because I omitted get_peft_model before SFTTrainer. Per HF docs, get_peft_model wraps base model and peft_config into PeftModel. So if you don’t do get_peft_model, model would be just AutoCasualLM not AutoPeftCasualLM. Therefore, when to do model.push_to_hub, the files being uploaded will be model.safetensors and config.json, not adapter_config.json and adapter_model.safetensors.

1 Like