Suppose I have a list of weighted keywords/phrases, such as "solar panel", "rooftop", etc. The weights are in [0,1] with higher weights indicating a stronger preference for specific keywords, so "solar panel" may have a weighting of 0.3 and "rooftop" may have a weighting of 0.2, for example. The sum of keyword weights is 1.

For each keyword/phrase, I additionally have a number of contextual sentences which are also weighted and carry a positive, negative, or neutral sentiment/connotation. For example, one contextual sentence related to the "solar panel" phrase might be "good for the environment" which is labelled with a positive sentiment and carries a weight of 0.2. The sum of weights for each keyword's contextual sentences is 1, so the sum of weights for all contextual sentences across all keywords is N, where N is the number of individual keywords.

Finally, I also have weighted linkages in [0,1] between keywords/phrases which, again, sum to 1. For example, the directed linkage from "solar panel" to "rooftop" may have a weight of 0.2 while the directed linkage from "rooftop" to "solar panel" may have a weight of 0.4.

I would like to use these weighted keywords, phrases, contextual sentiment-labelled sentences and linkages to create a summary in natural language. I realise that I'm working in reverse from the typical text summarisation objective, but I believe that the richness of my data should make the task a little easier.

How should I approach it? Should I first use a model to summarise the text contained within each of the contextual sentences before attempting to extract more basic keywords that can be used to generate summary text? How should I process the data? Is it worth pursuing a two-step approach, where a basic model summarises the keywords and contextual sentences in basic language before a secondary model transforms it to richer, more natural language?

I would be very grateful for any guidance or recommendations.

Edit: I'm very new to NLP, so I apologise for my lack of terminology and mathematical formalism.


1 Answer 1


If you have data with a good score system, I would start with something simple, because using a neural network like Bert might be complex to set up.

Something simple is to take the scores and build a phrase with meaning, for instance: "solar panel" + "rooftop" + "environment-friendly" = "Rooftop solar panel, with a low environmental impact (less than 8g of carbon/year)".

You can achieve this using if/then rules and some basic equations if there is numerical values. For example, 0.2 for the environmental impact would be something like (1-0.2)*10 = 8g.

Then you can improve results with a neural network like Bert, but you would need enough data to train it, using different inputs ("0.2,0.6,0.1") and their associated outputs (-> "Rooftop solar panel, with a low environmental impact (less than 8g of carbon/year)") and this train data should be representative enough of most common use cases.

See: https://chriskhanhtran.github.io/posts/extractive-summarization-with-bert/

  • 1
    $\begingroup$ Thanks for your suggestions, @Nicolas. It looks as though there already exists a transformer library (gagan3012/keytotext) that achieves more or less what I want it to; that is, abstractive text summarisation from keywords alone. However I think it would achieve much higher fidelity if I were to use an approach like yours first before calling the keytotext function. I imagine a multi-layered approach would offer the best possible outcome. $\endgroup$
    – Jeff
    Oct 25, 2022 at 10:51
  • $\begingroup$ Good to know. Thanks @Jeff $\endgroup$ Oct 25, 2022 at 12:56
  • $\begingroup$ If the answer is correct, could you validate it @Jeff ? $\endgroup$ Oct 29, 2022 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.