From 00ea100e965a9df44b2934bc2c5a40cd1cd70d91 Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Fri, 27 Mar 2020 16:05:37 +0100 Subject: [PATCH] add summarization and translation to notebook (#3478) --- notebooks/03-pipelines.ipynb | 3503 +++++++++++++++++++++++++++++----- 1 file changed, 3021 insertions(+), 482 deletions(-) diff --git a/notebooks/03-pipelines.ipynb b/notebooks/03-pipelines.ipynb index 908cb004a3..b346d77ea4 100644 --- a/notebooks/03-pipelines.ipynb +++ b/notebooks/03-pipelines.ipynb @@ -1,511 +1,3050 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": { + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.6" + }, "pycharm": { - "name": "#%% md\n" - } - }, - "source": [ - "## How can I leverage State-of-the-Art Natural Language Models with only one line of code ?" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "pycharm": { - "name": "#%% md\n" - } - }, - "source": [ - "Newly introduced in transformers v2.3.0, **pipelines** provides a high-level, easy to use,\n", - "API for doing inference over a variety of downstream-tasks, including: \n", - "\n", - "- Sentence Classification (Sentiment Analysis): Indicate if the overall sentence is either positive or negative. _(Binary Classification task or Logitic Regression task)_\n", - "- Token Classification (Named Entity Recognition, Part-of-Speech tagging): For each sub-entities _(**tokens**)_ in the input, assign them a label _(Classification task)_.\n", - "- Question-Answering: Provided a tuple (question, context) the model should find the span of text in **content** answering the **question**.\n", - "- Mask-Filling: Suggests possible word(s) to fill the masked input with respect to the provided **context**.\n", - "- Feature Extraction: Maps the input to a higher, multi-dimensional space learned from the data.\n", - "\n", - "Pipelines encapsulate the overall process of every NLP process:\n", - " \n", - " 1. Tokenization: Split the initial input into multiple sub-entities with ... properties (i.e. tokens).\n", - " 2. Inference: Maps every tokens into a more meaningful representation. \n", - " 3. Decoding: Use the above representation to generate and/or extract the final output for the underlying task.\n", - "\n", - "The overall API is exposed to the end-user through the `pipeline()` method with the following \n", - "structure:\n", - "\n", - "```python\n", - "from transformers import pipeline\n", - "\n", - "# Using default model and tokenizer for the task\n", - "pipeline(\"\")\n", - "\n", - "# Using a user-specified model\n", - "pipeline(\"\", model=\"\")\n", - "\n", - "# Using custom model/tokenizer as str\n", - "pipeline('', model='', tokenizer='')\n", - "```" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "outputs": [], - "source": [ - "!pip install transformers" - ], - "metadata": { - "collapsed": false, - "pycharm": { - "name": "#%% code\n" - } - } - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "pycharm": { - "is_executing": false, - "name": "#%% code \n" - } - }, - "outputs": [], - "source": [ - "from __future__ import print_function\n", - "import ipywidgets as widgets\n", - "from transformers import pipeline" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "pycharm": { - "name": "#%% md\n" - } - }, - "source": [ - "## 1. Sentence Classification - Sentiment Analysis" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "pycharm": { - "is_executing": false, - "name": "#%% code\n" - } - }, - "outputs": [ - { - "data": { - "text/plain": "HBox(children=(FloatProgress(value=0.0, description='Downloading', max=230.0, style=ProgressStyle(description_…", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 0, - "model_id": "c9db53f30b9446c0af03268633a966c0" + "stem_cell": { + "cell_type": "raw", + "source": [], + "metadata": { + "collapsed": false + } } - }, - "metadata": {}, - "output_type": "display_data" }, - { - "name": "stdout", - "text": [ - "\n" - ], - "output_type": "stream" + "colab": { + "name": "03-pipelines.ipynb", + "provenance": [] }, - { - "data": { - "text/plain": "[{'label': 'POSITIVE', 'score': 0.9997656}]" - }, - "metadata": {}, - "output_type": "execute_result", - "execution_count": 8 - } - ], - "source": [ - "nlp_sentence_classif = pipeline('sentiment-analysis')\n", - "nlp_sentence_classif('Such a nice weather outside !')" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "pycharm": { - "name": "#%% md\n" - } - }, - "source": [ - "## 2. Token Classification - Named Entity Recognition" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "pycharm": { - "is_executing": false, - "name": "#%% code\n" - } - }, - "outputs": [ - { - "data": { - "text/plain": "HBox(children=(FloatProgress(value=0.0, description='Downloading', max=230.0, style=ProgressStyle(description_…", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 0, - "model_id": "1e300789e22644f1aed66a5ed60e75c4" + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "4bab5df43b3c46caadf48e264344ab42": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "state": { + "_view_name": "HBoxView", + "_dom_classes": [], + "_model_name": "HBoxModel", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.5.0", + "box_style": "", + "layout": "IPY_MODEL_9b426c68631f4bb288e2ca79aad9f9d9", + "_model_module": "@jupyter-widgets/controls", + "children": [ + "IPY_MODEL_6902104f7ec143519fb1a6ab9363d4a0", + "IPY_MODEL_c133fb34fe2a4aba8a6b233671af8b04" + ] + } + }, + "9b426c68631f4bb288e2ca79aad9f9d9": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "6902104f7ec143519fb1a6ab9363d4a0": { + "model_module": "@jupyter-widgets/controls", + "model_name": "IntProgressModel", + "state": { + "_view_name": "ProgressView", + "style": "IPY_MODEL_e3f72d443a74414ca62c2b848d34b125", + "_dom_classes": [], + "description": "Downloading: 100%", + "_model_name": "IntProgressModel", + "bar_style": "success", + "max": 230, + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": 230, + "_view_count": null, + "_view_module_version": "1.5.0", + "orientation": "horizontal", + "min": 0, + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_5462b581976e47048642aa6bc12435bd" + } + }, + "c133fb34fe2a4aba8a6b233671af8b04": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "state": { + "_view_name": "HTMLView", + "style": "IPY_MODEL_ad84da685cf44abb90d17d9d2e023b48", + "_dom_classes": [], + "description": "", + "_model_name": "HTMLModel", + "placeholder": "​", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": " 230/230 [00:01<00:00, 194B/s]", + "_view_count": null, + "_view_module_version": "1.5.0", + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_a246f9eea2d7440cb979e728741d2e32" + } + }, + "e3f72d443a74414ca62c2b848d34b125": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "ProgressStyleModel", + "description_width": "initial", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "bar_color": null, + "_model_module": "@jupyter-widgets/controls" + } + }, + "5462b581976e47048642aa6bc12435bd": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "ad84da685cf44abb90d17d9d2e023b48": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "DescriptionStyleModel", + "description_width": "", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "_model_module": "@jupyter-widgets/controls" + } + }, + "a246f9eea2d7440cb979e728741d2e32": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "451464c936444ba5a652b46c1b4f9931": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "state": { + "_view_name": "HBoxView", + "_dom_classes": [], + "_model_name": "HBoxModel", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.5.0", + "box_style": "", + "layout": "IPY_MODEL_279291efd2c14a9eb2c3b98efbf152ad", + "_model_module": "@jupyter-widgets/controls", + "children": [ + "IPY_MODEL_b6e1a2e57f4948a39283f1370352612c", + "IPY_MODEL_9d4941ebdfa64978b47232f6e5908d97" + ] + } + }, + "279291efd2c14a9eb2c3b98efbf152ad": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "b6e1a2e57f4948a39283f1370352612c": { + "model_module": "@jupyter-widgets/controls", + "model_name": "IntProgressModel", + "state": { + "_view_name": "ProgressView", + "style": "IPY_MODEL_1006cc0fab1e4139bb7b135486261c92", + "_dom_classes": [], + "description": "Downloading: 100%", + "_model_name": "IntProgressModel", + "bar_style": "success", + "max": 230, + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": 230, + "_view_count": null, + "_view_module_version": "1.5.0", + "orientation": "horizontal", + "min": 0, + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_691c0bae60364890ab74934261207d4d" + } + }, + "9d4941ebdfa64978b47232f6e5908d97": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "state": { + "_view_name": "HTMLView", + "style": "IPY_MODEL_405afa5bb8b840d8bc0850e02f593ce4", + "_dom_classes": [], + "description": "", + "_model_name": "HTMLModel", + "placeholder": "​", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": " 230/230 [00:01<00:00, 198B/s]", + "_view_count": null, + "_view_module_version": "1.5.0", + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_78c718e3d5fa4cb892217260bea6d540" + } + }, + "1006cc0fab1e4139bb7b135486261c92": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "ProgressStyleModel", + "description_width": "initial", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "bar_color": null, + "_model_module": "@jupyter-widgets/controls" + } + }, + "691c0bae60364890ab74934261207d4d": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "405afa5bb8b840d8bc0850e02f593ce4": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "DescriptionStyleModel", + "description_width": "", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "_model_module": "@jupyter-widgets/controls" + } + }, + "78c718e3d5fa4cb892217260bea6d540": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "7d66a4534c164d2f9493fc0467abebbd": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "state": { + "_view_name": "HBoxView", + "_dom_classes": [], + "_model_name": "HBoxModel", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.5.0", + "box_style": "", + "layout": "IPY_MODEL_7a15588f85b14f2b93e32b4c0442fa1b", + "_model_module": "@jupyter-widgets/controls", + "children": [ + "IPY_MODEL_213567d815894ca08041f6d682ced3c9", + "IPY_MODEL_ee6c95e700e64d0a9ebec2c1545dd083" + ] + } + }, + "7a15588f85b14f2b93e32b4c0442fa1b": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "213567d815894ca08041f6d682ced3c9": { + "model_module": "@jupyter-widgets/controls", + "model_name": "IntProgressModel", + "state": { + "_view_name": "ProgressView", + "style": "IPY_MODEL_3e556abf5c4a4ee69d52366fd59471b2", + "_dom_classes": [], + "description": "Downloading: 100%", + "_model_name": "IntProgressModel", + "bar_style": "success", + "max": 230, + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": 230, + "_view_count": null, + "_view_module_version": "1.5.0", + "orientation": "horizontal", + "min": 0, + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_876b2eba73fa46a6a941d2e3a8a975ad" + } + }, + "ee6c95e700e64d0a9ebec2c1545dd083": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "state": { + "_view_name": "HTMLView", + "style": "IPY_MODEL_cd64e3f20b23483daa79712bde6622ea", + "_dom_classes": [], + "description": "", + "_model_name": "HTMLModel", + "placeholder": "​", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": " 230/230 [00:02<00:00, 85.4B/s]", + "_view_count": null, + "_view_module_version": "1.5.0", + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_67cbaa1f55d24e62ad6b022af36bca56" + } + }, + "3e556abf5c4a4ee69d52366fd59471b2": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "ProgressStyleModel", + "description_width": "initial", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "bar_color": null, + "_model_module": "@jupyter-widgets/controls" + } + }, + "876b2eba73fa46a6a941d2e3a8a975ad": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "cd64e3f20b23483daa79712bde6622ea": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "DescriptionStyleModel", + "description_width": "", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "_model_module": "@jupyter-widgets/controls" + } + }, + "67cbaa1f55d24e62ad6b022af36bca56": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "58669943d3064f309436157270544c08": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "state": { + "_view_name": "HBoxView", + "_dom_classes": [], + "_model_name": "HBoxModel", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.5.0", + "box_style": "", + "layout": "IPY_MODEL_3eff293c2b554d85aefaea863e29b678", + "_model_module": "@jupyter-widgets/controls", + "children": [ + "IPY_MODEL_d0b9925f3dde46008bf186cf5ef7722d", + "IPY_MODEL_427e07ce24a442af84ddc71f9463fdff" + ] + } + }, + "3eff293c2b554d85aefaea863e29b678": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "d0b9925f3dde46008bf186cf5ef7722d": { + "model_module": "@jupyter-widgets/controls", + "model_name": "IntProgressModel", + "state": { + "_view_name": "ProgressView", + "style": "IPY_MODEL_1eb2fa080ec44f8c8d5f6f52900277ab", + "_dom_classes": [], + "description": "Downloading: 100%", + "_model_name": "IntProgressModel", + "bar_style": "success", + "max": 230, + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": 230, + "_view_count": null, + "_view_module_version": "1.5.0", + "orientation": "horizontal", + "min": 0, + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_23377596349e40a89ea57c8558660073" + } + }, + "427e07ce24a442af84ddc71f9463fdff": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "state": { + "_view_name": "HTMLView", + "style": "IPY_MODEL_a35703cc8ff44e93a8c0eb413caddc40", + "_dom_classes": [], + "description": "", + "_model_name": "HTMLModel", + "placeholder": "​", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": " 230/230 [00:01<00:00, 120B/s]", + "_view_count": null, + "_view_module_version": "1.5.0", + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_9df7014c99b343f3b178fa020ff56010" + } + }, + "1eb2fa080ec44f8c8d5f6f52900277ab": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "ProgressStyleModel", + "description_width": "initial", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "bar_color": null, + "_model_module": "@jupyter-widgets/controls" + } + }, + "23377596349e40a89ea57c8558660073": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "a35703cc8ff44e93a8c0eb413caddc40": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "DescriptionStyleModel", + "description_width": "", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "_model_module": "@jupyter-widgets/controls" + } + }, + "9df7014c99b343f3b178fa020ff56010": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "57e8c36594d043c581c766b434037771": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "state": { + "_view_name": "HBoxView", + "_dom_classes": [], + "_model_name": "HBoxModel", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.5.0", + "box_style": "", + "layout": "IPY_MODEL_82760185d5c14a808cbf6639b589f249", + "_model_module": "@jupyter-widgets/controls", + "children": [ + "IPY_MODEL_f2a1b430594b4736879cdff4ec532098", + "IPY_MODEL_c81338551e60474fab9e9950fe5df294" + ] + } + }, + "82760185d5c14a808cbf6639b589f249": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "f2a1b430594b4736879cdff4ec532098": { + "model_module": "@jupyter-widgets/controls", + "model_name": "IntProgressModel", + "state": { + "_view_name": "ProgressView", + "style": "IPY_MODEL_98563b405bd043a9a301a43909e43157", + "_dom_classes": [], + "description": "Downloading: 100%", + "_model_name": "IntProgressModel", + "bar_style": "success", + "max": 230, + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": 230, + "_view_count": null, + "_view_module_version": "1.5.0", + "orientation": "horizontal", + "min": 0, + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_8c0e1b7fb6ac4ee7bbbaf6020b40cc77" + } + }, + "c81338551e60474fab9e9950fe5df294": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "state": { + "_view_name": "HTMLView", + "style": "IPY_MODEL_ad78042ee71a41fd989e4b4ce9d2e3c1", + "_dom_classes": [], + "description": "", + "_model_name": "HTMLModel", + "placeholder": "​", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": " 230/230 [00:01<00:00, 128B/s]", + "_view_count": null, + "_view_module_version": "1.5.0", + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_40c8d2617f3d4c84b923b140456fa5da" + } + }, + "98563b405bd043a9a301a43909e43157": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "ProgressStyleModel", + "description_width": "initial", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "bar_color": null, + "_model_module": "@jupyter-widgets/controls" + } + }, + "8c0e1b7fb6ac4ee7bbbaf6020b40cc77": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "ad78042ee71a41fd989e4b4ce9d2e3c1": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "DescriptionStyleModel", + "description_width": "", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "_model_module": "@jupyter-widgets/controls" + } + }, + "40c8d2617f3d4c84b923b140456fa5da": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "311a65b811964ebfa2c064eb348b3ce9": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "state": { + "_view_name": "HBoxView", + "_dom_classes": [], + "_model_name": "HBoxModel", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.5.0", + "box_style": "", + "layout": "IPY_MODEL_5a2032c44d0e4f8cbaf512e6c29214cd", + "_model_module": "@jupyter-widgets/controls", + "children": [ + "IPY_MODEL_54d1ff55e0094a4fa2b62ecdfb428328", + "IPY_MODEL_2e45f2d7d65246ecb8d6e666d026ac13" + ] + } + }, + "5a2032c44d0e4f8cbaf512e6c29214cd": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "54d1ff55e0094a4fa2b62ecdfb428328": { + "model_module": "@jupyter-widgets/controls", + "model_name": "IntProgressModel", + "state": { + "_view_name": "ProgressView", + "style": "IPY_MODEL_e05c0ec3b49e4d4990a943d428532fb0", + "_dom_classes": [], + "description": "Downloading: 100%", + "_model_name": "IntProgressModel", + "bar_style": "success", + "max": 230, + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": 230, + "_view_count": null, + "_view_module_version": "1.5.0", + "orientation": "horizontal", + "min": 0, + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_39721262fc1e4456966d92fabe0f54ea" + } + }, + "2e45f2d7d65246ecb8d6e666d026ac13": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "state": { + "_view_name": "HTMLView", + "style": "IPY_MODEL_4486f8a2efc34b9aab3864eb5ad2ba48", + "_dom_classes": [], + "description": "", + "_model_name": "HTMLModel", + "placeholder": "​", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": " 230/230 [00:01<00:00, 126B/s]", + "_view_count": null, + "_view_module_version": "1.5.0", + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_d6228324f3444aa6bd1323d65ae4ff75" + } + }, + "e05c0ec3b49e4d4990a943d428532fb0": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "ProgressStyleModel", + "description_width": "initial", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "bar_color": null, + "_model_module": "@jupyter-widgets/controls" + } + }, + "39721262fc1e4456966d92fabe0f54ea": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "4486f8a2efc34b9aab3864eb5ad2ba48": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "DescriptionStyleModel", + "description_width": "", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "_model_module": "@jupyter-widgets/controls" + } + }, + "d6228324f3444aa6bd1323d65ae4ff75": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "fd44cf6ab17e4b768b2e1d5cb8ce5af9": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "state": { + "_view_name": "HBoxView", + "_dom_classes": [], + "_model_name": "HBoxModel", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.5.0", + "box_style": "", + "layout": "IPY_MODEL_b8c0ea31578d4eaaa69251d0004fd8c6", + "_model_module": "@jupyter-widgets/controls", + "children": [ + "IPY_MODEL_2015cd9c1da9467290ecd9019af231eb", + "IPY_MODEL_17bacdaee55b43e8977c4dfe4f7245bb" + ] + } + }, + "b8c0ea31578d4eaaa69251d0004fd8c6": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "2015cd9c1da9467290ecd9019af231eb": { + "model_module": "@jupyter-widgets/controls", + "model_name": "IntProgressModel", + "state": { + "_view_name": "ProgressView", + "style": "IPY_MODEL_879ef9e1a0e94f3d96ed56fb4bae64b8", + "_dom_classes": [], + "description": "Downloading: 100%", + "_model_name": "IntProgressModel", + "bar_style": "success", + "max": 230, + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": 230, + "_view_count": null, + "_view_module_version": "1.5.0", + "orientation": "horizontal", + "min": 0, + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_7ab70324d42647acac5020b387955caf" + } + }, + "17bacdaee55b43e8977c4dfe4f7245bb": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "state": { + "_view_name": "HTMLView", + "style": "IPY_MODEL_31d97ecf78fa412c99e6659196d82828", + "_dom_classes": [], + "description": "", + "_model_name": "HTMLModel", + "placeholder": "​", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": " 230/230 [00:01<00:00, 129B/s]", + "_view_count": null, + "_view_module_version": "1.5.0", + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_c6be5d48ec3c4c799d1445607e5f1ac6" + } + }, + "879ef9e1a0e94f3d96ed56fb4bae64b8": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "ProgressStyleModel", + "description_width": "initial", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "bar_color": null, + "_model_module": "@jupyter-widgets/controls" + } + }, + "7ab70324d42647acac5020b387955caf": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "31d97ecf78fa412c99e6659196d82828": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "DescriptionStyleModel", + "description_width": "", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "_model_module": "@jupyter-widgets/controls" + } + }, + "c6be5d48ec3c4c799d1445607e5f1ac6": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "0bd407b4975f49c3827aede14c59501c": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DropdownModel", + "state": { + "_options_labels": [ + "sentiment-analysis", + "ner", + "fill_mask" + ], + "_view_name": "DropdownView", + "style": "IPY_MODEL_3f5406df699e44f5b60678c1c13500f5", + "_dom_classes": [], + "description": "Task:", + "_model_name": "DropdownModel", + "index": 1, + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_view_count": null, + "disabled": false, + "_view_module_version": "1.5.0", + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_17768469581445b68246ed308ce69326" + } + }, + "3f5406df699e44f5b60678c1c13500f5": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "DescriptionStyleModel", + "description_width": "", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "_model_module": "@jupyter-widgets/controls" + } + }, + "17768469581445b68246ed308ce69326": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "74cbcbae5cac4f12abf080a38390f05c": { + "model_module": "@jupyter-widgets/controls", + "model_name": "TextModel", + "state": { + "_view_name": "TextView", + "style": "IPY_MODEL_62b10ca525cc4ac68f3a006434eb7416", + "_dom_classes": [], + "description": "Your input:", + "_model_name": "TextModel", + "placeholder": "Enter something", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": "Peter Pan likes to go on holiday in Marseille, France.", + "_view_count": null, + "disabled": false, + "_view_module_version": "1.5.0", + "continuous_update": true, + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_211109537fbe4e60b89a238c89db1346" + } + }, + "62b10ca525cc4ac68f3a006434eb7416": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "DescriptionStyleModel", + "description_width": "", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "_model_module": "@jupyter-widgets/controls" + } + }, + "211109537fbe4e60b89a238c89db1346": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "d79946ac16ea4855a0bbe2ca2a4d4bf5": { + "model_module": "@jupyter-widgets/controls", + "model_name": "TextareaModel", + "state": { + "_view_name": "TextareaView", + "style": "IPY_MODEL_ab5774ac19f84ab18ddf09a63433df00", + "rows": null, + "_dom_classes": [], + "description": "Context:", + "_model_name": "TextareaModel", + "placeholder": "Enter something", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": "Einstein is famous for the general theory of relativity", + "_view_count": null, + "disabled": false, + "_view_module_version": "1.5.0", + "continuous_update": true, + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_a02164204f0f43668bc36a907e720af7" + } + }, + "ab5774ac19f84ab18ddf09a63433df00": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "DescriptionStyleModel", + "description_width": "", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "_model_module": "@jupyter-widgets/controls" + } + }, + "a02164204f0f43668bc36a907e720af7": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "3b12aec414b14221ad2a11dfd975faa0": { + "model_module": "@jupyter-widgets/controls", + "model_name": "TextModel", + "state": { + "_view_name": "TextView", + "style": "IPY_MODEL_d305ba1662e3466c93ab5cca7ebf8f33", + "_dom_classes": [], + "description": "Question:", + "_model_name": "TextModel", + "placeholder": "Enter something", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": "Why is Einstein famous for ?", + "_view_count": null, + "disabled": false, + "_view_module_version": "1.5.0", + "continuous_update": true, + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_879f7a3747ad455d810c7a29918648ee" + } + }, + "d305ba1662e3466c93ab5cca7ebf8f33": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "DescriptionStyleModel", + "description_width": "", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "_model_module": "@jupyter-widgets/controls" + } + }, + "879f7a3747ad455d810c7a29918648ee": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + } } - }, - "metadata": {}, - "output_type": "display_data" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "pycharm": { + "name": "#%% md\n" + }, + "id": "qUU7wy-brl_H", + "colab_type": "text" + }, + "source": [ + "## How can I leverage State-of-the-Art Natural Language Models with only one line of code ?" + ] }, { - "name": "stdout", - "text": [ - "\n" - ], - "output_type": "stream" + "cell_type": "markdown", + "metadata": { + "pycharm": { + "name": "#%% md\n" + }, + "id": "-HLOHXuArl_L", + "colab_type": "text" + }, + "source": [ + "Newly introduced in transformers v2.3.0, **pipelines** provides a high-level, easy to use,\n", + "API for doing inference over a variety of downstream-tasks, including: \n", + "\n", + "- ***Sentence Classification _(Sentiment Analysis)_***: Indicate if the overall sentence is either positive or negative, i.e. *binary classification task* or *logitic regression task*.\n", + "- ***Token Classification (Named Entity Recognition, Part-of-Speech tagging)***: For each sub-entities _(*tokens*)_ in the input, assign them a label, i.e. classification task.\n", + "- ***Question-Answering***: Provided a tuple (`question`, `context`) the model should find the span of text in `content` answering the `question`.\n", + "- ***Mask-Filling***: Suggests possible word(s) to fill the masked input with respect to the provided `context`.\n", + "- ***Summarization***: Summarizes the ``input`` article to a shorter article.\n", + "- ***Translation***: Translates the input from a language to another language.\n", + "- ***Feature Extraction***: Maps the input to a higher, multi-dimensional space learned from the data.\n", + "\n", + "Pipelines encapsulate the overall process of every NLP process:\n", + " \n", + " 1. *Tokenization*: Split the initial input into multiple sub-entities with ... properties (i.e. tokens).\n", + " 2. *Inference*: Maps every tokens into a more meaningful representation. \n", + " 3. *Decoding*: Use the above representation to generate and/or extract the final output for the underlying task.\n", + "\n", + "The overall API is exposed to the end-user through the `pipeline()` method with the following \n", + "structure:\n", + "\n", + "```python\n", + "from transformers import pipeline\n", + "\n", + "# Using default model and tokenizer for the task\n", + "pipeline(\"\")\n", + "\n", + "# Using a user-specified model\n", + "pipeline(\"\", model=\"\")\n", + "\n", + "# Using custom model/tokenizer as str\n", + "pipeline('', model='', tokenizer='')\n", + "```" + ] }, { - "data": { - "text/plain": "[{'word': 'Hu', 'score': 0.9970937967300415, 'entity': 'I-ORG'},\n {'word': '##gging', 'score': 0.9345750212669373, 'entity': 'I-ORG'},\n {'word': 'Face', 'score': 0.9787060022354126, 'entity': 'I-ORG'},\n {'word': 'French', 'score': 0.9981995820999146, 'entity': 'I-MISC'},\n {'word': 'New', 'score': 0.9983047246932983, 'entity': 'I-LOC'},\n {'word': '-', 'score': 0.8913455009460449, 'entity': 'I-LOC'},\n {'word': 'York', 'score': 0.9979523420333862, 'entity': 'I-LOC'}]" - }, - "metadata": {}, - "output_type": "execute_result", - "execution_count": 9 - } - ], - "source": [ - "nlp_token_class = pipeline('ner')\n", - "nlp_token_class('Hugging Face is a French company based in New-York.')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 3. Question Answering" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "pycharm": { - "is_executing": false, - "name": "#%% code\n" - } - }, - "outputs": [ - { - "data": { - "text/plain": "HBox(children=(FloatProgress(value=0.0, description='Downloading', max=230.0, style=ProgressStyle(description_…", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 0, - "model_id": "82aca58f1ea24b4cb37f16402e8a5923" - } - }, - "metadata": {}, - "output_type": "display_data" + "cell_type": "code", + "metadata": { + "pycharm": { + "name": "#%% code\n" + }, + "id": "4maAknWNrl_N", + "colab_type": "code", + "colab": {} + }, + "source": [ + "!pip install -q transformers" + ], + "execution_count": 0, + "outputs": [] }, { - "name": "stdout", - "text": [ - "\n" - ], - "output_type": "stream" + "cell_type": "code", + "metadata": { + "pycharm": { + "is_executing": false, + "name": "#%% code \n" + }, + "id": "uKaqzCh6rl_V", + "colab_type": "code", + "colab": {} + }, + "source": [ + "from __future__ import print_function\n", + "import ipywidgets as widgets\n", + "from transformers import pipeline" + ], + "execution_count": 0, + "outputs": [] }, { - "name": "stderr", - "text": [ - "convert squad examples to features: 100%|██████████| 1/1 [00:00<00:00, 225.51it/s]\n", - "add example index and unique id: 100%|██████████| 1/1 [00:00<00:00, 2158.67it/s]\n" - ], - "output_type": "stream" + "cell_type": "markdown", + "metadata": { + "pycharm": { + "name": "#%% md\n" + }, + "id": "uDPZ42Uerl_b", + "colab_type": "text" + }, + "source": [ + "## 1. Sentence Classification - Sentiment Analysis" + ] }, { - "data": { - "text/plain": "{'score': 0.9632966867654424, 'start': 42, 'end': 50, 'answer': 'New-York.'}" - }, - "metadata": {}, - "output_type": "execute_result", - "execution_count": 10 - } - ], - "source": [ - "nlp_qa = pipeline('question-answering')\n", - "nlp_qa(context='Hugging Face is a French company based in New-York.', question='Where is based Hugging Face ?')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 4. Text Generation - Mask Filling" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "pycharm": { - "is_executing": false, - "name": "#%% code\n" - } - }, - "outputs": [ - { - "data": { - "text/plain": "HBox(children=(FloatProgress(value=0.0, description='Downloading', max=230.0, style=ProgressStyle(description_…", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 0, - "model_id": "49df2227b4fa4eb28dcdcfc3d9261d0f" - } - }, - "metadata": {}, - "output_type": "display_data" + "cell_type": "code", + "metadata": { + "pycharm": { + "is_executing": false, + "name": "#%% code\n" + }, + "id": "AMRXHQw9rl_d", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 83, + "referenced_widgets": [ + "4bab5df43b3c46caadf48e264344ab42", + "9b426c68631f4bb288e2ca79aad9f9d9", + "6902104f7ec143519fb1a6ab9363d4a0", + "c133fb34fe2a4aba8a6b233671af8b04", + "e3f72d443a74414ca62c2b848d34b125", + "5462b581976e47048642aa6bc12435bd", + "ad84da685cf44abb90d17d9d2e023b48", + "a246f9eea2d7440cb979e728741d2e32" + ] + }, + "outputId": "a7a10851-b71e-4553-9afc-04066120410d" + }, + "source": [ + "nlp_sentence_classif = pipeline('sentiment-analysis')\n", + "nlp_sentence_classif('Such a nice weather outside !')" + ], + "execution_count": 3, + "outputs": [ + { + "output_type": "display_data", + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "4bab5df43b3c46caadf48e264344ab42", + "version_minor": 0, + "version_major": 2 + }, + "text/plain": [ + "HBox(children=(IntProgress(value=0, description='Downloading', max=230, style=ProgressStyle(description_width=…" + ] + }, + "metadata": { + "tags": [] + } + }, + { + "output_type": "stream", + "text": [ + "\n" + ], + "name": "stdout" + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "[{'label': 'POSITIVE', 'score': 0.9997656}]" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 3 + } + ] }, { - "name": "stdout", - "text": [ - "\n" - ], - "output_type": "stream" + "cell_type": "markdown", + "metadata": { + "pycharm": { + "name": "#%% md\n" + }, + "id": "RY8aUJTvrl_k", + "colab_type": "text" + }, + "source": [ + "## 2. Token Classification - Named Entity Recognition" + ] }, { - "data": { - "text/plain": "[{'sequence': ' Hugging Face is a French company based in Paris',\n 'score': 0.23106691241264343,\n 'token': 2201},\n {'sequence': ' Hugging Face is a French company based in Lyon',\n 'score': 0.0819825753569603,\n 'token': 12790},\n {'sequence': ' Hugging Face is a French company based in Geneva',\n 'score': 0.04769463092088699,\n 'token': 11559},\n {'sequence': ' Hugging Face is a French company based in Brussels',\n 'score': 0.047622501850128174,\n 'token': 6497},\n {'sequence': ' Hugging Face is a French company based in France',\n 'score': 0.04130595177412033,\n 'token': 1470}]" - }, - "metadata": {}, - "output_type": "execute_result", - "execution_count": 11 - } - ], - "source": [ - "nlp_fill = pipeline('fill-mask')\n", - "nlp_fill('Hugging Face is a French company based in ' + nlp_fill.tokenizer.mask_token)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 5. Projection - Features Extraction " - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "pycharm": { - "is_executing": false, - "name": "#%% code\n" - } - }, - "outputs": [ - { - "data": { - "text/plain": "HBox(children=(FloatProgress(value=0.0, description='Downloading', max=230.0, style=ProgressStyle(description_…", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 0, - "model_id": "2af4cfb19e3243dda014d0f56b48f4b2" - } - }, - "metadata": {}, - "output_type": "display_data" + "cell_type": "code", + "metadata": { + "pycharm": { + "is_executing": false, + "name": "#%% code\n" + }, + "id": "B3BDRX_Krl_n", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 185, + "referenced_widgets": [ + "451464c936444ba5a652b46c1b4f9931", + "279291efd2c14a9eb2c3b98efbf152ad", + "b6e1a2e57f4948a39283f1370352612c", + "9d4941ebdfa64978b47232f6e5908d97", + "1006cc0fab1e4139bb7b135486261c92", + "691c0bae60364890ab74934261207d4d", + "405afa5bb8b840d8bc0850e02f593ce4", + "78c718e3d5fa4cb892217260bea6d540" + ] + }, + "outputId": "a6b90b11-a272-4ecb-960d-4c682551b399" + }, + "source": [ + "nlp_token_class = pipeline('ner')\n", + "nlp_token_class('Hugging Face is a French company based in New-York.')" + ], + "execution_count": 4, + "outputs": [ + { + "output_type": "display_data", + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "451464c936444ba5a652b46c1b4f9931", + "version_minor": 0, + "version_major": 2 + }, + "text/plain": [ + "HBox(children=(IntProgress(value=0, description='Downloading', max=230, style=ProgressStyle(description_width=…" + ] + }, + "metadata": { + "tags": [] + } + }, + { + "output_type": "stream", + "text": [ + "\n" + ], + "name": "stdout" + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "[{'entity': 'I-ORG', 'score': 0.9970937967300415, 'word': 'Hu'},\n", + " {'entity': 'I-ORG', 'score': 0.9345749020576477, 'word': '##gging'},\n", + " {'entity': 'I-ORG', 'score': 0.9787060022354126, 'word': 'Face'},\n", + " {'entity': 'I-MISC', 'score': 0.9981995820999146, 'word': 'French'},\n", + " {'entity': 'I-LOC', 'score': 0.9983047246932983, 'word': 'New'},\n", + " {'entity': 'I-LOC', 'score': 0.8913459181785583, 'word': '-'},\n", + " {'entity': 'I-LOC', 'score': 0.9979523420333862, 'word': 'York'}]" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 4 + } + ] }, { - "name": "stdout", - "text": [ - "\n" - ], - "output_type": "stream" + "cell_type": "markdown", + "metadata": { + "id": "qIvUFEVarl_s", + "colab_type": "text" + }, + "source": [ + "## 3. Question Answering" + ] }, { - "data": { - "text/plain": "(1, 12, 768)" - }, - "metadata": {}, - "output_type": "execute_result", - "execution_count": 12 - } - ], - "source": [ - "import numpy as np\n", - "nlp_features = pipeline('feature-extraction')\n", - "output = nlp_features('Hugging Face is a French company based in Paris')\n", - "np.array(output).shape # (Samples, Tokens, Vector Size)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "pycharm": { - "name": "#%% md\n" - } - }, - "source": [ - "Alright ! Now you have a nice picture of what is possible through transformers' pipelines, and there is more\n", - "to come in future releases. \n", - "\n", - "In the meantime, you can try the different pipelines with your own inputs" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "pycharm": { - "is_executing": false, - "name": "#%% code\n" - } - }, - "outputs": [ - { - "data": { - "text/plain": "Dropdown(description='Task:', index=1, options=('sentiment-analysis', 'ner', 'fill_mask'), value='ner')", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 0, - "model_id": "10bac065d46f4e4d9a8498dcc8104ecd" - } - }, - "metadata": {}, - "output_type": "display_data" + "cell_type": "code", + "metadata": { + "pycharm": { + "is_executing": false, + "name": "#%% code\n" + }, + "id": "ND_8LzQKrl_u", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 117, + "referenced_widgets": [ + "7d66a4534c164d2f9493fc0467abebbd", + "7a15588f85b14f2b93e32b4c0442fa1b", + "213567d815894ca08041f6d682ced3c9", + "ee6c95e700e64d0a9ebec2c1545dd083", + "3e556abf5c4a4ee69d52366fd59471b2", + "876b2eba73fa46a6a941d2e3a8a975ad", + "cd64e3f20b23483daa79712bde6622ea", + "67cbaa1f55d24e62ad6b022af36bca56" + ] + }, + "outputId": "c59ae695-c465-4de6-fa6e-181d8f1a3992" + }, + "source": [ + "nlp_qa = pipeline('question-answering')\n", + "nlp_qa(context='Hugging Face is a French company based in New-York.', question='Where is based Hugging Face ?')" + ], + "execution_count": 5, + "outputs": [ + { + "output_type": "display_data", + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "7d66a4534c164d2f9493fc0467abebbd", + "version_minor": 0, + "version_major": 2 + }, + "text/plain": [ + "HBox(children=(IntProgress(value=0, description='Downloading', max=230, style=ProgressStyle(description_width=…" + ] + }, + "metadata": { + "tags": [] + } + }, + { + "output_type": "stream", + "text": [ + "\n" + ], + "name": "stdout" + }, + { + "output_type": "stream", + "text": [ + "convert squad examples to features: 100%|██████████| 1/1 [00:00<00:00, 142.60it/s]\n", + "add example index and unique id: 100%|██████████| 1/1 [00:00<00:00, 4341.93it/s]\n" + ], + "name": "stderr" + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "{'answer': 'New-York.', 'end': 50, 'score': 0.9632969241603995, 'start': 42}" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 5 + } + ] }, { - "data": { - "text/plain": "Text(value='', description='Your input:', placeholder='Enter something')", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 0, - "model_id": "2c5f1411f7a94714bc00f01b0e3b27b2" - } - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "task = widgets.Dropdown(\n", - " options=['sentiment-analysis', 'ner', 'fill_mask'],\n", - " value='ner',\n", - " description='Task:',\n", - " disabled=False\n", - ")\n", - "\n", - "input = widgets.Text(\n", - " value='',\n", - " placeholder='Enter something',\n", - " description='Your input:',\n", - " disabled=False\n", - ")\n", - "\n", - "def forward(_):\n", - " if len(input.value) > 0: \n", - " if task.value == 'ner':\n", - " output = nlp_token_class(input.value)\n", - " elif task.value == 'sentiment-analysis':\n", - " output = nlp_sentence_classif(input.value)\n", - " else:\n", - " if input.value.find('') == -1:\n", - " output = nlp_fill(input.value + ' ')\n", - " else:\n", - " output = nlp_fill(input.value) \n", - " print(output)\n", - "\n", - "input.on_submit(forward)\n", - "display(task, input)" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "pycharm": { - "is_executing": false, - "name": "#%% Question Answering\n" - } - }, - "outputs": [ + "cell_type": "markdown", + "metadata": { + "id": "9W_CnP5Zrl_2", + "colab_type": "text" + }, + "source": [ + "## 4. Text Generation - Mask Filling" + ] + }, { - "data": { - "text/plain": "Textarea(value='Einstein is famous for the general theory of relativity', description='Context:', placeholder=…", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 0, - "model_id": "019fde2343634e94b6f32d04f6350ec1" - } - }, - "metadata": {}, - "output_type": "display_data" + "cell_type": "code", + "metadata": { + "pycharm": { + "is_executing": false, + "name": "#%% code\n" + }, + "id": "zpJQ2HXNrl_4", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 321, + "referenced_widgets": [ + "58669943d3064f309436157270544c08", + "3eff293c2b554d85aefaea863e29b678", + "d0b9925f3dde46008bf186cf5ef7722d", + "427e07ce24a442af84ddc71f9463fdff", + "1eb2fa080ec44f8c8d5f6f52900277ab", + "23377596349e40a89ea57c8558660073", + "a35703cc8ff44e93a8c0eb413caddc40", + "9df7014c99b343f3b178fa020ff56010" + ] + }, + "outputId": "3fb62e7a-25a6-4b06-ced8-51eb8aa6bf33" + }, + "source": [ + "nlp_fill = pipeline('fill-mask')\n", + "nlp_fill('Hugging Face is a French company based in ' + nlp_fill.tokenizer.mask_token)" + ], + "execution_count": 6, + "outputs": [ + { + "output_type": "display_data", + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "58669943d3064f309436157270544c08", + "version_minor": 0, + "version_major": 2 + }, + "text/plain": [ + "HBox(children=(IntProgress(value=0, description='Downloading', max=230, style=ProgressStyle(description_width=…" + ] + }, + "metadata": { + "tags": [] + } + }, + { + "output_type": "stream", + "text": [ + "\n" + ], + "name": "stdout" + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "[{'score': 0.23106741905212402,\n", + " 'sequence': ' Hugging Face is a French company based in Paris',\n", + " 'token': 2201},\n", + " {'score': 0.08198167383670807,\n", + " 'sequence': ' Hugging Face is a French company based in Lyon',\n", + " 'token': 12790},\n", + " {'score': 0.04769487306475639,\n", + " 'sequence': ' Hugging Face is a French company based in Geneva',\n", + " 'token': 11559},\n", + " {'score': 0.04762246832251549,\n", + " 'sequence': ' Hugging Face is a French company based in Brussels',\n", + " 'token': 6497},\n", + " {'score': 0.041305847465991974,\n", + " 'sequence': ' Hugging Face is a French company based in France',\n", + " 'token': 1470}]" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 6 + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Fbs9t1KvrzDy", + "colab_type": "text" + }, + "source": [ + "## 5. Summarization\n", + "\n", + "Summarization is currently supported by `Bart` and `T5`." + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "8BaOgzi1u1Yc", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 88 + }, + "outputId": "2168e437-cfba-4247-a38c-07f02f555c6e" + }, + "source": [ + "TEXT_TO_SUMMARIZE = \"\"\" \n", + "New York (CNN)When Liana Barrientos was 23 years old, she got married in Westchester County, New York. \n", + "A year later, she got married again in Westchester County, but to a different man and without divorcing her first husband. \n", + "Only 18 days after that marriage, she got hitched yet again. Then, Barrientos declared \"I do\" five more times, sometimes only within two weeks of each other. \n", + "In 2010, she married once more, this time in the Bronx. In an application for a marriage license, she stated it was her \"first and only\" marriage. \n", + "Barrientos, now 39, is facing two criminal counts of \"offering a false instrument for filing in the first degree,\" referring to her false statements on the \n", + "2010 marriage license application, according to court documents. \n", + "Prosecutors said the marriages were part of an immigration scam. \n", + "On Friday, she pleaded not guilty at State Supreme Court in the Bronx, according to her attorney, Christopher Wright, who declined to comment further. \n", + "After leaving court, Barrientos was arrested and charged with theft of service and criminal trespass for allegedly sneaking into the New York subway through an emergency exit, said Detective \n", + "Annette Markowski, a police spokeswoman. In total, Barrientos has been married 10 times, with nine of her marriages occurring between 1999 and 2002. \n", + "All occurred either in Westchester County, Long Island, New Jersey or the Bronx. She is believed to still be married to four men, and at one time, she was married to eight men at once, prosecutors say. \n", + "Prosecutors said the immigration scam involved some of her husbands, who filed for permanent residence status shortly after the marriages. \n", + "Any divorces happened only after such filings were approved. It was unclear whether any of the men will be prosecuted. \n", + "The case was referred to the Bronx District Attorney\\'s Office by Immigration and Customs Enforcement and the Department of Homeland Security\\'s \n", + "Investigation Division. Seven of the men are from so-called \"red-flagged\" countries, including Egypt, Turkey, Georgia, Pakistan and Mali. \n", + "Her eighth husband, Rashid Rajput, was deported in 2006 to his native Pakistan after an investigation by the Joint Terrorism Task Force. \n", + "If convicted, Barrientos faces up to four years in prison. Her next court appearance is scheduled for May 18.\n", + "\"\"\"\n", + "\n", + "summarizer = pipeline('summarization')\n", + "summarizer(TEXT_TO_SUMMARIZE)" + ], + "execution_count": 7, + "outputs": [ + { + "output_type": "stream", + "text": [ + "Couldn't reach server at 'https://s3.amazonaws.com/models.huggingface.co/bert/facebook/bart-large-cnn/modelcard.json' to download model card file.\n", + "Creating an empty model card.\n" + ], + "name": "stderr" + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "[{'summary_text': 'Liana Barrientos has been married 10 times, sometimes within two weeks of each other. Prosecutors say the marriages were part of an immigration scam. She is believed to still be married to four men, and at one time, she was married to eight men at once. Her eighth husband was deported in 2006 to his native Pakistan.'}]" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 7 + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "u5JA6IJsr-G0", + "colab_type": "text" + }, + "source": [ + "## 6. Translation\n", + "\n", + "Translation is currently supported by `T5` for the language mappings English-to-French (`translation_en_to_fr`), English-to-German (`translation_en_to_de`) and English-to-Romanian (`translation_en_to_ro`)." + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "8FwayP4nwV3Z", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 83, + "referenced_widgets": [ + "57e8c36594d043c581c766b434037771", + "82760185d5c14a808cbf6639b589f249", + "f2a1b430594b4736879cdff4ec532098", + "c81338551e60474fab9e9950fe5df294", + "98563b405bd043a9a301a43909e43157", + "8c0e1b7fb6ac4ee7bbbaf6020b40cc77", + "ad78042ee71a41fd989e4b4ce9d2e3c1", + "40c8d2617f3d4c84b923b140456fa5da" + ] + }, + "outputId": "66956816-c924-4718-fe58-cabef7d51974" + }, + "source": [ + "# English to French\n", + "translator = pipeline('translation_en_to_fr')\n", + "translator(\"HuggingFace is a French company that is based in New York City. HuggingFace's mission is to solve NLP one commit at a time\")" + ], + "execution_count": 8, + "outputs": [ + { + "output_type": "display_data", + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "57e8c36594d043c581c766b434037771", + "version_minor": 0, + "version_major": 2 + }, + "text/plain": [ + "HBox(children=(IntProgress(value=0, description='Downloading', max=230, style=ProgressStyle(description_width=…" + ] + }, + "metadata": { + "tags": [] + } + }, + { + "output_type": "stream", + "text": [ + "\n" + ], + "name": "stdout" + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "[{'translation_text': 'HuggingFace est une entreprise française basée à New York et dont la mission est de résoudre les problèmes de NLP, un engagement à la fois.'}]" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 8 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "colab_type": "code", + "id": "ra0-WfznwoIW", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 83, + "referenced_widgets": [ + "311a65b811964ebfa2c064eb348b3ce9", + "5a2032c44d0e4f8cbaf512e6c29214cd", + "54d1ff55e0094a4fa2b62ecdfb428328", + "2e45f2d7d65246ecb8d6e666d026ac13", + "e05c0ec3b49e4d4990a943d428532fb0", + "39721262fc1e4456966d92fabe0f54ea", + "4486f8a2efc34b9aab3864eb5ad2ba48", + "d6228324f3444aa6bd1323d65ae4ff75" + ] + }, + "outputId": "278a3d5f-cc42-40bc-a9db-c92ec5a3a2f0" + }, + "source": [ + "# English to German\n", + "translator = pipeline('translation_en_to_de')\n", + "translator(\"The history of natural language processing (NLP) generally started in the 1950s, although work can be found from earlier periods.\")" + ], + "execution_count": 9, + "outputs": [ + { + "output_type": "display_data", + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "311a65b811964ebfa2c064eb348b3ce9", + "version_minor": 0, + "version_major": 2 + }, + "text/plain": [ + "HBox(children=(IntProgress(value=0, description='Downloading', max=230, style=ProgressStyle(description_width=…" + ] + }, + "metadata": { + "tags": [] + } + }, + { + "output_type": "stream", + "text": [ + "\n" + ], + "name": "stdout" + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "[{'translation_text': 'Die Geschichte der natürlichen Sprachenverarbeitung (NLP) begann im Allgemeinen in den 1950er Jahren, obwohl die Arbeit aus früheren Zeiten zu finden ist.'}]" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 9 + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Utmldmetrl_9", + "colab_type": "text" + }, + "source": [ + "## 7. Projection - Features Extraction " + ] + }, + { + "cell_type": "code", + "metadata": { + "pycharm": { + "is_executing": false, + "name": "#%% code\n" + }, + "id": "O4SjR1QQrl__", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 83, + "referenced_widgets": [ + "fd44cf6ab17e4b768b2e1d5cb8ce5af9", + "b8c0ea31578d4eaaa69251d0004fd8c6", + "2015cd9c1da9467290ecd9019af231eb", + "17bacdaee55b43e8977c4dfe4f7245bb", + "879ef9e1a0e94f3d96ed56fb4bae64b8", + "7ab70324d42647acac5020b387955caf", + "31d97ecf78fa412c99e6659196d82828", + "c6be5d48ec3c4c799d1445607e5f1ac6" + ] + }, + "outputId": "2ce966d5-7a89-4488-d48f-626d1c2a8222" + }, + "source": [ + "import numpy as np\n", + "nlp_features = pipeline('feature-extraction')\n", + "output = nlp_features('Hugging Face is a French company based in Paris')\n", + "np.array(output).shape # (Samples, Tokens, Vector Size)\n" + ], + "execution_count": 10, + "outputs": [ + { + "output_type": "display_data", + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "fd44cf6ab17e4b768b2e1d5cb8ce5af9", + "version_minor": 0, + "version_major": 2 + }, + "text/plain": [ + "HBox(children=(IntProgress(value=0, description='Downloading', max=230, style=ProgressStyle(description_width=…" + ] + }, + "metadata": { + "tags": [] + } + }, + { + "output_type": "stream", + "text": [ + "\n" + ], + "name": "stdout" + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "(1, 12, 768)" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 10 + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "pycharm": { + "name": "#%% md\n" + }, + "id": "02j8km8YrmAE", + "colab_type": "text" + }, + "source": [ + "Alright ! Now you have a nice picture of what is possible through transformers' pipelines, and there is more\n", + "to come in future releases. \n", + "\n", + "In the meantime, you can try the different pipelines with your own inputs" + ] + }, + { + "cell_type": "code", + "metadata": { + "pycharm": { + "is_executing": false, + "name": "#%% code\n" + }, + "id": "yFlBPQHtrmAH", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 116, + "referenced_widgets": [ + "0bd407b4975f49c3827aede14c59501c", + "3f5406df699e44f5b60678c1c13500f5", + "17768469581445b68246ed308ce69326", + "74cbcbae5cac4f12abf080a38390f05c", + "62b10ca525cc4ac68f3a006434eb7416", + "211109537fbe4e60b89a238c89db1346" + ] + }, + "outputId": "03cc3207-a7e8-49fd-904a-63a7a1d0eb7a" + }, + "source": [ + "task = widgets.Dropdown(\n", + " options=['sentiment-analysis', 'ner', 'fill_mask'],\n", + " value='ner',\n", + " description='Task:',\n", + " disabled=False\n", + ")\n", + "\n", + "input = widgets.Text(\n", + " value='',\n", + " placeholder='Enter something',\n", + " description='Your input:',\n", + " disabled=False\n", + ")\n", + "\n", + "def forward(_):\n", + " if len(input.value) > 0: \n", + " if task.value == 'ner':\n", + " output = nlp_token_class(input.value)\n", + " elif task.value == 'sentiment-analysis':\n", + " output = nlp_sentence_classif(input.value)\n", + " else:\n", + " if input.value.find('') == -1:\n", + " output = nlp_fill(input.value + ' ')\n", + " else:\n", + " output = nlp_fill(input.value) \n", + " print(output)\n", + "\n", + "input.on_submit(forward)\n", + "display(task, input)" + ], + "execution_count": 11, + "outputs": [ + { + "output_type": "display_data", + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "0bd407b4975f49c3827aede14c59501c", + "version_minor": 0, + "version_major": 2 + }, + "text/plain": [ + "Dropdown(description='Task:', index=1, options=('sentiment-analysis', 'ner', 'fill_mask'), value='ner')" + ] + }, + "metadata": { + "tags": [] + } + }, + { + "output_type": "display_data", + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "74cbcbae5cac4f12abf080a38390f05c", + "version_minor": 0, + "version_major": 2 + }, + "text/plain": [ + "Text(value='', description='Your input:', placeholder='Enter something')" + ] + }, + "metadata": { + "tags": [] + } + }, + { + "output_type": "stream", + "text": [ + "[{'word': 'Peter', 'score': 0.9935821294784546, 'entity': 'I-PER'}, {'word': 'Pan', 'score': 0.9901397228240967, 'entity': 'I-PER'}, {'word': 'Marseille', 'score': 0.9984904527664185, 'entity': 'I-LOC'}, {'word': 'France', 'score': 0.9998687505722046, 'entity': 'I-LOC'}]\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "code", + "metadata": { + "pycharm": { + "is_executing": false, + "name": "#%% Question Answering\n" + }, + "id": "GCoKbBTYrmAN", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 143, + "referenced_widgets": [ + "d79946ac16ea4855a0bbe2ca2a4d4bf5", + "ab5774ac19f84ab18ddf09a63433df00", + "a02164204f0f43668bc36a907e720af7", + "3b12aec414b14221ad2a11dfd975faa0", + "d305ba1662e3466c93ab5cca7ebf8f33", + "879f7a3747ad455d810c7a29918648ee" + ] + }, + "outputId": "57c3a647-160a-4b3a-e852-e7a1daf1294a" + }, + "source": [ + "context = widgets.Textarea(\n", + " value='Einstein is famous for the general theory of relativity',\n", + " placeholder='Enter something',\n", + " description='Context:',\n", + " disabled=False\n", + ")\n", + "\n", + "query = widgets.Text(\n", + " value='Why is Einstein famous for ?',\n", + " placeholder='Enter something',\n", + " description='Question:',\n", + " disabled=False\n", + ")\n", + "\n", + "def forward(_):\n", + " if len(context.value) > 0 and len(query.value) > 0: \n", + " output = nlp_qa(question=query.value, context=context.value) \n", + " print(output)\n", + "\n", + "query.on_submit(forward)\n", + "display(context, query)" + ], + "execution_count": 12, + "outputs": [ + { + "output_type": "display_data", + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d79946ac16ea4855a0bbe2ca2a4d4bf5", + "version_minor": 0, + "version_major": 2 + }, + "text/plain": [ + "Textarea(value='Einstein is famous for the general theory of relativity', description='Context:', placeholder=…" + ] + }, + "metadata": { + "tags": [] + } + }, + { + "output_type": "display_data", + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "3b12aec414b14221ad2a11dfd975faa0", + "version_minor": 0, + "version_major": 2 + }, + "text/plain": [ + "Text(value='Why is Einstein famous for ?', description='Question:', placeholder='Enter something')" + ] + }, + "metadata": { + "tags": [] + } + }, + { + "output_type": "stream", + "text": [ + "convert squad examples to features: 100%|██████████| 1/1 [00:00<00:00, 363.99it/s]\n", + "add example index and unique id: 100%|██████████| 1/1 [00:00<00:00, 5178.15it/s]\n" + ], + "name": "stderr" + }, + { + "output_type": "stream", + "text": [ + "{'score': 0.40340594113729367, 'start': 27, 'end': 54, 'answer': 'general theory of relativity'}\n" + ], + "name": "stdout" + } + ] } - ], - "source": [ - "context = widgets.Textarea(\n", - " value='Einstein is famous for the general theory of relativity',\n", - " placeholder='Enter something',\n", - " description='Context:',\n", - " disabled=False\n", - ")\n", - "\n", - "query = widgets.Text(\n", - " value='Why is Einstein famous for ?',\n", - " placeholder='Enter something',\n", - " description='Question:',\n", - " disabled=False\n", - ")\n", - "\n", - "def forward(_):\n", - " if len(context.value) > 0 and len(query.value) > 0: \n", - " output = nlp_qa(question=query.value, context=context.value) \n", - " print(output)\n", - "\n", - "query.on_submit(forward)\n", - "display(context, query)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.6" - }, - "pycharm": { - "stem_cell": { - "cell_type": "raw", - "source": [], - "metadata": { - "collapsed": false - } - } - } - }, - "nbformat": 4, - "nbformat_minor": 1 + ] } \ No newline at end of file