From 1b9bcb200b5f4f89b3e74737799711b93843cbb0 Mon Sep 17 00:00:00 2001 From: Benjamin Bossan Date: Thu, 23 Jan 2025 12:41:51 +0100 Subject: [PATCH] DOC Add entry to solve unknown config argument (#2340) There have been multiple issues and forum posts in the past asking about errors like: TypeError: LoraConfig.__init__() got an unexpected keyword argument ... This error can occur when the adapter that is being loaded is trained with a more recent PEFT version than the one currently being used. I thus added a section to the Troubleshooting part of our docs to describe the solutions. Note that we already added changes to PEFT in #2038 to make configs forward compatible. But since users who encounter this problem have, by definition, older PEFT versions, they don't benefit from this. --------- Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com> --- .../developer_guides/troubleshooting.md | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/source/developer_guides/troubleshooting.md b/docs/source/developer_guides/troubleshooting.md index 36abb07224..a0d0c91875 100644 --- a/docs/source/developer_guides/troubleshooting.md +++ b/docs/source/developer_guides/troubleshooting.md @@ -290,3 +290,31 @@ config = LoraConfig( ``` Depending on the type of model you use, the batch norm layers could have different names than `"normalization"`, so please ensure that the name matches your model architecture. + +## Version mismatch + +### Error while loading the config because of an unexpected keyword argument + +When you encounter an error like the one shown below, it means the adapter you're trying to load was trained with a more recent version of PEFT than the version you have installed on your system. + +``` +TypeError: LoraConfig.__init__() got an unexpected keyword argument +``` + +The best way to resolve this issue is to install the latest PEFT version: + +```sh +python -m pip install -U PEFT +``` + +If the adapter was trained from a source install of PEFT (an unreleased version of PEFT), then you also need to install PEFT from source. + +```sh +python -m pip install -U git+https://github.com/huggingface/peft.git +``` + +If it is not possible for you to upgrade PEFT, there is a workaround you can try. + +Assume the error message says that the unknown keyword argument is named `foobar`. Search inside the `adapter_config.json` of this PEFT adapter for the `foobar` entry and delete it from the file. Then save the file and try loading the model again. + +This solution works most of the time. As long as it is the default value for `foobar`, it can be ignored. However, when it is set to some other value, you will get incorrect results. Upgrading PEFT is the recommended solution.