microsoft / ProphetNet

A research project for natural language generation, containing the official implementations by MSRA NLC team.
MIT License
654 stars 105 forks source link

Abstractive Summarization using prophetnet #23

Open smita181298 opened 3 years ago

smita181298 commented 3 years ago

How to change the number of sentences in predicted summary by prophetnet. I want to control both length and number of sentences for different usecases @yuyan2do .It will be really helpful if you can tell that . Thanks

yuyan2do commented 3 years ago

lenpen is used to control the length, larger value make model prefer longer results. There is no argument to choose number of sentences, but you can handle it in post progress.

--lenpen 1.2

smita181298 commented 3 years ago

Thanks a lot @yuyan2do .can you give idea on how to do this ?

yuyan2do commented 3 years ago

See "Inference and Evaluation" section for how to use argument lenpen.

https://github.com/microsoft/ProphetNet#inference-and-evaluation

smita181298 commented 3 years ago

Thanks and Sorry for the unclear question asked before @yuyan2do. What I meant to ask is can you give an idea on how to handle it in post-progress?

Also, I evaluated the model using a checkpoint created for headline generation on a validation set which has 39 articles. The key in the below dictionary is the number of words in headline predicted by the model and value is no of articles which has a key number of words in the predicted headline.

lenpen==1.2 {6: 5, 9: 12, 7: 6, 12: 3, 8: 3, 10: 5, 11: 4, 13: 1}

for eg: The first item of dictionary shows there are 5 articles for which 6 words are there in the predicted headline by prophetnet.

lenpen==2 {8: 6, 10: 7, 11: 6, 7: 3, 12: 3, 6: 2, 9: 11, 13: 1} lenpen==5 {8: 6, 10: 7, 11: 7, 7: 2, 12: 5, 6: 1, 9: 10, 13: 1} lenpen==50 {6: 9, 5: 2, 7: 9, 12: 2, 8: 7, 9: 5, 10: 1, 11: 2, 13: 1, 4: 1}

I don't seem to understand the effect of lenpen.

Jain-Abhilash commented 3 years ago

@smita181298, len_penalty (float, optional): length penalty, where <1.0 favors shorter, >1.0 favors longer sentences (default: 1.0) From the fairseq github, they implement it in this manner: https://github.com/pytorch/fairseq/blob/8b9eaacf6b2d502cd7886dd7bf702a46ab37f058/fairseq/sequence_generator.py#L537

smita181298 commented 3 years ago

Yes I understand that @Jain-Abhilash len_penalty (float, optional): length penalty, where <1.0 favors shorter, >1.0 favors longer sentences (default: 1.0)

But I don't seem to understand the exact effect of lenpen based on the output of my data using the prophetnet model(which I posted before). Changing lenpen changes the number of words in the generated headline. But I want to generate a summary, not a headline and the maximum number of words in the headline is 13(as per my post before for my data, considering lenpen=50) which can not be considered as summary.

If drastically changing lenpen could have affected the drastic change in the number of words, it could be considered as summary.

Were you able to generate summary using prophetnet @Jain-Abhilash ?