HHousen / TransformerSum

Models to perform neural summarization (extractive and abstractive) using machine learning transformers and a tool to convert abstractive summarization datasets to the extractive task.
https://transformersum.rtfd.io
GNU General Public License v3.0
429 stars 58 forks source link

predictions_website.py raises AttributeError: '_LazyAutoMapping' object has no attribute '_mapping' #58

Closed Laurengcy closed 3 years ago

Laurengcy commented 3 years ago

After creating the transformersum conda env, I tried running python predictions_website.py and it triggers an error:

Traceback (most recent call last):
  File "predictions_website.py", line 8, in <module>
    from extractive import ExtractiveSummarizer  # noqa: E402
  File "/home/msi1/dev_home/transformersum/src/extractive.py", line 39, in <module>
    MODEL_CLASSES = tuple(m.model_type for m in MODEL_MAPPING)  # + CUSTOM_MODEL_CLASSES
  File "/home/msi1/anaconda3/envs/transformersum/lib/python3.7/site-packages/transformers/models/auto/auto_factory.py", line 528, in __iter__
    return iter(self._mapping.keys())
AttributeError: '_LazyAutoMapping' object has no attribute '_mapping'
Usama3627 commented 3 years ago

Experiencing the same issue when trying to import extractive from ExtractiveSummary Initially, the ModuleNotFoundError: No module named 'extractive' error was experienced (as mentioned in issue #59 but it was resolved after changing the directory to src.

Geethi2020 commented 3 years ago

Same issue for me as well, with import extractive from ExtractiveSummary. It used to work a couple of weeks ago. Anything changed recently ?

HHousen commented 3 years ago

This should now be resolved by 1395f378f7b661a1806bc70f653b0e46781dc575. Please let me know if this didn't work.

Geethi2020 commented 3 years ago

Thank you for fixing "_LazyAutoMapping" issue.

But now it triggers a ValueError though (which seems to have originally resolved a while back)

summary         = extrSumm_model.predict(context, raw_scores=False, num_summary_sentences=6)

Error message is

ValueError: [E003] Not a valid pipeline component. Expected callable, but got 'sentencizer' (name: 'None').[E004] If you meant to add a built-in component, use `create_pipe`: `nlp.add_pipe(nlp.create_pipe('sentencizer'))`

Log is

/content/transformersum/src/extractive.py in predict(self, input_text, raw_scores, num_summary_sentences)
   1174         """
   1175         nlp = English()
-> 1176       nlp.add_pipe("sentencizer")
   1177         doc = nlp(input_text)

/usr/local/lib/python3.7/dist-packages/spacy/language.py in add_pipe(self, component, name, before, after, first, last)
    325             if isinstance(component, basestring_) and component in self.factories:
    326                 msg += Errors.E004.format(component=component)
--> 327             raise ValueError(msg)
    328         if name is None:
    329             name = util.get_component_name(component)

Tried making the change as mentioned in the error message; but no luck. Would you please check ?

HHousen commented 3 years ago

Looks like you're using an old version of Spacy (probably v2). Please try upgrading to v3 with pip install -U spacy. Some services (ex: Google Colab) come with v2 installed by default but this library is updated to work with v3.

Geethi2020 commented 3 years ago

That worked. Thank you so much.