From 386e86e22288b08bf8bcc3cff4027c46ba866d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Louf?= Date: Mon, 7 Oct 2019 13:00:06 +0200 Subject: [PATCH] raise exception when class initialized with __init__ --- transformers/modeling_seq2seq.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/transformers/modeling_seq2seq.py b/transformers/modeling_seq2seq.py index 990f35ffedf..b14622e50f5 100644 --- a/transformers/modeling_seq2seq.py +++ b/transformers/modeling_seq2seq.py @@ -17,11 +17,13 @@ class Seq2SeqModel(object): def __init__(self): - # need to use from_pretrained to initialize - raise NotImplementedError + raise EnvironmentError( + """Seq2Seq is designed to be instantiated using the + `Seq2Seq.from_pretrained(encoder_name_or_path, decoder_name_or_path)` method.""" + ) @classmethod - def from_pretrained(cls, encoder, decoder): + def from_pretrained(cls, encoder_name, decoder_name): # Here we should call AutoModel to initialize the models depending # on the pretrained models taken as an input. # For a first iteration we only work with Bert.