bert-extractive-summarizer: Error when using custom BERT models.
When trying to use a custom model specifying the path, the class throws an error at the line: /summarizer/BertParent.py, line 41. The error is AttributeError: 'NoneType' object has no attribute 'from_pretrained'.
I think that the line:
base_model, base_tokenizer = self.MODELS.get(model, (None, None))
should become something like:
base_model, base_tokenizer = self.MODELS.get(model, (model, model))
when model specify the path to the custom bert model.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 17 (9 by maintainers)
You should be able to load a custom (Transformers based) model using the library. Here is an example from the readme, let me know if it you are still having issues.
Whoops, looks like I fixed one part, but need to fix the summarizer contract. I will get to that this weekend.
I am having the same issue: I am trying to load trained model using:
ext_model = Summarizer(model="../models/CNN_DailyMail_Extractive/bertext_cnndm_transformer.pt")I also tried to useext_model = Summarizer(custom_model="../models/CNN_DailyMail_Extractive/bertext_cnndm_transformer.pt")However, I have the following error:File "/usr/local/lib/python3.6/dist-packages/summarizer/BertParent.py", line 38, in __init__ self.model = base_model.from_pretrained(model, output_hidden_states=True) AttributeError: 'NoneType' object has no attribute 'from_pretrained'Sorry, I actually fixed this last night, and forgot to commit. I will update when I get home this evening.