Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with load_adapter: ValueError: Found multiple possible adapters matching 'en/wiki@ukp'. #163

Closed
gregor-ge opened this issue May 7, 2021 · 3 comments · Fixed by #164
Labels
bug Something isn't working

Comments

@gregor-ge
Copy link

Environment info

  • adapter-transformers version: 2.0.0

Information

Model I am using: bert-base-multilingual-cased

Relevant adapters:
en/wiki@ukp
wikiann/en@ukp

Any other language adapter with another adapter of the form $task/$language_code@ukp works.

To reproduce

Steps to reproduce the behavior:

Try loading one of the language adapters with m-bert.

model = AutoModelWithHeads.from_pretrained("bert-base-multilingual-cased")
model.load_adapter("en/wiki@ukp")
  File "C:\Users\Gregor\Anaconda3\envs\adapter\lib\site-packages\transformers\adapters\utils.py", line 260, in find_in_index
    raise ValueError("Found multiple possible adapters matching '{}'.".format(identifier))
ValueError: Found multiple possible adapters matching 'en/wiki@ukp'.

Expected behavior

The adapter is loaded normally.

Why this happens

Line 252 in transformers\adapters\utils.py calls _dict_extract() (in the same utils.py).
The problematic adapter wikiann/en@ukp matches due to the 'en' in the else-part (line 230) and is yielded which then results in two possible adapters matching 'en/wiki@ukp'.

The else-part should (as far as I can see) not be used if both primary_key and secondary_key is given and should only be evaluated if only a primary_key is given to allow for e.g. mode.load_adapter("cs") instead of mode.load_adapter("cs/wiki@ukp").

@gregor-ge gregor-ge added the bug Something isn't working label May 7, 2021
@gregor-ge
Copy link
Author

Changing line 230 in transformers\adapters\utils.py to elif secondary_key is None: results in the English language adapter loading correctly but I do not know if this has other unintended side-effects.

@calpt
Copy link
Member

calpt commented May 7, 2021

Thanks for the detailed bug report.

Changing line 230 in transformers\adapters\utils.py to elif secondary_key is None: results in the English language adapter loading correctly but I do not know if this has other unintended side-effects.

I think this solution should work. Would you mind opening a PR for it?

gregor-ge pushed a commit to gregor-ge/adapter-transformers that referenced this issue May 7, 2021
@gregor-ge
Copy link
Author

It's open

#164

@calpt calpt closed this as completed in #164 May 7, 2021
calpt pushed a commit that referenced this issue May 7, 2021
…#164)

Co-authored-by: Geigle <gregortheodor.geigle@stud.tu-darmstadt.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants