LukasStankevicius
commited on
Commit
•
63cabad
1
Parent(s):
b328056
Update README.md
Browse files
README.md
CHANGED
@@ -12,21 +12,9 @@ news articles using a transformer model**.
|
|
12 |
|
13 |
## Usage
|
14 |
```python
|
15 |
-
from transformers import
|
16 |
-
name
|
17 |
-
|
18 |
-
model = AutoModelForSeq2SeqLM.from_pretrained(name)
|
19 |
-
|
20 |
-
def decode(x):
|
21 |
-
return tokenizer.decode(x, skip_special_tokens=True)
|
22 |
-
|
23 |
-
def summarize(text_, **g_kwargs):
|
24 |
-
text_ = ' '.join(text_.strip().split())
|
25 |
-
input_dict = tokenizer(text_, padding=True, return_tensors="pt",
|
26 |
-
return_attention_mask=True)
|
27 |
-
output = model.generate(**input_dict, **g_kwargs)
|
28 |
-
predicted = list(map(decode, output.tolist()))[0]
|
29 |
-
return predicted
|
30 |
```
|
31 |
Given the following article body from [15min](#https://www.15min.lt/24sek/naujiena/lietuva/tarp-penkiu-rezultatyviausiu-tsrs-rinktines-visu-laiku-zaideju-trys-lietuviai-875-1380030):
|
32 |
```
|
@@ -41,9 +29,10 @@ Tarp žaidėjų, kurie sužaidė bent po 50 oficialių rungtynių Lietuvos rinkt
|
|
41 |
```
|
42 |
The summary can be obtained by:
|
43 |
```
|
|
|
44 |
g_kwargs = dict(max_length=512, num_beams=10, no_repeat_ngram_size=2,
|
45 |
early_stopping=True)
|
46 |
-
|
47 |
```
|
48 |
Output from above would be:
|
49 |
|
|
|
12 |
|
13 |
## Usage
|
14 |
```python
|
15 |
+
from transformers import pipeline
|
16 |
+
name= "LukasStankevicius/t5-base-lithuanian-news-summaries-175"
|
17 |
+
my_pipeline = pipeline(task="text2text-generation", model=name, framework="pt")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
```
|
19 |
Given the following article body from [15min](#https://www.15min.lt/24sek/naujiena/lietuva/tarp-penkiu-rezultatyviausiu-tsrs-rinktines-visu-laiku-zaideju-trys-lietuviai-875-1380030):
|
20 |
```
|
|
|
29 |
```
|
30 |
The summary can be obtained by:
|
31 |
```
|
32 |
+
text = ' '.join(text.strip().split())
|
33 |
g_kwargs = dict(max_length=512, num_beams=10, no_repeat_ngram_size=2,
|
34 |
early_stopping=True)
|
35 |
+
my_pipeline(text, truncation=True, **g_kwargs)[0]["generated_text"]
|
36 |
```
|
37 |
Output from above would be:
|
38 |
|