|
22 | 22 | "cell_type": "markdown",
|
23 | 23 | "metadata": {},
|
24 | 24 | "source": [
|
25 |
| - "#### Overview:\n", |
| 25 | + "## Overview\n", |
26 | 26 | "In [step 1](#Step-1:-Determine-input-prompt-and-visualize-word-dependencies) of this notebook, you will determine an input prompt that will be used to condition the GPT-2 model for text generation. You will also [visualize attention](#Step-1.1-Introduction-to-attention) mechanism of GPT-2 model. In [step 2](#Step-2:-Use-an-ML-model-to-generate-text-based-on-prompt), you will create the model from an AWS Marketplace subscription, and deploy to an Amazon SageMaker endpoint. In [step 3](#Step-3:-Explore-use-cases-and-model-parameters), you will explore text generation use cases with various model parameter settings. In [step 4](#Step-4:-Use-Amazon-SageMaker-batch-transform), you will perform inference asynchronously using SageMaker batch transform instead of the endpoint. In [Step 5](#Step-5:-Next-steps) you will find additional models to explore and experiment with."
|
27 | 27 | ]
|
28 | 28 | },
|
29 | 29 | {
|
30 | 30 | "cell_type": "markdown",
|
31 | 31 | "metadata": {},
|
32 | 32 | "source": [
|
33 |
| - "#### Contents:\n", |
| 33 | + "## Contents\n", |
34 | 34 | "* [Pre-requisites](#Pre-requisites)\n",
|
35 | 35 | "* [Step 1: Determine input prompt and visualize word dependencies](#Step-1:-Determine-input-prompt-and-visualize-word-dependencies)\n",
|
36 | 36 | " * [Step 1.1 Introduction to attention](#Step-1.1-Introduction-to-attention)\n",
|
|
54 | 54 | " * [Step 5.1: Additional resources](#Step-5.1:-Additional-resources)\n",
|
55 | 55 | " * [Step 5.2: Cancel AWS Marketplace subscription](#Step-5.2:-Cancel-AWS-Marketplace-subscription)\n",
|
56 | 56 | "\n",
|
57 |
| - "#### Usage instructions\n", |
| 57 | + "## Usage instructions\n", |
58 | 58 | "You can run this notebook one cell at a time (By using Shift+Enter for running a cell)."
|
59 | 59 | ]
|
60 | 60 | },
|
|
170 | 170 | "cell_type": "markdown",
|
171 | 171 | "metadata": {},
|
172 | 172 | "source": [
|
173 |
| - "### Step 1: Determine input prompt and visualize word dependencies" |
| 173 | + "## Step 1: Determine input prompt and visualize word dependencies" |
174 | 174 | ]
|
175 | 175 | },
|
176 | 176 | {
|
|
186 | 186 | "cell_type": "markdown",
|
187 | 187 | "metadata": {},
|
188 | 188 | "source": [
|
189 |
| - "#### Step 1.1 Introduction to attention\n", |
| 189 | + "### Step 1.1 Introduction to attention\n", |
190 | 190 | "\n",
|
191 | 191 | "[Self-Attention mechanism](https://arxiv.org/abs/1706.03762) is one of the key components for Transformers architectures, including GPT-2. It helps to relate different positions of a specific sequence of tokens in order to compute contextual representation of the sequence.\n",
|
192 | 192 | "\n",
|
|
219 | 219 | "cell_type": "markdown",
|
220 | 220 | "metadata": {},
|
221 | 221 | "source": [
|
222 |
| - "#### Step 1.2 Specify input prompt \n", |
| 222 | + "### Step 1.2 Specify input prompt \n", |
223 | 223 | "\n",
|
224 | 224 | "You can experiment with different prompts and see what contextual dependencies exist in your own examples. "
|
225 | 225 | ]
|
|
237 | 237 | "cell_type": "markdown",
|
238 | 238 | "metadata": {},
|
239 | 239 | "source": [
|
240 |
| - "#### Step 1.3 Visualize attention mechanism\n", |
| 240 | + "### Step 1.3 Visualize attention mechanism\n", |
241 | 241 | "\n",
|
242 | 242 | "In this step, let's call BertViz package to produce attention visualization of our input."
|
243 | 243 | ]
|
|
303 | 303 | "cell_type": "markdown",
|
304 | 304 | "metadata": {},
|
305 | 305 | "source": [
|
306 |
| - "### Step 2: Use an ML model to generate text based on prompt\n", |
| 306 | + "## Step 2: Use an ML model to generate text based on prompt\n", |
307 | 307 | "\n",
|
308 | 308 | "Because you utilize [GPT-2 XL - Text generation](https://aws.amazon.com/marketplace/pp/prodview-cdujckyfypprg) algorithm from AWS Marketplace - all you need to do to start using it - is to deploy it as an inference endpoint in your account. Alternatively, we can use SageMaker Batch Transformation to run inference on batch payloads. \n",
|
309 | 309 | "\n",
|
|
355 | 355 | "cell_type": "markdown",
|
356 | 356 | "metadata": {},
|
357 | 357 | "source": [
|
358 |
| - "#### Step 2.1: Specify model arn from AWS Marketplace subscription" |
| 358 | + "### Step 2.1: Specify model arn from AWS Marketplace subscription" |
359 | 359 | ]
|
360 | 360 | },
|
361 | 361 | {
|
|
380 | 380 | "cell_type": "markdown",
|
381 | 381 | "metadata": {},
|
382 | 382 | "source": [
|
383 |
| - "#### Step 2.2: Create model from model package and deploy to endpoint" |
| 383 | + "### Step 2.2: Create model from model package and deploy to endpoint" |
384 | 384 | ]
|
385 | 385 | },
|
386 | 386 | {
|
|
406 | 406 | "cell_type": "markdown",
|
407 | 407 | "metadata": {},
|
408 | 408 | "source": [
|
409 |
| - "### Step 3: Explore use cases and model parameters" |
| 409 | + "## Step 3: Explore use cases and model parameters" |
410 | 410 | ]
|
411 | 411 | },
|
412 | 412 | {
|
|
445 | 445 | "cell_type": "markdown",
|
446 | 446 | "metadata": {},
|
447 | 447 | "source": [
|
448 |
| - "#### Step 3.1: Use case 1: Assisted writing of prose" |
| 448 | + "### Step 3.1: Use case 1: Assisted writing of prose" |
449 | 449 | ]
|
450 | 450 | },
|
451 | 451 | {
|
|
511 | 511 | "cell_type": "markdown",
|
512 | 512 | "metadata": {},
|
513 | 513 | "source": [
|
514 |
| - "#### Step 3.2: Use case 2: Autonomous authoring of poem" |
| 514 | + "### Step 3.2: Use case 2: Autonomous authoring of poem" |
515 | 515 | ]
|
516 | 516 | },
|
517 | 517 | {
|
|
619 | 619 | "cell_type": "markdown",
|
620 | 620 | "metadata": {},
|
621 | 621 | "source": [
|
622 |
| - "#### Step 3.3: Additional Use-Cases" |
| 622 | + "### Step 3.3: Additional Use-Cases" |
623 | 623 | ]
|
624 | 624 | },
|
625 | 625 | {
|
|
812 | 812 | "cell_type": "markdown",
|
813 | 813 | "metadata": {},
|
814 | 814 | "source": [
|
815 |
| - "#### Step 3.4: Delete Amazon SageMaker endpoint" |
| 815 | + "### Step 3.4: Delete Amazon SageMaker endpoint" |
816 | 816 | ]
|
817 | 817 | },
|
818 | 818 | {
|
|
836 | 836 | "cell_type": "markdown",
|
837 | 837 | "metadata": {},
|
838 | 838 | "source": [
|
839 |
| - "### Step 4: Use Amazon SageMaker batch transform" |
| 839 | + "## Step 4: Use Amazon SageMaker batch transform" |
840 | 840 | ]
|
841 | 841 | },
|
842 | 842 | {
|
|
854 | 854 | "cell_type": "markdown",
|
855 | 855 | "metadata": {},
|
856 | 856 | "source": [
|
857 |
| - "#### Step 4.1: Create input file for batch transform job" |
| 857 | + "### Step 4.1: Create input file for batch transform job" |
858 | 858 | ]
|
859 | 859 | },
|
860 | 860 | {
|
|
886 | 886 | "cell_type": "markdown",
|
887 | 887 | "metadata": {},
|
888 | 888 | "source": [
|
889 |
| - "#### Step 4.2: Upload file to S3" |
| 889 | + "### Step 4.2: Upload file to S3" |
890 | 890 | ]
|
891 | 891 | },
|
892 | 892 | {
|
|
904 | 904 | "cell_type": "markdown",
|
905 | 905 | "metadata": {},
|
906 | 906 | "source": [
|
907 |
| - "#### Step 4.3: Execute the batch transform job" |
| 907 | + "### Step 4.3: Execute the batch transform job" |
908 | 908 | ]
|
909 | 909 | },
|
910 | 910 | {
|
|
948 | 948 | "cell_type": "markdown",
|
949 | 949 | "metadata": {},
|
950 | 950 | "source": [
|
951 |
| - "#### Step 4.4: Visualize output" |
| 951 | + "### Step 4.4: Visualize output" |
952 | 952 | ]
|
953 | 953 | },
|
954 | 954 | {
|
|
983 | 983 | "cell_type": "markdown",
|
984 | 984 | "metadata": {},
|
985 | 985 | "source": [
|
986 |
| - "#### Step 4.5: Delete the model" |
| 986 | + "### Step 4.5: Delete the model" |
987 | 987 | ]
|
988 | 988 | },
|
989 | 989 | {
|
|
999 | 999 | "cell_type": "markdown",
|
1000 | 1000 | "metadata": {},
|
1001 | 1001 | "source": [
|
1002 |
| - "### Step 5: Next steps" |
| 1002 | + "## Step 5: Next steps" |
1003 | 1003 | ]
|
1004 | 1004 | },
|
1005 | 1005 | {
|
1006 | 1006 | "cell_type": "markdown",
|
1007 | 1007 | "metadata": {},
|
1008 | 1008 | "source": [
|
1009 |
| - "#### Step 5.1: Additional resources" |
| 1009 | + "### Step 5.1: Additional resources" |
1010 | 1010 | ]
|
1011 | 1011 | },
|
1012 | 1012 | {
|
|
1025 | 1025 | "cell_type": "markdown",
|
1026 | 1026 | "metadata": {},
|
1027 | 1027 | "source": [
|
1028 |
| - "#### Step 5.2: Cancel AWS Marketplace subscription" |
| 1028 | + "### Step 5.2: Cancel AWS Marketplace subscription" |
1029 | 1029 | ]
|
1030 | 1030 | },
|
1031 | 1031 | {
|
|
0 commit comments