🚀 T5-base針對新聞摘要任務微調模型 📖✏️🧾
本項目所有榮譽歸於 Abhishek Kumar Mishra。
此模型是在 新聞摘要 數據集上對 谷歌的T5 基礎模型進行微調,以完成 摘要生成 下游任務。
✨ 主要特性
T5模型詳情
T5 模型由 Colin Raffel、Noam Shazeer、Adam Roberts、Katherine Lee、Sharan Narang、Michael Matena、Yanqi Zhou、Wei Li、Peter J. Liu 在論文 探索統一文本到文本轉換器的遷移學習極限 中提出。以下是論文摘要:
遷移學習是一種先在數據豐富的任務上預訓練模型,再在下游任務上進行微調的技術,已成為自然語言處理(NLP)領域的強大技術。遷移學習的有效性催生了多種方法、方法論和實踐。在本文中,我們通過引入一個統一的框架,將每個語言問題轉換為文本到文本的格式,探索了NLP遷移學習技術的格局。我們的系統研究比較了預訓練目標、架構、無標籤數據集、遷移方法和其他因素在數十個語言理解任務中的表現。通過將我們的探索見解與規模和新的“巨型清潔爬取語料庫”相結合,我們在涵蓋摘要生成、問答、文本分類等多個基準測試中取得了最先進的成果。為了促進未來NLP遷移學習的研究,我們發佈了數據集、預訓練模型和代碼。

下游任務(摘要生成)詳情 - 數據集 📚
新聞摘要
該數據集包含 4515 個示例,包含作者姓名、標題、文章鏈接、簡短文本和完整文章。這些摘要新聞來自Inshorts,新聞文章僅從《印度教徒報》、《印度時報》和《衛報》抓取。時間範圍為2017年2月至8月。
模型微調 🏋️
訓練腳本是 Abhishek Kumar Mishra 創建的 此Colab筆記本 的略微修改版本,所有榮譽歸於他!我還對模型進行了更多輪次(6輪)的訓練。
💻 使用示例
基礎用法
from transformers import AutoModelWithLMHead, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("mrm8488/t5-base-finetuned-summarize-news")
model = AutoModelWithLMHead.from_pretrained("mrm8488/t5-base-finetuned-summarize-news")
def summarize(text, max_length=150):
input_ids = tokenizer.encode(text, return_tensors="pt", add_special_tokens=True)
generated_ids = model.generate(input_ids=input_ids, num_beams=2, max_length=max_length, repetition_penalty=2.5, length_penalty=1.0, early_stopping=True)
preds = [tokenizer.decode(g, skip_special_tokens=True, clean_up_tokenization_spaces=True) for g in generated_ids]
return preds[0]
給定來自 《紐約時報》(2020年6月9日)的以下文章,標題為 喬治·弗洛伊德之死激發了一場運動。他今天將在休斯頓下葬:
在喧囂和憤怒之後,經過數週的示威活動和對種族正義的痛苦呼籲,那個因死亡引發了一場國際運動,且最後遺言 “我無法呼吸” 成為戰鬥口號的人,將於週二在休斯頓的私人葬禮上安息。46歲的喬治·弗洛伊德將被安葬在他母親墓旁的墓穴中。葬禮定於上午11點在讚美之泉教堂舉行,此前在明尼阿波利斯、北卡羅來納州和休斯頓舉行了五天的公眾追悼活動,而在明尼阿波利斯一名警察被錄像拍到在弗洛伊德先生死亡前將膝蓋壓在他脖子上近九分鐘之後已經過去了兩週。那名警察德里克·肖文被控二級謀殺和二級過失殺人罪。他在週一的法庭出庭時保釋金定為125萬美元。弗洛伊德先生死後憤怒和憤慨的爆發,以及抗議活動從他死亡的城市緊張、混亂的示威迅速蔓延到從羅馬到里約熱內盧的國際運動,反映了多年來目睹黑人死於警察或義警之手,而變革呼聲卻未得到回應所積累的挫敗感之深。
summarize('After the sound and the fury, weeks of demonstrations and anguished calls for racial justice, the man whose death gave rise to an international movement, and whose last words — “I can’t breathe” — have been a rallying cry, will be laid to rest on Tuesday at a private funeral in Houston.George Floyd, who was 46, will then be buried in a grave next to his mother’s.The service, scheduled to begin at 11 a.m. at the Fountain of Praise church, comes after five days of public memorials in Minneapolis, North Carolina and Houston and two weeks after a Minneapolis police officer was caught on video pressing his knee into Mr. Floyd’s neck for nearly nine minutes before Mr. Floyd died. That officer, Derek Chauvin, has been charged with second-degree murder and second-degree manslaughter. His bail was set at $1.25 million in a court appearance on Monday. The outpouring of anger and outrage after Mr. Floyd’s death — and the speed at which protests spread from tense, chaotic demonstrations in the city where he died to an international movement from Rome to Rio de Janeiro — has reflected the depth of frustration borne of years of watching black people die at the hands of the police or vigilantes while calls for change went unmet.', 80)
我們將得到:
在休斯頓的私人葬禮上。46歲的弗洛伊德死亡後將被安葬在他母親墓旁。一名明尼蘇達警察被錄像拍到在他死亡前將膝蓋壓在他脖子上近九分鐘。該警察被控二級過失殺人罪,保釋金定為120萬美元。
由 Manuel Romero/@mrm8488 創建 | 領英
在西班牙用心打造 ♥