dmmiller612 / bert-extractive-summarizer

Easy to use extractive text summarization with BERT
MIT License
1.38k stars 305 forks source link

Num Sentences error #89

Closed krrishdholakia closed 3 years ago

krrishdholakia commented 3 years ago

Hi,

trying to follow the num sentences example

result = model(body, num_sentences=3)

the error i'm getting is:

TypeError: __call__() got an unexpected keyword argument 'num_sentences'

dmmiller612 commented 3 years ago

What version are you using of bert-extractive-summarizer?

michael81045 commented 3 years ago

I also have the same problem. Here is my version of requirements: bert-extractive-summarizer = 0.4.2 transformers = 2.2.2 spacy = 2.3.4 numpy = 1.19.4 torch = 1.7.0+cpu tqdm = 4.54.0

It still worked last week. but, I got the TypeError today. Can you please help me to figure out what's going on in it? Thank you very much!

dmmiller612 commented 3 years ago

Thanks for the info. num_sentences was introduced in 0.5.1. The most recent version for bert-extractive-summarizer is 0.6.1.

dmmiller612 commented 3 years ago

Closing for now. Let me know if you are still having any problems.

iknoorjobs commented 2 years ago

Hi @dmmiller612

Could you please tell me why the number of returned sentences are sometimes one less than the set num_sentences parameter?

Example code try num_sentences 5 or 4 or 3 ..:

model = SBertSummarizer('all-mpnet-base-v2')
txt = """
A subset of machine learning is closely related to computational statistics. The study of mathematical optimization delivers methods. Theory and application domains to the field of machine learning. Data mining is a related field of study, focusing on exploratory data analysis through unsupervised learning. Some implementations of machine learning use data and neural networks in a way that mimics the working of a biological brain. In its application across business problems, machine learning is also referred to as predictive analytics.
"""
result = model(txt , num_sentences=5, return_as_list=True)
print(len(result))
4

Thanks