├── LICENSE ├── README.md ├── T5_Model_Demo.ipynb └── t5.gif /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # T5 : Text-to-Text-Transfer-Transformer 2 | Demo of the T5 model for various pre-trained task. 3 |

4 | 5 |

6 | 7 | Also, please find link to original work [Exploring the Limits of Transfer Learning with aUnified Text-to-Text Transformer](https://arxiv.org/pdf/1910.10683.pdf) 8 | 9 | _P.S. I have written a detailed blog @ [Understanding T5 Model](https://prakhartechviz.blogspot.com/2020/04/t5-text-to-text-transfer-transformer.html). Feel free to read it and leave your valuable comments._ 10 | 11 | -------------------------------------------------------------------------------- /T5_Model_Demo.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "T5 Model Demo", 7 | "provenance": [], 8 | "collapsed_sections": [] 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | } 14 | }, 15 | "cells": [ 16 | { 17 | "cell_type": "markdown", 18 | "metadata": { 19 | "id": "n-wFJmDJ1jzs", 20 | "colab_type": "text" 21 | }, 22 | "source": [ 23 | "# T5 Model Demo\n", 24 | "Author: Prakhar Mishra\n", 25 | "\n", 26 | "Connect me on [LinkedIn](https://www.linkedin.com/in/prakhar21) \\\\\n", 27 | "See more of my work at [GitHub](https://www.github.com/prakhar21) \\\\\n", 28 | "Read by [Blogs](https://www.prakhartechviz.blogspot.com)" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "metadata": { 34 | "id": "yfcFfjXUj_kC", 35 | "colab_type": "code", 36 | "outputId": "a5a67f7a-a37a-4dd1-b3ca-589c0332bea8", 37 | "colab": { 38 | "base_uri": "https://localhost:8080/", 39 | "height": 416 40 | } 41 | }, 42 | "source": [ 43 | "!pip install transformers --upgrade\n", 44 | "#transformers >= 2.8.0" 45 | ], 46 | "execution_count": 115, 47 | "outputs": [ 48 | { 49 | "output_type": "stream", 50 | "text": [ 51 | "Requirement already up-to-date: transformers in /usr/local/lib/python3.6/dist-packages (2.8.0)\n", 52 | "Requirement already satisfied, skipping upgrade: sacremoses in /usr/local/lib/python3.6/dist-packages (from transformers) (0.0.41)\n", 53 | "Requirement already satisfied, skipping upgrade: boto3 in /usr/local/lib/python3.6/dist-packages (from transformers) (1.12.40)\n", 54 | "Requirement already satisfied, skipping upgrade: tqdm>=4.27 in /usr/local/lib/python3.6/dist-packages (from transformers) (4.38.0)\n", 55 | "Requirement already satisfied, skipping upgrade: filelock in /usr/local/lib/python3.6/dist-packages (from transformers) (3.0.12)\n", 56 | "Requirement already satisfied, skipping upgrade: requests in /usr/local/lib/python3.6/dist-packages (from transformers) (2.21.0)\n", 57 | "Requirement already satisfied, skipping upgrade: regex!=2019.12.17 in /usr/local/lib/python3.6/dist-packages (from transformers) (2019.12.20)\n", 58 | "Requirement already satisfied, skipping upgrade: numpy in /usr/local/lib/python3.6/dist-packages (from transformers) (1.18.2)\n", 59 | "Requirement already satisfied, skipping upgrade: sentencepiece in /usr/local/lib/python3.6/dist-packages (from transformers) (0.1.85)\n", 60 | "Requirement already satisfied, skipping upgrade: dataclasses; python_version < \"3.7\" in /usr/local/lib/python3.6/dist-packages (from transformers) (0.7)\n", 61 | "Requirement already satisfied, skipping upgrade: tokenizers==0.5.2 in /usr/local/lib/python3.6/dist-packages (from transformers) (0.5.2)\n", 62 | "Requirement already satisfied, skipping upgrade: six in /usr/local/lib/python3.6/dist-packages (from sacremoses->transformers) (1.12.0)\n", 63 | "Requirement already satisfied, skipping upgrade: joblib in /usr/local/lib/python3.6/dist-packages (from sacremoses->transformers) (0.14.1)\n", 64 | "Requirement already satisfied, skipping upgrade: click in /usr/local/lib/python3.6/dist-packages (from sacremoses->transformers) (7.1.1)\n", 65 | "Requirement already satisfied, skipping upgrade: jmespath<1.0.0,>=0.7.1 in /usr/local/lib/python3.6/dist-packages (from boto3->transformers) (0.9.5)\n", 66 | "Requirement already satisfied, skipping upgrade: botocore<1.16.0,>=1.15.40 in /usr/local/lib/python3.6/dist-packages (from boto3->transformers) (1.15.40)\n", 67 | "Requirement already satisfied, skipping upgrade: s3transfer<0.4.0,>=0.3.0 in /usr/local/lib/python3.6/dist-packages (from boto3->transformers) (0.3.3)\n", 68 | "Requirement already satisfied, skipping upgrade: urllib3<1.25,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests->transformers) (1.24.3)\n", 69 | "Requirement already satisfied, skipping upgrade: idna<2.9,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests->transformers) (2.8)\n", 70 | "Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests->transformers) (3.0.4)\n", 71 | "Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests->transformers) (2020.4.5.1)\n", 72 | "Requirement already satisfied, skipping upgrade: docutils<0.16,>=0.10 in /usr/local/lib/python3.6/dist-packages (from botocore<1.16.0,>=1.15.40->boto3->transformers) (0.15.2)\n", 73 | "Requirement already satisfied, skipping upgrade: python-dateutil<3.0.0,>=2.1 in /usr/local/lib/python3.6/dist-packages (from botocore<1.16.0,>=1.15.40->boto3->transformers) (2.8.1)\n" 74 | ], 75 | "name": "stdout" 76 | } 77 | ] 78 | }, 79 | { 80 | "cell_type": "markdown", 81 | "metadata": { 82 | "id": "4JoyxwyzskuP", 83 | "colab_type": "text" 84 | }, 85 | "source": [ 86 | "# Using Main Class" 87 | ] 88 | }, 89 | { 90 | "cell_type": "code", 91 | "metadata": { 92 | "id": "HeYHsEhuCkqE", 93 | "colab_type": "code", 94 | "colab": {} 95 | }, 96 | "source": [ 97 | "from transformers import T5Tokenizer, T5ForConditionalGeneration\n", 98 | "import time\n", 99 | "\n", 100 | "model = T5ForConditionalGeneration.from_pretrained('t5-small') #tiny-base\n", 101 | "tokenizer = T5Tokenizer.from_pretrained('t5-small') #tiny-base\n", 102 | "\n", 103 | "start_time = time.time()\n", 104 | "\n", 105 | "def summarization_infer(text, max=50):\n", 106 | " preprocess_text = text.replace(\"\\n\", \" \").strip()\n", 107 | " t5_prepared_Text = \"summarize: \"+preprocess_text\n", 108 | " tokenized_text = tokenizer.encode(t5_prepared_Text, return_tensors=\"pt\")\n", 109 | "\n", 110 | " summary_ids = model.generate(tokenized_text, min_length=30, max_length=max, top_k=100, top_p=0.8) #top-k top-p sampling strategy\n", 111 | " output = tokenizer.decode(summary_ids[0], skip_special_tokens=True)\n", 112 | " end_time = time.time()\n", 113 | " print (f'Time taken : {end_time-start_time}')\n", 114 | " return output\n", 115 | "\n", 116 | "def translation_infer(text, max=50):\n", 117 | " preprocess_text = text.replace(\"\\n\", \" \").strip()\n", 118 | " t5_prepared_Text = \"translate English to German: \"+preprocess_text\n", 119 | " tokenized_text = tokenizer.encode(t5_prepared_Text, return_tensors=\"pt\")\n", 120 | "\n", 121 | " translation_ids = model.generate(tokenized_text, min_length=10, max_length=50, early_stopping=True, num_beams=2)\n", 122 | " output = tokenizer.decode(translation_ids[0], skip_special_tokens=True)\n", 123 | " end_time = time.time()\n", 124 | " print (f'Time taken : {end_time-start_time}')\n", 125 | " return output\n", 126 | "\n", 127 | "def grammatical_acceptibility_infer(text):\n", 128 | " preprocess_text = text.replace(\"\\n\", \" \").strip()\n", 129 | " t5_prepared_Text = \"cola sentence: \"+preprocess_text\n", 130 | " tokenized_text = tokenizer.encode(t5_prepared_Text, return_tensors=\"pt\")\n", 131 | "\n", 132 | " grammar_ids = model.generate(tokenized_text, min_length=1, max_length=3)\n", 133 | " output = tokenizer.decode(grammar_ids[0], skip_special_tokens=True)\n", 134 | " end_time = time.time()\n", 135 | " print (f'Time taken : {end_time-start_time}')\n", 136 | " return output" 137 | ], 138 | "execution_count": 0, 139 | "outputs": [] 140 | }, 141 | { 142 | "cell_type": "markdown", 143 | "metadata": { 144 | "id": "NE8F2GoWsuZ3", 145 | "colab_type": "text" 146 | }, 147 | "source": [ 148 | "# Using PyTorch Pipelines\n", 149 | "Newly introduced in transformers v2.3.0, pipelines provides a high-level, easy to use, API for doing inference over a variety of downstream-tasks. Read [more practical documentation](https://www.kaggle.com/funtowiczmo/hugging-face-transformers-how-to-use-pipelines)" 150 | ] 151 | }, 152 | { 153 | "cell_type": "code", 154 | "metadata": { 155 | "id": "arzvSJ87kWsG", 156 | "colab_type": "code", 157 | "colab": { 158 | "base_uri": "https://localhost:8080/", 159 | "height": 54 160 | }, 161 | "outputId": "17e70727-8131-47c7-b25e-ac7ea9412564" 162 | }, 163 | "source": [ 164 | "from transformers import pipeline\n", 165 | "\n", 166 | "summarization_pipeline = pipeline(task='summarization', model=\"t5-small\") \n", 167 | "output = summarization_pipeline(text, min_length=30, max_length=50, top_k=100, top_p=0.8)\n", 168 | "print (output)" 169 | ], 170 | "execution_count": 147, 171 | "outputs": [ 172 | { 173 | "output_type": "stream", 174 | "text": [ 175 | "[{'summary_text': \"india's novel coronavirus count has increased to 21,700, according to the latest ministry of health and family welfare data . the death toll due to the virus is 686 after 34 more patients succumbed to the highly\"}]\n" 176 | ], 177 | "name": "stdout" 178 | } 179 | ] 180 | }, 181 | { 182 | "cell_type": "markdown", 183 | "metadata": { 184 | "id": "ksJD3i3w6Ee4", 185 | "colab_type": "text" 186 | }, 187 | "source": [ 188 | "# Making Flask API" 189 | ] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "metadata": { 194 | "id": "HOkFL8pp6GCB", 195 | "colab_type": "code", 196 | "colab": { 197 | "base_uri": "https://localhost:8080/", 198 | "height": 121 199 | }, 200 | "outputId": "2160c980-1b92-4314-ee18-e968cb5fcc9c" 201 | }, 202 | "source": [ 203 | "from flask import Flask, request\n", 204 | "\n", 205 | "app = Flask(__name__)\n", 206 | "\n", 207 | "@app.route('/infer', methods=['POST'])\n", 208 | "def infer():\n", 209 | " args = request.args['task']\n", 210 | " text = request.args['text']\n", 211 | " if args=='summarize':\n", 212 | " return summarization_infer(text)\n", 213 | " elif args=='translation':\n", 214 | " return translation_infer(text)\n", 215 | " else:\n", 216 | " return grammatical_acceptibility_infer(text)\n", 217 | "\n", 218 | "if __name__=='__main__':\n", 219 | " app.run(host='0.0.0.0', port=5555, debug=False, threaded=True)\n", 220 | " " 221 | ], 222 | "execution_count": 150, 223 | "outputs": [ 224 | { 225 | "output_type": "stream", 226 | "text": [ 227 | " * Serving Flask app \"__main__\" (lazy loading)\n", 228 | " * Environment: production\n", 229 | "\u001b[31m WARNING: This is a development server. Do not use it in a production deployment.\u001b[0m\n", 230 | "\u001b[2m Use a production WSGI server instead.\u001b[0m\n", 231 | " * Debug mode: off\n" 232 | ], 233 | "name": "stdout" 234 | }, 235 | { 236 | "output_type": "stream", 237 | "text": [ 238 | " * Running on http://0.0.0.0:5555/ (Press CTRL+C to quit)\n" 239 | ], 240 | "name": "stderr" 241 | } 242 | ] 243 | }, 244 | { 245 | "cell_type": "code", 246 | "metadata": { 247 | "id": "w5OWx66m8dyY", 248 | "colab_type": "code", 249 | "colab": {} 250 | }, 251 | "source": [ 252 | "text =\"\"\"\n", 253 | "With 1,229 fresh cases in the last 24 hours, India's novel coronavirus count has increased to 21,700, according to the latest Ministry of Health and Family Welfare data. Along with that, the death toll due to the virus has increased to 686 after 34 more patients succumbed to the highly contagious disease since yesterday, it said. So far, India has 16,689 active cases. There are also 77 foreign nationals who are affected by the virus, the ministry said. Apart from that, there are at least 4,324 patients who have been discharged or cured from the highly contagious disease and one has migrated from the country. Speaking at the press briefing today, Lav Agarwal, Joint Secretary, Health Ministry, said, \"As on today, we have 12 districts that did not have a fresh case in the last 28 days or more. There are now 78 districts (23 States/UTs) that has not reported any fresh cases during the last 14 Days.\" However, he also said that the increase in the number of coronavirus cases in the country is \"more or less linear, not exponential.\" According to the Thursday morning data of health ministry, 4,257 Covid-19 patients have been cured so far, bring the recovery rate to is 19.89% as of now, said Aggrawal. He also added, \"We have been able to cut virus transmission, minimise spread of COVID-19 in 30 days of lockdown.\"\n", 254 | "\"\"\"" 255 | ], 256 | "execution_count": 0, 257 | "outputs": [] 258 | }, 259 | { 260 | "cell_type": "code", 261 | "metadata": { 262 | "id": "YOQ-SwN08w3n", 263 | "colab_type": "code", 264 | "colab": { 265 | "base_uri": "https://localhost:8080/", 266 | "height": 72 267 | }, 268 | "outputId": "83d5fc39-7553-427f-db8f-3fdf048f0b78" 269 | }, 270 | "source": [ 271 | "summarization_infer(text)" 272 | ], 273 | "execution_count": 161, 274 | "outputs": [ 275 | { 276 | "output_type": "stream", 277 | "text": [ 278 | "Time taken : 158.3986692428589\n" 279 | ], 280 | "name": "stdout" 281 | }, 282 | { 283 | "output_type": "execute_result", 284 | "data": { 285 | "text/plain": [ 286 | "\"india's novel coronavirus count has increased to 21,700, according to the latest ministry of health and family welfare data. the death toll due to the virus has increased to 686 after 34 more patients succumbed to\"" 287 | ] 288 | }, 289 | "metadata": { 290 | "tags": [] 291 | }, 292 | "execution_count": 161 293 | } 294 | ] 295 | }, 296 | { 297 | "cell_type": "code", 298 | "metadata": { 299 | "id": "OMZsSvnT9sT5", 300 | "colab_type": "code", 301 | "colab": {} 302 | }, 303 | "source": [ 304 | "" 305 | ], 306 | "execution_count": 0, 307 | "outputs": [] 308 | } 309 | ] 310 | } -------------------------------------------------------------------------------- /t5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prakhar21/T5-Text-to-Text-Transfer-Transformer/5dae142475dd96853aaa36faacbcafd5dcf47bce/t5.gif --------------------------------------------------------------------------------