ohmeow / blurr

A library that integrates huggingface transformers with the world of fastai, giving fastai devs everything they need to train, evaluate, and deploy transformer specific models.
https://ohmeow.github.io/blurr
Apache License 2.0
289 stars 34 forks source link

blurr Translation High Level API broken #70

Closed kurianbenoy closed 2 years ago

kurianbenoy commented 2 years ago

On running a minor modification of Blurr Translation High level API, it looks broken.

The issue looks like the variable NLP is missing in file

NameError                                 Traceback (most recent call last)
Input In [21], in <module>
      1 #hide-output
----> 2 learn = BlearnerForTranslation.from_data(
      3     translation_df,
      4     pretrained_model_name,
      5     src_lang_name="English",
      6     src_lang_attr="en",
      7     trg_lang_name="Malayalam",
      8     trg_lang_attr="ml",
      9     dl_kwargs={"bs": 16},
     10 )

File /opt/conda/lib/python3.8/site-packages/blurr/text/modeling/seq2seq/translation.py:111, in BlearnerForTranslation.from_data(cls, data, pretrained_model_name_or_path, src_lang_name, src_lang_attr, trg_lang_name, trg_lang_attr, max_length, max_target_length, dblock_splitter, hf_tok_kwargs, text_gen_kwargs, dl_kwargs, learner_kwargs)
    109 model_cls = cls.get_model_cls()
    110 model = model_cls.from_pretrained(pretrained_model_name_or_path)
--> 111 hf_arch = NLP.get_model_architecture(type(model).__name__)
    113 if hf_arch == "mbart":
    114     hf_tok_kwargs = {**{"src_lang": "en_XX", "tgt_lang": "en_XX"}, **hf_tok_kwargs}

NameError: name 'NLP' is not defined
kurianbenoy commented 2 years ago

Issue can be reproduced with this gist:

https://gist.github.com/kurianbenoy/812512abae60a57851786958e33c1144

fanbyprinciple commented 2 years ago

facing the same issue here ! :(

ohmeow commented 2 years ago

Good catch.

Had to remove the NLP singleton because it made the library unusable on kaggle. Will fix this in next couple of days and issue a new release.