--- language: - en tags: - summarization - t5-large-summarization - pipeline:summarization license: mit model-index: - name: sysresearch101/t5-large-finetuned-xsum" results: - task: type: summarization name: Summarization dataset: name: xsum type: xsum config: 3.0.0 split: train metrics: - name: ROUGE-1 type: rouge value: verified: true - name: ROUGE-2 type: rouge value: verified: true - name: ROUGE-L type: rouge value: verified: true - name: ROUGE-LSUM type: rouge value: verified: true - name: loss type: loss value: verified: true - name: gen_len type: gen_len value: verified: true - task: type: summarization name: Summarization dataset: name: xsum type: xsum config: default split: test metrics: - name: ROUGE-1 type: rouge value: 26.8921 verified: true - name: ROUGE-2 type: rouge value: 6.9411 verified: true - name: ROUGE-L type: rouge value: 21.2832 verified: true - name: ROUGE-LSUM type: rouge value: 21.284 verified: true - name: loss type: loss value: 2.5411810874938965 verified: true - name: gen_len type: gen_len value: 18.7755 verified: true - task: type: summarization name: Summarization dataset: name: cnn_dailymail type: cnn_dailymail config: 3.0.0 split: train metrics: - name: ROUGE-1 type: rouge value: 17.7078 verified: true - name: ROUGE-2 type: rouge value: 3.3446 verified: true - name: ROUGE-L type: rouge value: 12.8664 verified: true - name: ROUGE-LSUM type: rouge value: 15.6724 verified: true - name: loss type: loss value: 3.786738157272339 verified: true - name: gen_len type: gen_len value: 18.8385 verified: true --- # T5-large Summarization Model Trained on the XSUM Dataset Finetuned T5 Large summarization model. ## Finetuning Corpus `t5-large-finetuned-xsum` model is based on `t5-large model` by [huggingface](https://huggingface.co/t5-large), finetuned using [XSUM](https://huggingface.co/datasets/xsum) datasets. ## Load Finetuned Model ```python from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, DataCollatorForSeq2Seq, Seq2SeqTrainingArguments, Seq2SeqTrainer tokenizer = AutoTokenizer.from_pretrained("sysresearch101/t5-large-finetuned-xsum") model = model = AutoModelForSeq2SeqLM.from_pretrained("sysresearch101/t5-large-finetuned-xsum") ARTICLE_TO_SUMMARIZE = "..." # generate summary input_ids = tokenizer.encode(ARTICLE_TO_SUMMARIZE, return_tensors='pt') summary_ids = model.generate(input_ids, min_length=20, max_length=80, num_beams=10, repetition_penalty=2.5, length_penalty=1.0, early_stopping=True, no_repeat_ngram_size=2, use_cache=True, do_sample = True, temperature = 0.8, top_k = 50, top_p = 0.95) summary_text = tokenizer.decode(summary_ids[0], skip_special_tokens=True) print(summary_text) Output: ``` ### How to use via a pipeline Here is how to use this model with the [pipeline API](https://huggingface.co/transformers/main_classes/pipelines.html): ```python from transformers import pipeline summarizer = pipeline("summarization", model="sysresearch101/t5-large-finetuned-xsum") ARTICLE = """ New York (CNN)When Liana Barrientos was 23 years old, she got married in Westchester County, New York. A year later, she got married again in Westchester County, but to a different man and without divorcing her first husband. Only 18 days after that marriage, she got hitched yet again. Then, Barrientos declared "I do" five more times, sometimes only within two weeks of each other. In 2010, she married once more, this time in the Bronx. In an application for a marriage license, she stated it was her "first and only" marriage. Barrientos, now 39, is facing two criminal counts of "offering a false instrument for filing in the first degree," referring to her false statements on the 2010 marriage license application, according to court documents. Prosecutors said the marriages were part of an immigration scam. On Friday, she pleaded not guilty at State Supreme Court in the Bronx, according to her attorney, Christopher Wright, who declined to comment further. After leaving court, Barrientos was arrested and charged with theft of service and criminal trespass for allegedly sneaking into the New York subway through an emergency exit, said Detective Annette Markowski, a police spokeswoman. In total, Barrientos has been married 10 times, with nine of her marriages occurring between 1999 and 2002. All occurred either in Westchester County, Long Island, New Jersey or the Bronx. She is believed to still be married to four men, and at one time, she was married to eight men at once, prosecutors say. Prosecutors said the immigration scam involved some of her husbands, who filed for permanent residence status shortly after the marriages. Any divorces happened only after such filings were approved. It was unclear whether any of the men will be prosecuted. The case was referred to the Bronx District Attorney\'s Office by Immigration and Customs Enforcement and the Department of Homeland Security\'s Investigation Division. Seven of the men are from so-called "red-flagged" countries, including Egypt, Turkey, Georgia, Pakistan and Mali. Her eighth husband, Rashid Rajput, was deported in 2006 to his native Pakistan after an investigation by the Joint Terrorism Task Force. If convicted, Barrientos faces up to four years in prison. Her next court appearance is scheduled for May 18. """ print(summarizer(ARTICLE, max_length=130, min_length=30, do_sample=False)) >>> [{'summary_text': 'Liana Barrientos, 39, is charged with two counts of "offering a false instrument for filing in the first degree" In total, she has been married 10 times, with nine of her marriages occurring between 1999 and 2002. She is believed to still be married to four men.'}] ```