Unverified Commit 00ea100e authored by Patrick von Platen's avatar Patrick von Platen Committed by GitHub
Browse files

add summarization and translation to notebook (#3478)

parent b08259a1
{ {
"cells": [ "nbformat": 4,
{ "nbformat_minor": 0,
"cell_type": "markdown", "metadata": {
"metadata": { "kernelspec": {
"pycharm": { "display_name": "Python 3",
"name": "#%% md\n" "language": "python",
} "name": "python3"
}, },
"source": [ "language_info": {
"## How can I leverage State-of-the-Art Natural Language Models with only one line of code ?" "codemirror_mode": {
] "name": "ipython",
}, "version": 3
{ },
"cell_type": "markdown", "file_extension": ".py",
"metadata": { "mimetype": "text/x-python",
"pycharm": { "name": "python",
"name": "#%% md\n" "nbconvert_exporter": "python",
} "pygments_lexer": "ipython3",
}, "version": "3.7.6"
"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(\"<task-name>\")\n",
"\n",
"# Using a user-specified model\n",
"pipeline(\"<task-name>\", model=\"<model_name>\")\n",
"\n",
"# Using custom model/tokenizer as str\n",
"pipeline('<task-name>', model='<model name>', tokenizer='<tokenizer_name>')\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": { "pycharm": {
"name": "#%% md\n" "stem_cell": {
"cell_type": "raw",
"source": [],
"metadata": {
"collapsed": false
}
}
},
"colab": {
"name": "03-pipelines.ipynb",
"provenance": []
},
"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&lt;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&lt;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&lt;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&lt;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&lt;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&lt;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&lt;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
}
}
}
} }
},
"source": [
"## 1. Sentence Classification - Sentiment Analysis"
]
}, },
{ "cells": [
"cell_type": "code",
"execution_count": 8,
"metadata": {
"pycharm": {
"is_executing": false,
"name": "#%% code\n"
}
},
"outputs": [
{ {
"data": { "cell_type": "markdown",
"text/plain": "HBox(children=(FloatProgress(value=0.0, description='Downloading', max=230.0, style=ProgressStyle(description_…", "metadata": {
"application/vnd.jupyter.widget-view+json": { "pycharm": {
"version_major": 2, "name": "#%% md\n"
"version_minor": 0, },
"model_id": "c9db53f30b9446c0af03268633a966c0" "id": "qUU7wy-brl_H",
} "colab_type": "text"
}, },
"metadata": {}, "source": [
"output_type": "display_data" "## How can I leverage State-of-the-Art Natural Language Models with only one line of code ?"
]
}, },
{ {
"name": "stdout", "cell_type": "markdown",
"text": [ "metadata": {
"\n" "pycharm": {
], "name": "#%% md\n"
"output_type": "stream" },
"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(\"<task-name>\")\n",
"\n",
"# Using a user-specified model\n",
"pipeline(\"<task-name>\", model=\"<model_name>\")\n",
"\n",
"# Using custom model/tokenizer as str\n",
"pipeline('<task-name>', model='<model name>', tokenizer='<tokenizer_name>')\n",
"```"
]
}, },
{ {
"data": { "cell_type": "code",
"text/plain": "[{'label': 'POSITIVE', 'score': 0.9997656}]" "metadata": {
}, "pycharm": {
"metadata": {}, "name": "#%% code\n"
"output_type": "execute_result", },
"execution_count": 8 "id": "4maAknWNrl_N",
} "colab_type": "code",
], "colab": {}
"source": [ },
"nlp_sentence_classif = pipeline('sentiment-analysis')\n", "source": [
"nlp_sentence_classif('Such a nice weather outside !')" "!pip install -q transformers"
] ],
}, "execution_count": 0,
{ "outputs": []
"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": { "cell_type": "code",
"text/plain": "HBox(children=(FloatProgress(value=0.0, description='Downloading', max=230.0, style=ProgressStyle(description_…", "metadata": {
"application/vnd.jupyter.widget-view+json": { "pycharm": {
"version_major": 2, "is_executing": false,
"version_minor": 0, "name": "#%% code \n"
"model_id": "1e300789e22644f1aed66a5ed60e75c4" },
} "id": "uKaqzCh6rl_V",
}, "colab_type": "code",
"metadata": {}, "colab": {}
"output_type": "display_data" },
"source": [
"from __future__ import print_function\n",
"import ipywidgets as widgets\n",
"from transformers import pipeline"
],
"execution_count": 0,
"outputs": []
}, },
{ {
"name": "stdout", "cell_type": "markdown",
"text": [ "metadata": {
"\n" "pycharm": {
], "name": "#%% md\n"
"output_type": "stream" },
"id": "uDPZ42Uerl_b",
"colab_type": "text"
},
"source": [
"## 1. Sentence Classification - Sentiment Analysis"
]
}, },
{ {
"data": { "cell_type": "code",
"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": {
}, "pycharm": {
"metadata": {}, "is_executing": false,
"output_type": "execute_result", "name": "#%% code\n"
"execution_count": 9 },
} "id": "AMRXHQw9rl_d",
], "colab_type": "code",
"source": [ "colab": {
"nlp_token_class = pipeline('ner')\n", "base_uri": "https://localhost:8080/",
"nlp_token_class('Hugging Face is a French company based in New-York.')" "height": 83,
] "referenced_widgets": [
}, "4bab5df43b3c46caadf48e264344ab42",
{ "9b426c68631f4bb288e2ca79aad9f9d9",
"cell_type": "markdown", "6902104f7ec143519fb1a6ab9363d4a0",
"metadata": {}, "c133fb34fe2a4aba8a6b233671af8b04",
"source": [ "e3f72d443a74414ca62c2b848d34b125",
"## 3. Question Answering" "5462b581976e47048642aa6bc12435bd",
] "ad84da685cf44abb90d17d9d2e023b48",
}, "a246f9eea2d7440cb979e728741d2e32"
{ ]
"cell_type": "code", },
"execution_count": 10, "outputId": "a7a10851-b71e-4553-9afc-04066120410d"
"metadata": { },
"pycharm": { "source": [
"is_executing": false, "nlp_sentence_classif = pipeline('sentiment-analysis')\n",
"name": "#%% code\n" "nlp_sentence_classif('Such a nice weather outside !')"
} ],
}, "execution_count": 3,
"outputs": [ "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
}
]
},
{ {
"data": { "cell_type": "markdown",
"text/plain": "HBox(children=(FloatProgress(value=0.0, description='Downloading', max=230.0, style=ProgressStyle(description_…", "metadata": {
"application/vnd.jupyter.widget-view+json": { "pycharm": {
"version_major": 2, "name": "#%% md\n"
"version_minor": 0, },
"model_id": "82aca58f1ea24b4cb37f16402e8a5923" "id": "RY8aUJTvrl_k",
} "colab_type": "text"
}, },
"metadata": {}, "source": [
"output_type": "display_data" "## 2. Token Classification - Named Entity Recognition"
]
}, },
{ {
"name": "stdout", "cell_type": "code",
"text": [ "metadata": {
"\n" "pycharm": {
], "is_executing": false,
"output_type": "stream" "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": "stderr", "cell_type": "markdown",
"text": [ "metadata": {
"convert squad examples to features: 100%|██████████| 1/1 [00:00<00:00, 225.51it/s]\n", "id": "qIvUFEVarl_s",
"add example index and unique id: 100%|██████████| 1/1 [00:00<00:00, 2158.67it/s]\n" "colab_type": "text"
], },
"output_type": "stream" "source": [
"## 3. Question Answering"
]
}, },
{ {
"data": { "cell_type": "code",
"text/plain": "{'score': 0.9632966867654424, 'start': 42, 'end': 50, 'answer': 'New-York.'}" "metadata": {
}, "pycharm": {
"metadata": {}, "is_executing": false,
"output_type": "execute_result", "name": "#%% code\n"
"execution_count": 10 },
} "id": "ND_8LzQKrl_u",
], "colab_type": "code",
"source": [ "colab": {
"nlp_qa = pipeline('question-answering')\n", "base_uri": "https://localhost:8080/",
"nlp_qa(context='Hugging Face is a French company based in New-York.', question='Where is based Hugging Face ?')" "height": 117,
] "referenced_widgets": [
}, "7d66a4534c164d2f9493fc0467abebbd",
{ "7a15588f85b14f2b93e32b4c0442fa1b",
"cell_type": "markdown", "213567d815894ca08041f6d682ced3c9",
"metadata": {}, "ee6c95e700e64d0a9ebec2c1545dd083",
"source": [ "3e556abf5c4a4ee69d52366fd59471b2",
"## 4. Text Generation - Mask Filling" "876b2eba73fa46a6a941d2e3a8a975ad",
] "cd64e3f20b23483daa79712bde6622ea",
}, "67cbaa1f55d24e62ad6b022af36bca56"
{ ]
"cell_type": "code", },
"execution_count": 11, "outputId": "c59ae695-c465-4de6-fa6e-181d8f1a3992"
"metadata": { },
"pycharm": { "source": [
"is_executing": false, "nlp_qa = pipeline('question-answering')\n",
"name": "#%% code\n" "nlp_qa(context='Hugging Face is a French company based in New-York.', question='Where is based Hugging Face ?')"
} ],
}, "execution_count": 5,
"outputs": [ "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": { "cell_type": "markdown",
"text/plain": "HBox(children=(FloatProgress(value=0.0, description='Downloading', max=230.0, style=ProgressStyle(description_…", "metadata": {
"application/vnd.jupyter.widget-view+json": { "id": "9W_CnP5Zrl_2",
"version_major": 2, "colab_type": "text"
"version_minor": 0, },
"model_id": "49df2227b4fa4eb28dcdcfc3d9261d0f" "source": [
} "## 4. Text Generation - Mask Filling"
}, ]
"metadata": {},
"output_type": "display_data"
}, },
{ {
"name": "stdout", "cell_type": "code",
"text": [ "metadata": {
"\n" "pycharm": {
], "is_executing": false,
"output_type": "stream" "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': '<s> Hugging Face is a French company based in Paris</s>',\n",
" 'token': 2201},\n",
" {'score': 0.08198167383670807,\n",
" 'sequence': '<s> Hugging Face is a French company based in Lyon</s>',\n",
" 'token': 12790},\n",
" {'score': 0.04769487306475639,\n",
" 'sequence': '<s> Hugging Face is a French company based in Geneva</s>',\n",
" 'token': 11559},\n",
" {'score': 0.04762246832251549,\n",
" 'sequence': '<s> Hugging Face is a French company based in Brussels</s>',\n",
" 'token': 6497},\n",
" {'score': 0.041305847465991974,\n",
" 'sequence': '<s> Hugging Face is a French company based in France</s>',\n",
" 'token': 1470}]"
]
},
"metadata": {
"tags": []
},
"execution_count": 6
}
]
}, },
{ {
"data": { "cell_type": "markdown",
"text/plain": "[{'sequence': '<s> Hugging Face is a French company based in Paris</s>',\n 'score': 0.23106691241264343,\n 'token': 2201},\n {'sequence': '<s> Hugging Face is a French company based in Lyon</s>',\n 'score': 0.0819825753569603,\n 'token': 12790},\n {'sequence': '<s> Hugging Face is a French company based in Geneva</s>',\n 'score': 0.04769463092088699,\n 'token': 11559},\n {'sequence': '<s> Hugging Face is a French company based in Brussels</s>',\n 'score': 0.047622501850128174,\n 'token': 6497},\n {'sequence': '<s> Hugging Face is a French company based in France</s>',\n 'score': 0.04130595177412033,\n 'token': 1470}]" "metadata": {
}, "id": "Fbs9t1KvrzDy",
"metadata": {}, "colab_type": "text"
"output_type": "execute_result", },
"execution_count": 11 "source": [
} "## 5. Summarization\n",
], "\n",
"source": [ "Summarization is currently supported by `Bart` and `T5`."
"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": { "cell_type": "code",
"text/plain": "HBox(children=(FloatProgress(value=0.0, description='Downloading', max=230.0, style=ProgressStyle(description_…", "metadata": {
"application/vnd.jupyter.widget-view+json": { "id": "8BaOgzi1u1Yc",
"version_major": 2, "colab_type": "code",
"version_minor": 0, "colab": {
"model_id": "2af4cfb19e3243dda014d0f56b48f4b2" "base_uri": "https://localhost:8080/",
} "height": 88
}, },
"metadata": {}, "outputId": "2168e437-cfba-4247-a38c-07f02f555c6e"
"output_type": "display_data" },
"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
}
]
}, },
{ {
"name": "stdout", "cell_type": "markdown",
"text": [ "metadata": {
"\n" "id": "u5JA6IJsr-G0",
], "colab_type": "text"
"output_type": "stream" },
"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`)."
]
}, },
{ {
"data": { "cell_type": "code",
"text/plain": "(1, 12, 768)" "metadata": {
}, "id": "8FwayP4nwV3Z",
"metadata": {}, "colab_type": "code",
"output_type": "execute_result", "colab": {
"execution_count": 12 "base_uri": "https://localhost:8080/",
} "height": 83,
], "referenced_widgets": [
"source": [ "57e8c36594d043c581c766b434037771",
"import numpy as np\n", "82760185d5c14a808cbf6639b589f249",
"nlp_features = pipeline('feature-extraction')\n", "f2a1b430594b4736879cdff4ec532098",
"output = nlp_features('Hugging Face is a French company based in Paris')\n", "c81338551e60474fab9e9950fe5df294",
"np.array(output).shape # (Samples, Tokens, Vector Size)\n" "98563b405bd043a9a301a43909e43157",
] "8c0e1b7fb6ac4ee7bbbaf6020b40cc77",
}, "ad78042ee71a41fd989e4b4ce9d2e3c1",
{ "40c8d2617f3d4c84b923b140456fa5da"
"cell_type": "markdown", ]
"metadata": { },
"pycharm": { "outputId": "66956816-c924-4718-fe58-cabef7d51974"
"name": "#%% md\n" },
} "source": [
}, "# English to French\n",
"source": [ "translator = pipeline('translation_en_to_fr')\n",
"Alright ! Now you have a nice picture of what is possible through transformers' pipelines, and there is more\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\")"
"to come in future releases. \n", ],
"\n", "execution_count": 8,
"In the meantime, you can try the different pipelines with your own inputs" "outputs": [
] {
}, "output_type": "display_data",
{ "data": {
"cell_type": "code", "application/vnd.jupyter.widget-view+json": {
"execution_count": 13, "model_id": "57e8c36594d043c581c766b434037771",
"metadata": { "version_minor": 0,
"pycharm": { "version_major": 2
"is_executing": false, },
"name": "#%% code\n" "text/plain": [
} "HBox(children=(IntProgress(value=0, description='Downloading', max=230, style=ProgressStyle(description_width=…"
}, ]
"outputs": [ },
"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
}
]
},
{ {
"data": { "cell_type": "code",
"text/plain": "Dropdown(description='Task:', index=1, options=('sentiment-analysis', 'ner', 'fill_mask'), value='ner')", "metadata": {
"application/vnd.jupyter.widget-view+json": { "colab_type": "code",
"version_major": 2, "id": "ra0-WfznwoIW",
"version_minor": 0, "colab": {
"model_id": "10bac065d46f4e4d9a8498dcc8104ecd" "base_uri": "https://localhost:8080/",
} "height": 83,
}, "referenced_widgets": [
"metadata": {}, "311a65b811964ebfa2c064eb348b3ce9",
"output_type": "display_data" "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
}
]
}, },
{ {
"data": { "cell_type": "markdown",
"text/plain": "Text(value='', description='Your input:', placeholder='Enter something')", "metadata": {
"application/vnd.jupyter.widget-view+json": { "id": "Utmldmetrl_9",
"version_major": 2, "colab_type": "text"
"version_minor": 0, },
"model_id": "2c5f1411f7a94714bc00f01b0e3b27b2" "source": [
} "## 7. Projection - Features Extraction "
}, ]
"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('<mask>') == -1:\n",
" output = nlp_fill(input.value + ' <mask>')\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": [
{ {
"data": { "cell_type": "code",
"text/plain": "Textarea(value='Einstein is famous for the general theory of relativity', description='Context:', placeholder=…", "metadata": {
"application/vnd.jupyter.widget-view+json": { "pycharm": {
"version_major": 2, "is_executing": false,
"version_minor": 0, "name": "#%% code\n"
"model_id": "019fde2343634e94b6f32d04f6350ec1" },
} "id": "O4SjR1QQrl__",
}, "colab_type": "code",
"metadata": {}, "colab": {
"output_type": "display_data" "base_uri": "https://localhost:8080/",
} "height": 83,
], "referenced_widgets": [
"source": [ "fd44cf6ab17e4b768b2e1d5cb8ce5af9",
"context = widgets.Textarea(\n", "b8c0ea31578d4eaaa69251d0004fd8c6",
" value='Einstein is famous for the general theory of relativity',\n", "2015cd9c1da9467290ecd9019af231eb",
" placeholder='Enter something',\n", "17bacdaee55b43e8977c4dfe4f7245bb",
" description='Context:',\n", "879ef9e1a0e94f3d96ed56fb4bae64b8",
" disabled=False\n", "7ab70324d42647acac5020b387955caf",
")\n", "31d97ecf78fa412c99e6659196d82828",
"\n", "c6be5d48ec3c4c799d1445607e5f1ac6"
"query = widgets.Text(\n", ]
" value='Why is Einstein famous for ?',\n", },
" placeholder='Enter something',\n", "outputId": "2ce966d5-7a89-4488-d48f-626d1c2a8222"
" description='Question:',\n", },
" disabled=False\n", "source": [
")\n", "import numpy as np\n",
"\n", "nlp_features = pipeline('feature-extraction')\n",
"def forward(_):\n", "output = nlp_features('Hugging Face is a French company based in Paris')\n",
" if len(context.value) > 0 and len(query.value) > 0: \n", "np.array(output).shape # (Samples, Tokens, Vector Size)\n"
" output = nlp_qa(question=query.value, context=context.value) \n", ],
" print(output)\n", "execution_count": 10,
"\n", "outputs": [
"query.on_submit(forward)\n", {
"display(context, query)" "output_type": "display_data",
] "data": {
} "application/vnd.jupyter.widget-view+json": {
], "model_id": "fd44cf6ab17e4b768b2e1d5cb8ce5af9",
"metadata": { "version_minor": 0,
"kernelspec": { "version_major": 2
"display_name": "Python 3", },
"language": "python", "text/plain": [
"name": "python3" "HBox(children=(IntProgress(value=0, description='Downloading', max=230, style=ProgressStyle(description_width=…"
}, ]
"language_info": { },
"codemirror_mode": { "metadata": {
"name": "ipython", "tags": []
"version": 3 }
}, },
"file_extension": ".py", {
"mimetype": "text/x-python", "output_type": "stream",
"name": "python", "text": [
"nbconvert_exporter": "python", "\n"
"pygments_lexer": "ipython3", ],
"version": "3.7.6" "name": "stdout"
}, },
"pycharm": { {
"stem_cell": { "output_type": "execute_result",
"cell_type": "raw", "data": {
"source": [], "text/plain": [
"metadata": { "(1, 12, 768)"
"collapsed": false ]
},
"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('<mask>') == -1:\n",
" output = nlp_fill(input.value + ' <mask>')\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"
}
]
} }
} ]
}
},
"nbformat": 4,
"nbformat_minor": 1
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment