Migrate model card from transformers-repo
Browse filesRead announcement at https://discuss.huggingface.co/t/announcement-all-model-cards-will-be-migrated-to-hf-co-model-repos/2755
Original file history: https://github.com/huggingface/transformers/commits/master/model_cards/Michau/t5-base-en-generate-headline/README.md
README.md
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## About the model
|
2 |
+
|
3 |
+
The model has been trained on a collection of 500k articles with headings. Its purpose is to create a one-line heading suitable for the given article.
|
4 |
+
|
5 |
+
Sample code with a WikiNews article:
|
6 |
+
|
7 |
+
```python
|
8 |
+
import torch
|
9 |
+
from transformers import T5ForConditionalGeneration,T5Tokenizer
|
10 |
+
|
11 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
12 |
+
|
13 |
+
model = T5ForConditionalGeneration.from_pretrained("Michau/t5-base-en-generate-headline")
|
14 |
+
tokenizer = T5Tokenizer.from_pretrained("Michau/t5-base-en-generate-headline")
|
15 |
+
model = model.to(device)
|
16 |
+
|
17 |
+
article = '''
|
18 |
+
Very early yesterday morning, the United States President Donald Trump reported he and his wife First Lady Melania Trump tested positive for COVID-19. Officials said the Trumps' 14-year-old son Barron tested negative as did First Family and Senior Advisors Jared Kushner and Ivanka Trump.
|
19 |
+
Trump took to social media, posting at 12:54 am local time (0454 UTC) on Twitter, "Tonight, [Melania] and I tested positive for COVID-19. We will begin our quarantine and recovery process immediately. We will get through this TOGETHER!" Yesterday afternoon Marine One landed on the White House's South Lawn flying Trump to Walter Reed National Military Medical Center (WRNMMC) in Bethesda, Maryland.
|
20 |
+
Reports said both were showing "mild symptoms". Senior administration officials were tested as people were informed of the positive test. Senior advisor Hope Hicks had tested positive on Thursday.
|
21 |
+
Presidential physician Sean Conley issued a statement saying Trump has been given zinc, vitamin D, Pepcid and a daily Aspirin. Conley also gave a single dose of the experimental polyclonal antibodies drug from Regeneron Pharmaceuticals.
|
22 |
+
According to official statements, Trump, now operating from the WRNMMC, is to continue performing his duties as president during a 14-day quarantine. In the event of Trump becoming incapacitated, Vice President Mike Pence could take over the duties of president via the 25th Amendment of the US Constitution. The Pence family all tested negative as of yesterday and there were no changes regarding Pence's campaign events.
|
23 |
+
'''
|
24 |
+
|
25 |
+
text = "headline: " + article
|
26 |
+
|
27 |
+
max_len = 256
|
28 |
+
|
29 |
+
encoding = tokenizer.encode_plus(text, return_tensors = "pt")
|
30 |
+
input_ids = encoding["input_ids"].to(device)
|
31 |
+
attention_masks = encoding["attention_mask"].to(device)
|
32 |
+
|
33 |
+
beam_outputs = model.generate(
|
34 |
+
input_ids = input_ids,
|
35 |
+
attention_mask = attention_masks,
|
36 |
+
max_length = 64,
|
37 |
+
num_beams = 3,
|
38 |
+
early_stopping = True,
|
39 |
+
)
|
40 |
+
|
41 |
+
result = tokenizer.decode(beam_outputs[0])
|
42 |
+
print(result)
|
43 |
+
```
|
44 |
+
|
45 |
+
Result:
|
46 |
+
|
47 |
+
```Trump and First Lady Melania Test Positive for COVID-19```
|