Get startedGet started for free

Summarizing news articles for quick insights

A news aggregation app needs to provide users with concise summaries of lengthy news articles so they can quickly grasp the main points without reading the entire text. Your task is to use a Hugging Face pipeline to generate clear, brief summaries from full news articles.

This exercise is part of the course

Natural Language Processing (NLP) in Python

View Course

Exercise instructions

  • Create a summarizer pipeline using the "cnicu/t5-small-booksum" model.
  • Summarize the given article text.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

from transformers import pipeline

# Create the summarization pipeline
summarizer = pipeline(task="____", model="____")

article = """NASA's Perseverance rover has successfully collected its first rock samples from Mars, marking a significant milestone in the mission. The samples will be stored for potential return to Earth in the future, providing valuable insight into the planet's geology and potential signs of past microbial life."""

# Generate the summary
summary = ____

print(summary)
Edit and Run Code