Last active
November 10, 2020 18:15
-
-
Save manmohan24nov/083ec048f0fe09317abf75482ae86228 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> from transformers import T5Tokenizer, T5ForConditionalGeneration | |
2020-11-10 18:10:11.206223: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1 | |
>>> model = T5ForConditionalGeneration.from_pretrained('t5-base') | |
>>> tokenizer = T5Tokenizer.from_pretrained('t5-base') | |
>>> text = ".".join(comment_section) | |
>>> Preprocessed_text = "summarize: " + text | |
>>> tokens_input = tokenizer.encode(Preprocessed_text,return_tensors="pt", max_length=512, truncation=True) | |
>>> summary_ids = model.generate(tokens_input, | |
... min_length=60, | |
... max_length=180, | |
... length_penalty=4.0) | |
>>> | |
>>> summary = tokenizer.decode(summary_ids[0]) | |
>>> print(summary) | |
british queen elizabeth sends birthday cards to people who turn 100 on their birthday. | |
i think it's a weird phenomenon because it's not automatic. | |
i've never heard of a queen of england so i can't help but think it's a joke. | |
i'd love to see a british queen congratulate her on her 100th birthday. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment