🚀 mT5-m2m-CrossSum-enhanced
本倉庫包含一個經過增強的多對多(m2m)mT5檢查點,該檢查點在CrossSum數據集的所有跨語言對上進行了微調。此模型旨在將用任何語言撰寫的文本總結為指定的目標語言。有關微調的詳細信息和腳本,請參閱論文和官方倉庫。
🚀 快速開始
✨ 主要特性
- 支持多種語言,涵蓋阿姆哈拉語、阿拉伯語、阿塞拜疆語等眾多語言。
- 能夠將任意語言的文本總結為指定的目標語言。
📦 安裝指南
文檔未提及安裝步驟,此處跳過。
💻 使用示例
基礎用法
import re
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
WHITESPACE_HANDLER = lambda k: re.sub('\s+', ' ', re.sub('\n+', ' ', k.strip()))
article_text = """Videos that say approved vaccines are dangerous and cause autism, cancer or infertility are among those that will be taken down, the company said. The policy includes the termination of accounts of anti-vaccine influencers. Tech giants have been criticised for not doing more to counter false health information on their sites. In July, US President Joe Biden said social media platforms were largely responsible for people's scepticism in getting vaccinated by spreading misinformation, and appealed for them to address the issue. YouTube, which is owned by Google, said 130,000 videos were removed from its platform since last year, when it implemented a ban on content spreading misinformation about Covid vaccines. In a blog post, the company said it had seen false claims about Covid jabs "spill over into misinformation about vaccines in general". The new policy covers long-approved vaccines, such as those against measles or hepatitis B. "We're expanding our medical misinformation policies on YouTube with new guidelines on currently administered vaccines that are approved and confirmed to be safe and effective by local health authorities and the WHO," the post said, referring to the World Health Organization."""
model_name = "csebuetnlp/mT5_m2m_crossSum_enhanced"
tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=False)
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
get_lang_id = lambda lang: tokenizer._convert_token_to_id(
model.config.task_specific_params["langid_map"][lang][1]
)
target_lang = "english"
input_ids = tokenizer(
[WHITESPACE_HANDLER(article_text)],
return_tensors="pt",
padding="max_length",
truncation=True,
max_length=512
)["input_ids"]
output_ids = model.generate(
input_ids=input_ids,
decoder_start_token_id=get_lang_id(target_lang),
max_length=84,
no_repeat_ngram_size=2,
num_beams=4,
)[0]
summary = tokenizer.decode(
output_ids,
skip_special_tokens=True,
clean_up_tokenization_spaces=False
)
print(summary)
可用的目標語言名稱
amharic
(阿姆哈拉語)
arabic
(阿拉伯語)
azerbaijani
(阿塞拜疆語)
bengali
(孟加拉語)
burmese
(緬甸語)
chinese_simplified
(簡體中文)
chinese_traditional
(繁體中文)
english
(英語)
french
(法語)
gujarati
(古吉拉特語)
hausa
(豪薩語)
hindi
(印地語)
igbo
(伊博語)
indonesian
(印尼語)
japanese
(日語)
kirundi
(基隆迪語)
korean
(韓語)
kyrgyz
(吉爾吉斯語)
marathi
(馬拉地語)
nepali
(尼泊爾語)
oromo
(奧羅莫語)
pashto
(普什圖語)
persian
(波斯語)
pidgin
(皮欽語)
portuguese
(葡萄牙語)
punjabi
(旁遮普語)
russian
(俄語)
scottish_gaelic
(蘇格蘭蓋爾語)
serbian_cyrillic
(塞爾維亞語 - 西裡爾字母)
serbian_latin
(塞爾維亞語 - 拉丁字母)
sinhala
(僧伽羅語)
somali
(索馬里語)
spanish
(西班牙語)
swahili
(斯瓦希里語)
tamil
(泰米爾語)
telugu
(泰盧固語)
thai
(泰語)
tigrinya
(提格雷尼亞語)
turkish
(土耳其語)
ukrainian
(烏克蘭語)
urdu
(烏爾都語)
uzbek
(烏茲別克語)
vietnamese
(越南語)
welsh
(威爾士語)
yoruba
(約魯巴語)
📚 詳細文檔
文檔未提供詳細說明,此處跳過。
🔧 技術細節
文檔未提供技術實現細節,此處跳過。
📄 許可證
本項目採用cc-by-nc-sa-4.0
許可證。
📚 引用
如果您使用此模型,請引用以下論文:
@article{hasan2021crosssum,
author = {Tahmid Hasan and Abhik Bhattacharjee and Wasi Uddin Ahmad and Yuan-Fang Li and Yong-bin Kang and Rifat Shahriyar},
title = {CrossSum: Beyond English-Centric Cross-Lingual Abstractive Text Summarization for 1500+ Language Pairs},
journal = {CoRR},
volume = {abs/2112.08804},
year = {2021},
url = {https://arxiv.org/abs/2112.08804},
eprinttype = {arXiv},
eprint = {2112.08804}
}