File size: 9,518 Bytes
21891a9
 
 
d8fb5ba
21891a9
 
f207d00
 
21891a9
 
08403d7
21891a9
a88627f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54c3c07
 
 
 
 
 
 
 
 
d8fb5ba
54c3c07
d8fb5ba
54c3c07
d8fb5ba
 
54c3c07
d8fb5ba
54c3c07
d8fb5ba
 
54c3c07
d8fb5ba
54c3c07
d8fb5ba
 
54c3c07
d8fb5ba
54c3c07
d8fb5ba
 
54c3c07
d8fb5ba
54c3c07
d8fb5ba
 
54c3c07
d8fb5ba
54c3c07
d8fb5ba
21891a9
 
 
 
 
 
81e5a41
 
 
 
21891a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
---
language:
- en
license: mit
tags:
- summarization
- t5-large-summarization
- pipeline:summarization
thumbnail: https://huggingface.co/front/thumbnails/facebook.png
model-index:
- name: sysresearch101/t5-large-finetuned-xsum-cnn
  results:
  # - task:
  #     type: summarization
  #     name: Summarization
  #   dataset-1:
  #     name: cnn_dailymail
  #     type: cnn_dailymail
  #     config: 3.0.0
  #     split: train
  #   dataset-2:
  #     name: xsum
  #     type: xsum
    # metrics:
    # - type: rouge
    #   value: <TODO>
    #   name: ROUGE-1
    #   verified: true
    #   verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiYzI1MjFiNzJiYjVjNGMxNDM1MTU2YWU2MzIyMThhYjdkYmU5YTM4Yzk5OWYzYTcyZDQwNDg1NmIyYzNkZjFjMiIsInZlcnNpb24iOjF9.fVKnv7zkhNG6zLLpok10xyIHyYaGqiOShLXu9aDJvJNyZdKL82WHj_eP6Huv3hb5fmzlW8ZBJ_f7KOb98JjpDg
    # - type: rouge
    #   value: <TODO>
    #   name: ROUGE-2
    #   verified: true
    #   verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiYzMwOTllNmQ0MTMzNzI3MjMyMjVlZTU0YWI1OGYyNWY4ZWEyMGJmMzNjOWVjOTEyYmI2NGM3MjU2MmY1ZmU1YSIsInZlcnNpb24iOjF9.sUGKAQSY8k7JFCxCSjGC1Y8N6C-9zbeqALTr45erB30Q4yO7Poq9V2WoJQ3Eh6JJhHC8-V_REJtujCxmIJUPCQ
    # - type: rouge
    #   value: <TODO>
    #   name: ROUGE-L
    #   verified: true
    #   verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiMjYyNjk0NzdjMTViZmJkNGFlMDFhNWJjMjYyZDhjMzMzMjAyNmNiMzc0YTk5ZDI2ZTNlZDc1ZTE0ZTc1ODJkZCIsInZlcnNpb24iOjF9.m9PCgMGsGjD42_J2gokmzzHrh-sIHLf2txvmHzbNoV4vx_7JfF-LNoodgd_D6rPuJrebld5w6JwMgSI4abPQDg
    # - type: rouge
    #   value: <TODO>
    #   name: ROUGE-LSUM
    #   verified: true
    #   verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiZDMyODhjMjZlMjQzMDE0NDUyZjg3YjUyYmFmYmQzMjNkZGE5YjlhNzU4MDdhMmQwZjJjNjE2ZjZlMjQzNWJlYSIsInZlcnNpb24iOjF9.I_xeOcRbe_g3fLBeEraHI7JsxBz_rKlm893dylB0HGD4UyHuM5qtYyLu5p2ohhIoXX_W-PC-AFF-mlrUcBZhBw
    # - type: loss
    #   value: <TODO>
    #   name: loss
    #   verified: true
    #   verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiZWZiZGExY2M4NmM3ODhhZWVjYjk1MTg0M2YwMzc2Y2JkMmYxZjVkNzk0MDVhY2I2MzIyMDJiOWE4MmM3ZjIzYyIsInZlcnNpb24iOjF9.lFkphS1uVSwwr8h8dOq-AOghE8RYh9QRKL1f4QPzxxp8q-TiKEDwsWlyjnAaWXpUjNbMVMDETGiP5-pzKOomBg
    # - type: gen_len
    #   value: <TODO>
    #   name: gen_len
    #   verified: true
    #   verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiZmQwYmU0MjU5MTMxNGNiYWNmZGYwNDRmZGU2M2E0MTJmMTVjOThhZGM4NjU4MTI4ZDk5YzY4YjkyMDNlYzcxZSIsInZlcnNpb24iOjF9.6ZRzKoP9RGfr95lRPxJlETH-tbNZ-evNv8_AdkwULllUyIlpanmU0BF57EJHkIf4CYYuyjC_phaCfplAH8rmBQ
  - task:
      type: summarization
      name: Summarization
    dataset:
      name: xsum
      type: xsum
      config: default
      split: test
    metrics:
    - type: rouge
      value: 36.7656
      name: ROUGE-1
      verified: true
      verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiN2QzMDg4NTM0ZTc5MjAzNTY4MmY1YTRiMWI3M2I2NDdjMTM4ZGNhYzZhOWQzMWI0MjJlYmU3MTg0ZjVjMTEyZSIsInZlcnNpb24iOjF9.AuKHql0LQs0zDQNn7zvySnX50GAC8jEWyYz-LtBgWj0dcad86J8yfHbIDswmgx2ur0S3yttw72qNExag_Fw7Dw
    - type: rouge
      value: 14.6898
      name: ROUGE-2
      verified: true
      verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiZTE3ZTExY2M3MTIwMWY0ODRkZDI1YjU2ZjRkOGJjOGQyYjcxMTMxOWExN2Q0OGNkZmNiYzYzYzVhODY4YzEwOSIsInZlcnNpb24iOjF9.F1Q17sa8IAsW8ouQ2VDLq_VvHDxjuMjVU3rMfvkbmKxAjTDKVTiaG6Eg9uSKIYzgJoDSsxhsZcjH-J0gGQv3Dg
    - type: rouge
      value: 30.0646
      name: ROUGE-L
      verified: true
      verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiYzI1NjE0NmI5Nzc3ODFiNDI5YzVhNjUzNzU1NzA0ZDMwMjFjZDE1YzUxNjZmZTAwZTM0MmVmN2ZkYWUwMjBiZSIsInZlcnNpb24iOjF9.xehN8zOV6050WvoLZIJ-l2zB93jWY_ugcydDDqV06XwdKwZ7l0TI8BoLDOO7Mw7dRmHOWLNruDJZnOnW3_3pCQ
    - type: rouge
      value: 30.0563
      name: ROUGE-LSUM
      verified: true
      verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiZmU0OTVhYTY0ZDJmOTU3OWE5MzgxYzdhNmQ3MjM3YzM2MGIzOGViY2ZkMTI1ZWI4NDMwOTlkODBjOGE4NTE4ZCIsInZlcnNpb24iOjF9.FtNN06HKSgEB1tiWpToEVnNfzhQs9ZR59386YynOY6T6oKWxbIiRyItzYXobNw96lg5c2sE4vdJSfdtbBpkyDA
    - type: loss
      value: 1.6373405456542969
      name: loss
      verified: true
      verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiYTVjYzI0MmMyY2IzYTE0NDUxY2FiMDM4Mjk2NTI1NTk0NjFiYTY2OWMxODRjNWJhYjU4ZWU5OTk4Y2E5N2RkOSIsInZlcnNpb24iOjF9.Cz5AQ-B8IAXmf1Xc_7UJ0pI9XKYHxDEwmoP3ZFsS2Wmbk1pUB8o_Y8AErBR8-Q60qR_ndw8eSwrI0EnPohYHCw
    - type: gen_len
      value: 18.6054
      name: gen_len
      verified: true
      verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiMWRlMjM5MzAyMjEzYzdkODFmNDk4NDg5NWM4NWIxMTU4YWMxNzZjMGFjOWJiMDdkMjQyMTY0ZGFmYzA2OTA0YiIsInZlcnNpb24iOjF9.IFiGJEsyD7Uhj8bo9SsAgibk9qCXZH6IWaLKULLxBz5N8WXF2vc2Mfg5OThEzdrydPhJInRgp0jd8m-kF5nNCA
---

# T5-large Summarization Model Trained on the combined XSUM-CNN Daily Mail Dataset

Finetuned T5 Large summarization model. 

## LeaderBoard Rankings 
Currently ranks third (rouge-score) on the xsum dataset for summarization, trailing only Facebook's Bart-Large-Xsum and Google's Pegasus-Xsum.
see : https://huggingface.co/spaces/autoevaluate/leaderboards?dataset=xsum , make sure to select Task : Summarization and Sorting Metric : Rouge Score 

## Finetuning Corpus

`t5-large-finetuned-xsum-cnn` model is based on `t5-large model` by [huggingface](https://huggingface.co/t5-large), finetuned using and fine-tuned on [CNN Daily Mail](https://huggingface.co/datasets/cnn_dailymail),and [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-cnn")
model = model = AutoModelForSeq2SeqLM.from_pretrained("sysresearch101/t5-large-finetuned-xsum-cnn")

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: <TODO>

```

### 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-cnn")

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.'}]
```