-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
[AutoModel] Add AutoModelForTextEncoding #24305
Changes from all commits
2a3d77e
8dfc66d
1c7fdde
137b872
5846d40
f748280
9d2e4e2
ee0642d
adc7782
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1011,6 +1011,36 @@ | |
] | ||
) | ||
|
||
MODEL_FOR_TEXT_ENCODING_MAPPING_NAMES = OrderedDict( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this list good for you @amyeroberts? It's the most popular encoder-only architectures, and enc-dec ones where we have the encoder model separated as an import There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep! We can always add as needed :) |
||
[ | ||
("albert", "AlbertModel"), | ||
("bert", "BertModel"), | ||
("big_bird", "BigBirdModel"), | ||
("data2vec-text", "Data2VecTextModel"), | ||
("deberta", "DebertaModel"), | ||
("deberta-v2", "DebertaV2Model"), | ||
("distilbert", "DistilBertModel"), | ||
("electra", "ElectraModel"), | ||
("flaubert", "FlaubertModel"), | ||
("ibert", "IBertModel"), | ||
("longformer", "LongformerModel"), | ||
("mobilebert", "MobileBertModel"), | ||
("mt5", "MT5EncoderModel"), | ||
("nystromformer", "NystromformerModel"), | ||
("reformer", "ReformerModel"), | ||
("rembert", "RemBertModel"), | ||
("roberta", "RobertaModel"), | ||
("roberta-prelayernorm", "RobertaPreLayerNormModel"), | ||
("roc_bert", "RoCBertModel"), | ||
("roformer", "RoFormerModel"), | ||
("squeezebert", "SqueezeBertModel"), | ||
("t5", "T5EncoderModel"), | ||
("xlm", "XLMModel"), | ||
("xlm-roberta", "XLMRobertaModel"), | ||
("xlm-roberta-xl", "XLMRobertaXLModel"), | ||
] | ||
) | ||
|
||
MODEL_MAPPING = _LazyAutoMapping(CONFIG_MAPPING_NAMES, MODEL_MAPPING_NAMES) | ||
MODEL_FOR_PRETRAINING_MAPPING = _LazyAutoMapping(CONFIG_MAPPING_NAMES, MODEL_FOR_PRETRAINING_MAPPING_NAMES) | ||
MODEL_WITH_LM_HEAD_MAPPING = _LazyAutoMapping(CONFIG_MAPPING_NAMES, MODEL_WITH_LM_HEAD_MAPPING_NAMES) | ||
|
@@ -1088,11 +1118,17 @@ | |
|
||
MODEL_FOR_MASK_GENERATION_MAPPING = _LazyAutoMapping(CONFIG_MAPPING_NAMES, MODEL_FOR_MASK_GENERATION_MAPPING_NAMES) | ||
|
||
MODEL_FOR_TEXT_ENCODING_MAPPING = _LazyAutoMapping(CONFIG_MAPPING_NAMES, MODEL_FOR_TEXT_ENCODING_MAPPING_NAMES) | ||
|
||
|
||
class AutoModelForMaskGeneration(_BaseAutoModelClass): | ||
_model_mapping = MODEL_FOR_MASK_GENERATION_MAPPING | ||
|
||
|
||
class AutoModelForTextEncoding(_BaseAutoModelClass): | ||
_model_mapping = MODEL_FOR_TEXT_ENCODING_MAPPING | ||
|
||
|
||
class AutoModel(_BaseAutoModelClass): | ||
_model_mapping = MODEL_MAPPING | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -524,6 +524,9 @@ def __init__(self, *args, **kwargs): | |
MODEL_FOR_TABLE_QUESTION_ANSWERING_MAPPING = None | ||
|
||
|
||
MODEL_FOR_TEXT_ENCODING_MAPPING = None | ||
|
||
|
||
MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING = None | ||
|
||
|
||
|
@@ -726,6 +729,13 @@ def __init__(self, *args, **kwargs): | |
requires_backends(self, ["torch"]) | ||
|
||
|
||
class AutoModelForTextEncoding(metaclass=DummyObject): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be the equivalent There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah perfect! Thanks for flagging! Resolved in 8b003f7 |
||
_backends = ["torch"] | ||
|
||
def __init__(self, *args, **kwargs): | ||
requires_backends(self, ["torch"]) | ||
|
||
|
||
class AutoModelForTokenClassification(metaclass=DummyObject): | ||
_backends = ["torch"] | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TF equivalent class should be in this init too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in 8b003f7