MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Natural Language Processing (NLP) in Python

Lihat Kursus

Petunjuk latihan

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

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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 dan Jalankan Kode