add device to code
Browse files
README.md
CHANGED
@@ -380,16 +380,18 @@ Install/update transformers `pip install -U transformers`
|
|
380 |
Summarize text with pipeline:
|
381 |
|
382 |
```python
|
|
|
383 |
from transformers import pipeline
|
384 |
|
385 |
summarizer = pipeline(
|
386 |
-
|
387 |
-
|
388 |
-
)
|
|
|
389 |
long_text = "Here is a lot of text I don't want to read. Replace me"
|
390 |
|
391 |
result = summarizer(long_text)
|
392 |
-
print(result[0][
|
393 |
```
|
394 |
|
395 |
Pass [other parameters related to beam search textgen](https://huggingface.co/blog/how-to-generate) when calling `summarizer` to get even higher quality results.
|
|
|
380 |
Summarize text with pipeline:
|
381 |
|
382 |
```python
|
383 |
+
import torch
|
384 |
from transformers import pipeline
|
385 |
|
386 |
summarizer = pipeline(
|
387 |
+
"summarization",
|
388 |
+
"pszemraj/long-t5-tglobal-base-16384-book-summary",
|
389 |
+
device=0 if torch.cuda.is_available() else -1,
|
390 |
+
)
|
391 |
long_text = "Here is a lot of text I don't want to read. Replace me"
|
392 |
|
393 |
result = summarizer(long_text)
|
394 |
+
print(result[0]["summary_text"])
|
395 |
```
|
396 |
|
397 |
Pass [other parameters related to beam search textgen](https://huggingface.co/blog/how-to-generate) when calling `summarizer` to get even higher quality results.
|