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

Simplify XAdapterModel implementations #641

Merged
merged 6 commits into from
Feb 17, 2024
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
16 changes: 16 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# https://www.sphinx-doc.org/en/main/usage/configuration.html
import os
import sys
import re


# -- Path setup --------------------------------------------------------------
Expand Down Expand Up @@ -87,6 +88,21 @@
smv_remote_whitelist = None


def skip_head_member(app, what, name, obj, skip, options):
if type(obj).__name__ == "function" and "inherited-members" in options and (m := re.match(r"add\_(.*)\_head$", name)):
cls_name = options["inherited-members"].replace("PreTrainedModel", "AdapterModel").replace("PretrainedModel", "AdapterModel")
cls = vars(sys.modules["adapters"])[cls_name]
# HACK: currently parses head type from name
head_type_str = m.group(1).replace("qa", "question_answering")
if head_type_str in cls.head_types:
return False
else:
return True

return skip


def setup(app):
app.connect('autodoc-skip-member', skip_head_member)
app.add_config_value("recommonmark_config", {"enable_eval_rst": True}, True)
app.add_css_file("custom.css")
1 change: 1 addition & 0 deletions src/adapters/heads/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
from .base import *
from .dependency_parsing import *
from .language_modeling import BertStyleMaskedLMHead, CausalLMHead, Seq2SeqLMHead
from .model_mixin import ModelWithFlexibleHeadsAdaptersMixin
491 changes: 2 additions & 489 deletions src/adapters/heads/base.py

Large diffs are not rendered by default.

Loading
Loading