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

Avoid attempting to set prediction head if non-existent #377

Merged
merged 2 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/transformers/adapters/heads/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,10 +642,14 @@ def set_active_adapters(
# use last adapter name as name of prediction head
if self.active_adapters:
head_setup = parse_heads_from_composition(self.active_adapters)
if head_setup:
if isinstance(head_setup, str):
head_setup = [head_setup]
if head_setup and all(head in self.heads for head in head_setup):
self.active_head = head_setup
else:
logger.info("Could not identify a valid prediction head from setup '{}'.".format(self.active_adapters))
logger.info(
"Could not identify valid prediction head(s) from setup '{}'.".format(self.active_adapters)
)

def add_custom_head(self, head_type, head_name, overwrite_ok=False, set_active=True, **kwargs):
if head_type in self.config.custom_heads:
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/dependency_versions_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"fugashi": "fugashi>=1.0",
"GitPython": "GitPython<3.1.19",
"hf-doc-builder": "hf-doc-builder>=0.3.0",
"huggingface-hub": "huggingface-hub>=0.1.0,<1.0",
"huggingface-hub": "huggingface-hub>=0.1.0,<0.8.0",
"importlib_metadata": "importlib_metadata",
"ipadic": "ipadic>=1.0.0,<2.0",
"isort": "isort>=5.5.4",
Expand Down