sysresearch101 commited on
Commit
21891a9
·
1 Parent(s): 0fd59c0

Create new file

Browse files
Files changed (1) hide show
  1. README.md +128 -0
README.md ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - summarization
6
+ license: mit
7
+ thumbnail: https://huggingface.co/front/thumbnails/facebook.png
8
+ model-index:
9
+ - name: facebook/bart-large-cnn
10
+ results:
11
+ - task:
12
+ type: summarization
13
+ name: Summarization
14
+ dataset:
15
+ name: cnn_dailymail
16
+ type: cnn_dailymail
17
+ config: 3.0.0
18
+ split: train
19
+ metrics:
20
+ - name: ROUGE-1
21
+ type: rouge
22
+ value: 42.9486
23
+ verified: true
24
+ - name: ROUGE-2
25
+ type: rouge
26
+ value: 20.8149
27
+ verified: true
28
+ - name: ROUGE-L
29
+ type: rouge
30
+ value: 30.6186
31
+ verified: true
32
+ - name: ROUGE-LSUM
33
+ type: rouge
34
+ value: 40.0376
35
+ verified: true
36
+ - name: loss
37
+ type: loss
38
+ value: 2.529000997543335
39
+ verified: true
40
+ - name: gen_len
41
+ type: gen_len
42
+ value: 78.5866
43
+ verified: true
44
+ ---
45
+ language: id
46
+ tags:
47
+ - pipeline:summarization
48
+ - summarization
49
+ - t5-large
50
+ datasets:
51
+ - [CNN Daily Mail](https://huggingface.co/datasets/cnn_dailymail)
52
+ - [XSUM](https://huggingface.co/datasets/xsum)
53
+ ---
54
+
55
+ # T5-large Summarization Model Trained on the combined XSUM-CNN Daily Mail Dataset
56
+
57
+ Finetuned T5 Large summarization model.
58
+
59
+ ## Finetuning Corpus
60
+
61
+ `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.
62
+
63
+ ## Load Finetuned Model
64
+
65
+ ```python
66
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, DataCollatorForSeq2Seq, Seq2SeqTrainingArguments, Seq2SeqTrainer
67
+
68
+ tokenizer = AutoTokenizer.from_pretrained("sysresearch101/t5-large-finetuned-xsum-cnn")
69
+ model = model = AutoModelForSeq2SeqLM.from_pretrained("sysresearch101/t5-large-finetuned-xsum-cnn")
70
+
71
+ ARTICLE_TO_SUMMARIZE = "..."
72
+
73
+ # generate summary
74
+
75
+ input_ids = tokenizer.encode(ARTICLE_TO_SUMMARIZE, return_tensors='pt')
76
+ summary_ids = model.generate(input_ids,
77
+ min_length=20,
78
+ max_length=80,
79
+ num_beams=10,
80
+ repetition_penalty=2.5,
81
+ length_penalty=1.0,
82
+ early_stopping=True,
83
+ no_repeat_ngram_size=2,
84
+ use_cache=True,
85
+ do_sample = True,
86
+ temperature = 0.8,
87
+ top_k = 50,
88
+ top_p = 0.95)
89
+
90
+ summary_text = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
91
+ print(summary_text)
92
+
93
+ Output: <TODO>
94
+
95
+ ```
96
+
97
+ ### How to use via a pipeline
98
+
99
+ Here is how to use this model with the [pipeline API](https://huggingface.co/transformers/main_classes/pipelines.html):
100
+
101
+
102
+ ```python
103
+ from transformers import pipeline
104
+
105
+ summarizer = pipeline("summarization", model="sysresearch101/t5-large-finetuned-xsum-cnn")
106
+
107
+ ARTICLE = """ New York (CNN)When Liana Barrientos was 23 years old, she got married in Westchester County, New York.
108
+ A year later, she got married again in Westchester County, but to a different man and without divorcing her first husband.
109
+ 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.
110
+ 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.
111
+ 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
112
+ 2010 marriage license application, according to court documents.
113
+ Prosecutors said the marriages were part of an immigration scam.
114
+ On Friday, she pleaded not guilty at State Supreme Court in the Bronx, according to her attorney, Christopher Wright, who declined to comment further.
115
+ 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
116
+ Annette Markowski, a police spokeswoman. In total, Barrientos has been married 10 times, with nine of her marriages occurring between 1999 and 2002.
117
+ 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.
118
+ Prosecutors said the immigration scam involved some of her husbands, who filed for permanent residence status shortly after the marriages.
119
+ Any divorces happened only after such filings were approved. It was unclear whether any of the men will be prosecuted.
120
+ The case was referred to the Bronx District Attorney\'s Office by Immigration and Customs Enforcement and the Department of Homeland Security\'s
121
+ Investigation Division. Seven of the men are from so-called "red-flagged" countries, including Egypt, Turkey, Georgia, Pakistan and Mali.
122
+ Her eighth husband, Rashid Rajput, was deported in 2006 to his native Pakistan after an investigation by the Joint Terrorism Task Force.
123
+ If convicted, Barrientos faces up to four years in prison. Her next court appearance is scheduled for May 18.
124
+ """
125
+ print(summarizer(ARTICLE, max_length=130, min_length=30, do_sample=False))
126
+ >>> [{'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.'}]
127
+ ```
128
+