📢
Admissions Open for August 2026 Batch | Free Career Counselling | Limited Scholarships
Register Now →

Learning Guides

Text Summarization Using NLP: Extractive vs Abstractive Methods

Quick answer: Learn the two main approaches to text summarization in NLP, extractive and abstractive, with a practical extractive summarization example in Python.

What is Text Summarization?

Text summarization automatically condenses a longer document into a shorter version while preserving its key information, a task with obvious value for news, research papers and long reports.

Two Fundamentally Different Approaches

ExtractiveAbstractive
Selects existing sentences directly from the textGenerates new sentences that may not appear in the original
Simpler, more reliably factualCan read more naturally, but risks generating inaccurate content
Uses statistical or graph based rankingUses deep learning, typically transformer models

Extractive Summarization: How It Works

Extractive methods score each sentence by importance, using signals like word frequency or sentence position, then select the highest scoring sentences to form the summary, preserving the original wording exactly.

A Simple Extractive Example Using Word Frequency

import nltk
from nltk.corpus import stopwords
from nltk.tokenize import sent_tokenize, word_tokenize
from collections import defaultdict

nltk.download('punkt')
nltk.download('stopwords')

def summarize(text, num_sentences=3):
    sentences = sent_tokenize(text)
    words = word_tokenize(text.lower())
    stop_words = set(stopwords.words('english'))

    word_freq = defaultdict(int)
    for word in words:
        if word.isalnum() and word not in stop_words:
            word_freq[word] += 1

    sentence_scores = defaultdict(int)
    for sentence in sentences:
        for word in word_tokenize(sentence.lower()):
            if word in word_freq:
                sentence_scores[sentence] += word_freq[word]

    top_sentences = sorted(sentence_scores, key=sentence_scores.get, reverse=True)[:num_sentences]
    return ' '.join(top_sentences)

This scores each sentence by how many frequently occurring, non-stopword terms it contains, then selects the top-scoring sentences as the summary.

Abstractive Summarization Using Transformers

from transformers import pipeline

summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
summary = summarizer(long_text, max_length=100, min_length=30, do_sample=False)

print(summary[0]['summary_text'])

This uses a pretrained transformer model to generate a genuinely new summary, potentially paraphrasing and rewording content rather than only extracting original sentences.

Which Approach to Choose

Extractive summarization is more reliably factual since it never invents content, making it safer for domains like legal or medical text where accuracy is critical. Abstractive summarization can produce more fluent, natural summaries but carries a genuine risk of introducing inaccurate or fabricated details, sometimes called hallucination.

Evaluating Summary Quality

ROUGE scores are the standard metric, comparing overlap between the generated summary and one or more human-written reference summaries.

Common Interview Questions

What is the difference between extractive and abstractive summarization?

Extractive summarization selects and combines existing sentences directly from the source text. Abstractive summarization generates new sentences that may reword or paraphrase the original content.

Why might extractive summarization be preferred in a high-stakes domain?

It never invents content, since it only selects sentences that already exist in the source, making it more reliably factual than abstractive methods, which can occasionally generate inaccurate details.

FAQ

Frequently Asked Questions

What is the difference between extractive and abstractive text summarization?

Extractive summarization selects existing sentences directly from the source text. Abstractive summarization generates new sentences, potentially rewording the original content.

Which summarization approach is safer for accuracy?

Extractive summarization, since it only selects sentences that already exist in the source and never invents new content, unlike abstractive methods which can occasionally hallucinate details.

What metric is commonly used to evaluate summary quality?

ROUGE score, which measures overlap between the generated summary and one or more human-written reference summaries.

Want This Mapped to Your Own Background?

A free counselling session will tell you which path fits, and will tell you honestly if none of ours does.

Book Free Career Counselling

Keep Reading

Related Articles