File size: 8,925 Bytes
2e4f613
 
 
534ca44
2e4f613
 
 
 
 
57bdf7e
2e4f613
ff4a3a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2db2d7b
 
 
 
 
 
 
 
 
534ca44
2db2d7b
534ca44
2db2d7b
534ca44
 
2db2d7b
534ca44
2db2d7b
534ca44
 
2db2d7b
534ca44
2db2d7b
534ca44
 
2db2d7b
534ca44
2db2d7b
534ca44
 
2db2d7b
534ca44
2db2d7b
534ca44
 
2db2d7b
534ca44
2db2d7b
534ca44
2e4f613
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
language:
- en
license: mit
tags:
- summarization
- t5-large-summarization
- pipeline:summarization
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:
  #   - type: rouge
  #     value: <TODO>
  #     name: ROUGE-1
  #     verified: true
  #     verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiNmE1YjI2OWVjMGRiZWU3MjJhOTViMWIzNWU3MDNlZmFkMmNhZTFiN2RhOTc0ZjkyNzc5ZDg1YWZiZWFhMTEyZiIsInZlcnNpb24iOjF9.ye9137aCRynwSZM0YD2k4_LIcrRU4EyCRjBB8YQ0kUCImJyHNVFPFbbzObfLSM3XQ_tauALczriBCMJ7IGxeDQ
  #   - type: rouge
  #     value: <TODO>
  #     name: ROUGE-2
  #     verified: true
  #     verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiYWYzYzZlZTEwYThhYjJkYzE0MzA1ZjE2NDBiMDNjOTNlZWNjNmMxNDJiMDE4OTJhMjdhNGI3OWRiZjQ1M2RhOSIsInZlcnNpb24iOjF9.-6WOpeYKgyiQSvWIeCfJWWTzI8kt_Q5by31r-ceBF384NMf6APLA94jKpLdE2HDbDgUtuxF9LAHFz9jmhkqKCA
  #   - type: rouge
  #     value: <TODO>
  #     name: ROUGE-L
  #     verified: true
  #     verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiNDAxODg3ZjRlMmUwZTdjYmRmYTZhMzEwYTg4MmU4NmY2MmJlZTE5N2MxYjY4YmE4NGM0NDJkNDRiYjc2OTQwMSIsInZlcnNpb24iOjF9.iWTpIMKC2HGkJMYOQviXBnc-lj4pHLWVyfMXSfbz26s1KUi5gOD97eEaHeBmUW5IMs64dosTVa6xo3T-5_FdDA
  #   - type: rouge
  #     value: <TODO>
  #     name: ROUGE-LSUM
  #     verified: true
  #     verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiMGU2YzFiMDRkOTc2OTFjMGI1MzA3MTgwMzczMjhkMTMxNzkyNDVlZGUzMGM3OTk4ODk0YjQ4MzRjYTVlNmZmNiIsInZlcnNpb24iOjF9.K1duMlA1zQpSiencBbbhpShckuvEb8zspnJG5jf1n65KmNY4Md3VA96ERKixUOIymnTo-gKyS9QEDKblPmR_Ag
  #   - type: loss
  #     value: <TODO>
  #     name: loss
  #     verified: true
  #     verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiZDQ4MDI4MzgyOWUwYzI0YTE3MTE2ODdhYjU3MGE1MTg1NTU4OTM4NzlmYjE1MDY5M2Q2OTVkZjY4MzRlZTYzOCIsInZlcnNpb24iOjF9.5BMk4fs-oVoDNJnPBpDlSkywd3Qogat4_N8_IdS26AObm2i1blwonx4sy8l8RK50pq16bJbplBEEG-3HuTz9DQ
  #   - type: gen_len
  #     value: <TODO>
  #     name: gen_len
  #     verified: true
  #     verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiOTE4ZTAzNmYxMzE2NGYzYTM2MzMxNTNlN2M4YmJlOWI3ZWFkMGRlMTc5NGMzNjBlZjg1MjJhZDdlNDIwZTAwNyIsInZlcnNpb24iOjF9._JTVMjukkupE4_QWOQZZZVwmnXSh-ppo7jlGdk0CUxNIIVTStxQhex09O1H6-Ilk9dtYk1PVCNNg8alZAFHeDQ
  - task:
      type: summarization
      name: Summarization
    dataset:
      name: xsum
      type: xsum
      config: default
      split: test
    metrics:
    - type: rouge
      value: 26.8921
      name: ROUGE-1
      verified: true
      verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiZmFkMTFiNmM3YmRkZDk1Y2FhM2EwOTdiYmUwYjBhMGEzZmIyZmIwNWI5OTVmY2U0N2QzYzgxYzM0OTEzMjFjNSIsInZlcnNpb24iOjF9.fOq4zI_BWvTLFJFQOWNk3xEsDIu3aAeboGYPw5TiBqdJJjvdyKmLbfj2WVnNboWbrmp1PuL01iJjTi2Xj6PUAA
    - type: rouge
      value: 6.9411
      name: ROUGE-2
      verified: true
      verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiMTBlZmI3NjQ3M2JiYzI4MTg3YmJkMjg0ZmE5MDUwNzljNTYyM2M0NzA3YTNiNTA2Nzk4MDhhYWZjZjgyMmE1MCIsInZlcnNpb24iOjF9.rH0DY2hMz2rXaK29vkt7xah-3G95rY4MOS2oVKjXmw4TijB-ZVytfLJAlBmyqA8HYAythRCywmLSjjCDWc66Cg
    - type: rouge
      value: 21.2832
      name: ROUGE-L
      verified: true
      verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiODAwZDYzNTc0NjZhNzNiMDE2ZDY2NjNjNmViNTc0NDVjNTZkYjljODhmYmNiMWFhY2NkZjU5MzQ0NmM0OTcyMSIsInZlcnNpb24iOjF9.5duHtdjZ8dwtbp1HKyMR4mVK9IIlEZvuWGjQMErpE7VNyKPhMOT6Avh_vXFQz6q_jBzqpZGGREho1mt50yBsDw
    - type: rouge
      value: 21.284
      name: ROUGE-LSUM
      verified: true
      verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiMGQ2NmNhZTZmZDFkNTcyYjQ4MjhhYWJhODY1ZGRjODY2ZTE5MmRmZDRlYTk4NWE4YWM1OWY2M2NjOWQ3YzU0OCIsInZlcnNpb24iOjF9.SJ8xTcAVWrRDmJmQoxE1ADIcdGA4tr3V04Lv0ipMJiUksCdNC7FO8jYbjG9XmiqbDnnr5h4XoK4JB4-GsA-gDA
    - type: loss
      value: 2.5411810874938965
      name: loss
      verified: true
      verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiZGViNTVlNGI0Njk4NmZmZjExNDBkNTQ4N2FhMzRkZjRjNDNlYzFhZDIyMjJhMmFiM2ZhMTQzYTM4YzNkNWVlNyIsInZlcnNpb24iOjF9.p9n2Kf48k9F9Bkk9j7UKRayvVmOr7_LV80T0ti4lUWFtTsZ91Re841xnEAcKSYgQ9-Bni56ldq9js3kunspJCw
    - type: gen_len
      value: 18.7755
      name: gen_len
      verified: true
      verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiZmQ1ZWUxNmFjNmU0OGI4MDQyZDNjMWQwZGViNDhlMzE1OGE3YmYwYzZjYmM1NWEwMjk2MDFiMjQ4ZThhMjg5YyIsInZlcnNpb24iOjF9.aNp-NFzBSm84GnXuDtYuHaOsSk7zw8kjCphowYFciwt-aDnhwwurYIr59kMT8JNFMnRInsDi8tvYdapareV3DA
---

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

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