fastAbs_base / README.md
polieste's picture
Update README.md
ab1ce0e
|
raw
history blame
4.42 kB
metadata
tags:
  - summarization
  - mT5
datasets:
  - csebuetnlp/xlsum
language:
  - am
  - ar
  - az
  - bn
  - my
  - zh
  - en
  - fr
  - gu
  - ha
  - hi
  - ig
  - id
  - ja
  - rn
  - ko
  - ky
  - mr
  - ne
  - om
  - ps
  - fa
  - pcm
  - pt
  - pa
  - ru
  - gd
  - sr
  - si
  - so
  - es
  - sw
  - ta
  - te
  - th
  - ti
  - tr
  - uk
  - ur
  - uz
  - vi
  - cy
  - yo
licenses:
  - cc-by-nc-sa-4.0
widget:
  - 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-index:
  - name: csebuetnlp/mT5_multilingual_XLSum
    results:
      - task:
          type: summarization
          name: Summarization
        dataset:
          name: xsum
          type: xsum
          config: default
          split: test
        metrics:
          - name: ROUGE-1
            type: rouge
            value: 36.5002
            verified: true
          - name: ROUGE-2
            type: rouge
            value: 13.934
            verified: true
          - name: ROUGE-L
            type: rouge
            value: 28.9876
            verified: true
          - name: ROUGE-LSUM
            type: rouge
            value: 28.9958
            verified: true
          - name: loss
            type: loss
            value: 2.0674800872802734
            verified: true
          - name: gen_len
            type: gen_len
            value: 26.9733
            verified: true

Using this model in transformers (tested on 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_multilingual_XLSum"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)

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,
    max_length=256,
    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)