สรุปข่าวเพื่อให้ได้ใจความสำคัญอย่างรวดเร็ว
แอปรวบรวมข่าวต้องการนำเสนอบทสรุปกระชับของบทความข่าวที่ยาว เพื่อให้ผู้ใช้เข้าใจประเด็นสำคัญได้อย่างรวดเร็วโดยไม่ต้องอ่านทั้งหมด ในแบบฝึกหัดนี้จะใช้ Hugging Face pipeline เพื่อสร้างบทสรุปที่ชัดเจนและกระชับจากบทความข่าวฉบับเต็ม
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การประมวลผลภาษาธรรมชาติ (NLP) ด้วย Python
คำแนะนำการฝึกหัด
- สร้าง pipeline ชื่อ
summarizerโดยใช้โมเดล"cnicu/t5-small-booksum" - สรุปความข้อความ
articleที่กำหนดให้
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
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)