ONNX Model Zoo

xnohat/mT5_m2m_crossSum_enhanced

By xnohat · ↓ 2 · ♥ 0 · Updated 2023-10-27

What's in this repo

This page lists the files in xnohat/mT5_m2m_crossSum_enhanced, including decoder_model.onnx, decoder_model_merged.onnx, decoder_model_merged_quantized.onnx and more.

  • 8 ONNX models (.onnx files)
  • 17 files, including 8 .onnx, 6 .json, 1 .md, 1 .model
  • Last updated 2023-10-27

ONNX files

File Size Download
onnx/decoder_model.onnx — Download
onnx/decoder_model_merged.onnx — Download
onnx/decoder_model_merged_quantized.onnx — Download
onnx/decoder_model_quantized.onnx — Download
onnx/decoder_with_past_model.onnx — Download
onnx/decoder_with_past_model_quantized.onnx — Download
onnx/encoder_model.onnx — Download
onnx/encoder_model_quantized.onnx — Download

How to use

These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.

README

mT5-m2m-CrossSum-enhanced

本仓库包含一个增强的多对多(m2m)mT5 检查点,该模型在 CrossSum 数据集的所有跨语言对上进行了微调。该模型能够将任意语言的文本摘要为指定的目标语言。 有关微调细节和脚本,请参阅论文和官方仓库。

在 transformers 中使用此模型(已在 4.11.0.dev0 上测试)

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" # for a list of available language names see below

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

引用

如果您使用此模型,请引用以下论文:

@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}
}

Model info

transformers
transformers onnx mt5 text2text-generation endpoints_compatible region:us
↓ 2 ♥ 0

Created: 2023-10-27

Updated: 2023-10-27

View on Hugging Face

Files (17)

.gitattributes
README.md
config.json
generation_config.json
onnx/decoder_model.onnx ONNX
onnx/decoder_model_merged.onnx ONNX
onnx/decoder_model_quantized.onnx ONNX
onnx/decoder_with_past_model.onnx ONNX
onnx/decoder_with_past_model_quantized.onnx ONNX
onnx/encoder_model.onnx ONNX
onnx/encoder_model_quantized.onnx ONNX
quantize_config.json
special_tokens_map.json
spiece.model
tokenizer.json
tokenizer_config.json

Related models