Text summarization condenses lengthy documents while retaining important information and meaning. It assists users in efficiently processing large amounts of information in a variety of industries such as news, education, business, and healthcare. Despite their benefits, text summarization models frequently struggle with generalizing to new domains, with differing styles and vocabularies causing domain shifts and negatively impacting performance. This limitation limits the models' practical use and scalability in real-world scenarios where users encounter texts from various domains.
To address this issue, we propose assessing the cross-domain adaptability of text summarizer models, with a particular focus on news article summarization. With their diverse topics, genres, and perspectives, news articles present challenges for summarization models. We compare the performance of the TextRank summarizer, an Extractive Summarization model, and the BARTBase Model, an Abstractive Summarization model, using the BBC News Summary dataset, which contains articles and summaries from five domains. Our evaluation involves training and comparing these models on the domain set on which they were developed as well as an unknown different domain set, to assess their adaptability to diverse domains. This study aims to help users who want high-quality summaries in any domain, as well as developers who want to create adaptable text summarization models without the need for additional labeled data.
- Prerequisites
- Summarizers
- Implementation of Summarizers
- Evaluation of the models
- Results
- Analysis
- Developers
- Links
- References
- Python 3 Environment (Anaconda preferred)
- Python modules required: os, re, chardet, numpy, pandas, nltk, textwrap, contractions, sklearn, gensim, scipy, networkx, matplotlib, seaborn, torch, transformers, tqdm, rouge_score, bert_score, warnings
OR
- Any Python3 IDE installed with the above modules. (Pycharm is used in the development of this project)
The dataset we use for this project is from Kaggle and was created using a dataset used for data categorization that consists of 2225 documents from the BBC news website corresponding to stories in five topical areas from 2004 to 2005. This dataset contains texts from five different domains, making it appropriate for assessing cross-domain adaptability. Articles and summaries are stored as individual text files in separate folders for each domain. For the next steps, the article and summary files are combined into five dataframes, each containing the filename, news article, and summary for each domain.
![image](https://private-user-images.githubusercontent.com/42197976/290614958-119b493e-b396-49e8-98cd-29707853fa35.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ4NTI5NTEsIm5iZiI6MTcyNDg1MjY1MSwicGF0aCI6Ii80MjE5Nzk3Ni8yOTA2MTQ5NTgtMTE5YjQ5M2UtYjM5Ni00OWU4LTk4Y2QtMjk3MDc4NTNmYTM1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI4VDEzNDQxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNjNGM0ZjUyODhlNDhlYzBiNGY1ZjU2NTllY2VlMTY3ZDA3NTY3NzY5NGJkY2RiMjM4NTY5ZjdiYzVmMDk4MGYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.IC05hikuk5ayY3tScziJjOw_9mW1zneg5vcInfhUSTA)
The datasets are shuffled and Text Contractions are expanded across the datasets. We analyze the sentence lengths and remove the records with outliers.
![image](https://private-user-images.githubusercontent.com/42197976/290615021-91746b1e-283b-4616-bf80-b2b689595d06.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ4NTI5NTEsIm5iZiI6MTcyNDg1MjY1MSwicGF0aCI6Ii80MjE5Nzk3Ni8yOTA2MTUwMjEtOTE3NDZiMWUtMjgzYi00NjE2LWJmODAtYjJiNjg5NTk1ZDA2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI4VDEzNDQxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWEwNTQ3MTkyOGQ0OWU4ODg2Y2VlMmQ0ZDA2ZWJkMWQ3MzM4NDQ5NmYzMGNhYTkxOTFkM2Q3MDZjNDY1N2I3ODEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.kqHg2VKojPgOywOjUmIGdZrzsvwl4-9wn9o4Wan_s7s)
Text summarization can be divided into two categories: Extractive and Abstractive.
- Extractive summarization involves determining and combining the most important sentences or phrases from the source text, forming the summary without introducing new words or sentences. This procedure is similar to highlighting key sections of the text.
- Our study focuses on extractive summarization using the TextRank Algorithm, which ranks sentences based on their frequency and similarity to other texts. TextRank, which is based on the PageRank algorithm used in online search results, treats sentences as nodes in a graph, connected by edges that represent their similarity. Various similarity metrics, such as cosine similarity, Jaccard similarity, and word overlap, quantify this similarity. TextRank assigns scores to sentences based on the quality and quantity of their links, with the highest-scoring sentences chosen for the summary.
- Abstractive summarization methods create new words or phrases to capture the essence of the original text rather than simply copying and pasting. Instead, they paraphrase or rewrite the content, providing a condensed rewrite.
- Our method makes use of the BART algorithm, which has been optimized for abstractive summarization. BART is a Facebook AI-developed sequence-to-sequence transformer based model that consists of an encoder and a decoder supported by the Transformer architecture. The encoder creates hidden states from the input text, and the decoder generates the output text from these hidden states. BART-base excels in abstractive summarization due to its bidirectional context in the encoder and autoregressive generation in the decoder, which was trained on a large text corpus with a denoising autoencoder objective.
We group the dataset into two categories: business, technology and entertainment, politics, and run the TextRank algorithm on each domain separately to observe if there is a difference in the results.
![image](https://private-user-images.githubusercontent.com/42197976/290615134-0b11367f-0196-4167-9464-92bac87454d2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ4NTI5NTEsIm5iZiI6MTcyNDg1MjY1MSwicGF0aCI6Ii80MjE5Nzk3Ni8yOTA2MTUxMzQtMGIxMTM2N2YtMDE5Ni00MTY3LTk0NjQtOTJiYWM4NzQ1NGQyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI4VDEzNDQxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTFmYzBhNmEyMTAzZWExNTgzMTgxYzU5MmZlMGI4MjczNDEyYTRlNWNlN2E3YWRhZDY4MTY1YmI1NmExMjQyNGYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.lN-2L1Z-Dy9hlUC_Q94BpdN-EQ5VHNPYIt8FgpUqclk)
To maintain consistency and focus on important content, the input text is tokenized, converted to lowercase, and punctuation is removed. Common stopwords are excluded.
Word2Vec generates word embeddings, which are then combined to form sentence embeddings for semantic meaning. The similarity matrix summarizes sentence relationships using cosine similarity, providing a comprehensive overview of sentence connections.
The edges of the graph are weighted according to the calculated similarity matrix, emphasizing strong connections between sentences, and establishing the importance of each sentence with others.
Originally designed for web page ranking, the algorithm is applied to evaluate and rank sentences based on importance. Higher rankings are assigned to sentences connected to other important ones, conveying essential information.
Top-ranked sentences are extracted using Ranking-Based Selection, ensuring key information retention. This procedure collects the most important and relevant information for the summary.
We divide the dataset into two different sets โ business, politics, technology and entertainment, sport. We fine-tune and train the BART model on one set and continuously evaluate the model. The model thus created is tested on the other set to determine how it adapts to a different domain.
![image](https://private-user-images.githubusercontent.com/42197976/290616866-9a1cd6d4-a971-441e-b5b7-932c7a5e5cde.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ4NTI5NTEsIm5iZiI6MTcyNDg1MjY1MSwicGF0aCI6Ii80MjE5Nzk3Ni8yOTA2MTY4NjYtOWExY2Q2ZDQtYTk3MS00NDFlLWI1YjctOTMyYzdhNWU1Y2RlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI4VDEzNDQxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNjMzU2MDBiNzJmODllZTEzNDMwY2I2M2VkNThhZTdiOTU1NTJiMzRhNjRhNTNiMGUxYTVhMmM3Y2E2MDAwYzgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.OGXSnLu9-hEfo96LBlqwCHwYXAQLWrtaF7BSVH8ediM)
We use the BART-Base model from transformers for transfer learning to leverage saved weights of the model pre-trained on a large corpus of data.
BART Tokenizer is used to tokenize input text. Tokenized sequences are stacked into PyTorch Tensors, resulting in the creation of a Tensor Dataset for articles and summaries. Sequence lengths are adjusted to accommodate model input size constraints. Shuffling prevents the model from learning the same examples in the same order each epoch, and batching is done via DataLoaders for faster model updates.
The model undergoes fine-tuning for summarization using a sequence-to-sequence learning approach. AdamW optimizer with a 1e-4 learning rate and 0.001 weight decay is employed. A Linear Schedule with a Warm-up learning rate reducer is used, gradually increasing the learning rate at the training start. A warm-up period and linear decay stabilize training. Beam search decoding captures diverse text possibilities, enhancing summary quality.
Training steps are determined by batches in the dataloader and epochs. The training loop spans multiple epochs, with gradient accumulation for less frequent weight updates and Mixed-precision training for efficiency. Continuous evaluation is also done on a validation set to record Training loss, Rouge-1, and BERT Scores. The model, trained for three epochs without improvement, is saved after completion.
ROUGE, is a set of metrics used to evaluate the quality of text summarization by comparing the overlap between the generated summary and reference summaries.
- We use Rouge-1 which specifically measures unigram overlap between the generated and reference summaries.
- It considers the recall of unigrams, capturing how many reference unigrams are also present in the generated summary.
- It is especially useful for assessing the informativeness and content overlap.
BERT Score utilizes contextual embeddings from BERT to measure the similarity between the generated and reference summaries - It is designed to capture semantic similarity.
- It considers the surrounding context of each word, providing a more nuanced understanding of semantics.
- It focuses on measuring semantic similarity, and evaluating how well the generated summary captures the meaning of the reference summaries.
- This goes beyond lexical matching, emphasizing a deeper assessment of the underlying semantic content in the text.
By evaluating these both we get insights of both informativeness and semantic efficiency of the generated summaries.
- When the TextRank model is applied to data from two different domains, findings match those of Wang et al., who used the BERT model as a basis for extractive summarization. On the two domains we trained, our implementation has a Mean ROUGE-1 precision of 0.35 and 0.37 and a Mean BERTScore of 0.67 and 0.65.
![image](https://private-user-images.githubusercontent.com/42197976/290616034-df75610c-eda8-4d0d-85cf-2c0c4c02993f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ4NTI5NTEsIm5iZiI6MTcyNDg1MjY1MSwicGF0aCI6Ii80MjE5Nzk3Ni8yOTA2MTYwMzQtZGY3NTYxMGMtZWRhOC00ZDBkLTg1Y2YtMmMwYzRjMDI5OTNmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI4VDEzNDQxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYxZDFhODFjYzJjNGQ2Mzc3ZjVlNzZhNTcwZTU0M2RiYmU0YmQxZjhjMzA3MTU2ODc2OTZjMDVmYmFiM2JlOTAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.iZfB9Q_51aINZIjsatm5IPBuU1nK0Z_7U47yRUn0RGY)
- The BART model developed in this work performs better than the model in the paper where it was first introduced as well as the model trained on the BBC News dataset in the work done by Anushka Gupta et al.,
- We used one set of domains to train the BART Model, and then we applied it to a different set of domains. The domain data used for model testing is a different dataset that is unknown, whereas the dataset used for validation during training is the same. The model's ROUGE-1 precision and BERTScore are 0.67 and 0.71 for the same domain data, respectively, and 0.71 and 0.69 when tested on a different domain.
![image](https://private-user-images.githubusercontent.com/42197976/290616293-36161bc4-1949-456d-90c1-26d950da1a5b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ4NTI5NTEsIm5iZiI6MTcyNDg1MjY1MSwicGF0aCI6Ii80MjE5Nzk3Ni8yOTA2MTYyOTMtMzYxNjFiYzQtMTk0OS00NTZkLTkwYzEtMjZkOTUwZGExYTViLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI4VDEzNDQxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVhYzk0MjczNDFjODc4N2Q1YzAzOWE2MGU0MTE1ODZhYjQ2YzJkYWYyZDMxODFhMDBmMGE3OGJiZGE5MjI4MTQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Y69z3tsDpPoP1oJgC7gZdtbZeoowcZOVHteb6JaWayc)
![image](https://private-user-images.githubusercontent.com/42197976/290616307-be97313b-0798-46b8-9a82-518ff548e83d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ4NTI5NTEsIm5iZiI6MTcyNDg1MjY1MSwicGF0aCI6Ii80MjE5Nzk3Ni8yOTA2MTYzMDctYmU5NzMxM2ItMDc5OC00NmI4LTlhODItNTE4ZmY1NDhlODNkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI4VDEzNDQxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYzMTQ2ZjI2ZmI5ZjVhODYxNWNhMjMxNTM1Njk2MmUxNzVkODhmYTM4NzI2YzI3MDI3MmE1YmFmYThmNzI2NTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.CX8nkS5dWU7k_7QH6TunuLh6-IyeSqnlG8gLxcIqcn8)
This work provides an extensive investigation of cross-domain adaptability in text summarization, most notably demonstrating the improved performance of the BART model over its initial implementation and a model optimized for the BBC News dataset. The BART model's excellent ROUGE scores demonstrate how well it summarizes news articles from various industries. Prospective research directions entail expanding the scope of adaptability testing to encompass larger text domains, including dialogues and research articles, which should yield additional insights into the practicality of the model. Notably, the observed limitations point to areas that need to be improved upon in subsequent research, such as the reliance on a small amount of labeled data and the requirement for a more comprehensive set of evaluation metrics.
GitHub: G K Y SHASTRY
Contact me: [email protected] , [email protected]