├── main.py ├── README.md └── Lab_1_summarize_dialogue.ipynb /main.py: -------------------------------------------------------------------------------- 1 | # This is a sample Python script. 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gen_ai_with_llms_course 2 | This is a repository I document all the notebooks from my Deeplearning.ai course on Generative AI with Large Language Models 3 | 4 | [Course](https://www.coursera.org/learn/generative-ai-with-llms/home/week/1) 5 | 6 | The LLM model that will be used is the 7 | [Flan T5 model](https://huggingface.co/docs/transformers/model_doc/flan-t5) 8 | -------------------------------------------------------------------------------- /Lab_1_summarize_dialogue.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Generative AI Use Case: Summarize Dialogue\n", 8 | "\n", 9 | "Welcome to the practical side of this course. In this lab you will do the dialogue summarization task using generative AI. You will explore how the input text affects the output of the model, and perform prompt engineering to direct it towards the task you need. By comparing zero shot, one shot, and few shot inferences, you will take the first step towards prompt engineering and see how it can enhance the generative output of Large Language Models." 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "# Table of Contents" 17 | ] 18 | }, 19 | { 20 | "cell_type": "markdown", 21 | "metadata": {}, 22 | "source": [ 23 | "- [ 1 - Set up Kernel and Required Dependencies](#1)\n", 24 | "- [ 2 - Summarize Dialogue without Prompt Engineering](#2)\n", 25 | "- [ 3 - Summarize Dialogue with an Instruction Prompt](#3)\n", 26 | " - [ 3.1 - Zero Shot Inference with an Instruction Prompt](#3.1)\n", 27 | " - [ 3.2 - Zero Shot Inference with the Prompt Template from FLAN-T5](#3.2)\n", 28 | "- [ 4 - Summarize Dialogue with One Shot and Few Shot Inference](#4)\n", 29 | " - [ 4.1 - One Shot Inference](#4.1)\n", 30 | " - [ 4.2 - Few Shot Inference](#4.2)\n", 31 | "- [ 5 - Generative Configuration Parameters for Inference](#5)\n" 32 | ] 33 | }, 34 | { 35 | "cell_type": "markdown", 36 | "metadata": {}, 37 | "source": [ 38 | "\n", 39 | "## 1 - Set up Kernel and Required Dependencies" 40 | ] 41 | }, 42 | { 43 | "cell_type": "markdown", 44 | "metadata": { 45 | "tags": [] 46 | }, 47 | "source": [ 48 | "First, check that the correct kernel is chosen.\n", 49 | "\n", 50 | "\n", 51 | "\n", 52 | "You can click on that (top right of the screen) to see and check the details of the image, kernel, and instance type.\n", 53 | "\n", 54 | "" 55 | ] 56 | }, 57 | { 58 | "cell_type": "markdown", 59 | "metadata": { 60 | "tags": [] 61 | }, 62 | "source": [ 63 | "Now install the required packages to use PyTorch and Hugging Face transformers and datasets.\n", 64 | "\n", 65 | "\"Time" 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": null, 71 | "metadata": { 72 | "tags": [] 73 | }, 74 | "outputs": [], 75 | "source": [ 76 | "%pip install --upgrade pip\n", 77 | "%pip install --disable-pip-version-check \\\n", 78 | " torch==1.13.1 \\\n", 79 | " torchdata==0.5.1 --quiet\n", 80 | "\n", 81 | "%pip install \\\n", 82 | " transformers==4.27.2 \\\n", 83 | " datasets==2.11.0 --quiet" 84 | ] 85 | }, 86 | { 87 | "cell_type": "markdown", 88 | "metadata": { 89 | "tags": [] 90 | }, 91 | "source": [ 92 | "\"Time" 93 | ] 94 | }, 95 | { 96 | "cell_type": "markdown", 97 | "metadata": { 98 | "tags": [] 99 | }, 100 | "source": [ 101 | "Load the datasets, Large Language Model (LLM), tokenizer, and configurator. Do not worry if you do not understand yet all of those components - they will be described and discussed later in the notebook." 102 | ] 103 | }, 104 | { 105 | "cell_type": "code", 106 | "execution_count": null, 107 | "metadata": { 108 | "tags": [] 109 | }, 110 | "outputs": [], 111 | "source": [ 112 | "from datasets import load_dataset\n", 113 | "from transformers import AutoModelForSeq2SeqLM\n", 114 | "from transformers import AutoTokenizer\n", 115 | "from transformers import GenerationConfig" 116 | ] 117 | }, 118 | { 119 | "cell_type": "markdown", 120 | "metadata": {}, 121 | "source": [ 122 | "\n", 123 | "## 2 - Summarize Dialogue without Prompt Engineering\n", 124 | "\n", 125 | "In this use case, you will be generating a summary of a dialogue with the pre-trained Large Language Model (LLM) FLAN-T5 from Hugging Face. The list of available models in the Hugging Face `transformers` package can be found [here](https://huggingface.co/docs/transformers/index). \n", 126 | "\n", 127 | "Let's upload some simple dialogues from the [DialogSum](https://huggingface.co/datasets/knkarthick/dialogsum) Hugging Face dataset. This dataset contains 10,000+ dialogues with the corresponding manually labeled summaries and topics. " 128 | ] 129 | }, 130 | { 131 | "cell_type": "code", 132 | "execution_count": null, 133 | "metadata": { 134 | "tags": [] 135 | }, 136 | "outputs": [], 137 | "source": [ 138 | "huggingface_dataset_name = \"knkarthick/dialogsum\"\n", 139 | "\n", 140 | "dataset = load_dataset(huggingface_dataset_name)" 141 | ] 142 | }, 143 | { 144 | "cell_type": "markdown", 145 | "metadata": { 146 | "tags": [] 147 | }, 148 | "source": [ 149 | "Print a couple of dialogues with their baseline summaries." 150 | ] 151 | }, 152 | { 153 | "cell_type": "code", 154 | "execution_count": null, 155 | "metadata": { 156 | "tags": [] 157 | }, 158 | "outputs": [], 159 | "source": [ 160 | "example_indices = [40, 200]\n", 161 | "\n", 162 | "dash_line = '-'.join('' for x in range(100))\n", 163 | "\n", 164 | "for i, index in enumerate(example_indices):\n", 165 | " print(dash_line)\n", 166 | " print('Example ', i + 1)\n", 167 | " print(dash_line)\n", 168 | " print('INPUT DIALOGUE:')\n", 169 | " print(dataset['test'][index]['dialogue'])\n", 170 | " print(dash_line)\n", 171 | " print('BASELINE HUMAN SUMMARY:')\n", 172 | " print(dataset['test'][index]['summary'])\n", 173 | " print(dash_line)\n", 174 | " print()" 175 | ] 176 | }, 177 | { 178 | "cell_type": "markdown", 179 | "metadata": {}, 180 | "source": [ 181 | "Load the [FLAN-T5 model](https://huggingface.co/docs/transformers/model_doc/flan-t5), creating an instance of the `AutoModelForSeq2SeqLM` class with the `.from_pretrained()` method. " 182 | ] 183 | }, 184 | { 185 | "cell_type": "code", 186 | "execution_count": null, 187 | "metadata": { 188 | "id": "iAYlS40Z3l-v", 189 | "tags": [] 190 | }, 191 | "outputs": [], 192 | "source": [ 193 | "model_name='google/flan-t5-base'\n", 194 | "\n", 195 | "model = AutoModelForSeq2SeqLM.from_pretrained(model_name)" 196 | ] 197 | }, 198 | { 199 | "cell_type": "markdown", 200 | "metadata": { 201 | "id": "sPqQA3TT3l_I", 202 | "tags": [] 203 | }, 204 | "source": [ 205 | "To perform encoding and decoding, you need to work with text in a tokenized form. **Tokenization** is the process of splitting texts into smaller units that can be processed by the LLM models. \n", 206 | "\n", 207 | "Download the tokenizer for the FLAN-T5 model using `AutoTokenizer.from_pretrained()` method. Parameter `use_fast` switches on fast tokenizer. At this stage, there is no need to go into the details of that, but you can find the tokenizer parameters in the [documentation](https://huggingface.co/docs/transformers/v4.28.1/en/model_doc/auto#transformers.AutoTokenizer)." 208 | ] 209 | }, 210 | { 211 | "cell_type": "code", 212 | "execution_count": null, 213 | "metadata": { 214 | "id": "sPqQA3TT3l_I", 215 | "tags": [] 216 | }, 217 | "outputs": [], 218 | "source": [ 219 | "tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=True)" 220 | ] 221 | }, 222 | { 223 | "cell_type": "markdown", 224 | "metadata": { 225 | "tags": [] 226 | }, 227 | "source": [ 228 | "Test the tokenizer encoding and decoding a simple sentence:" 229 | ] 230 | }, 231 | { 232 | "cell_type": "code", 233 | "execution_count": null, 234 | "metadata": { 235 | "tags": [] 236 | }, 237 | "outputs": [], 238 | "source": [ 239 | "sentence = \"What time is it, Tom?\"\n", 240 | "\n", 241 | "sentence_encoded = tokenizer(sentence, return_tensors='pt')\n", 242 | "\n", 243 | "sentence_decoded = tokenizer.decode(\n", 244 | " sentence_encoded[\"input_ids\"][0], \n", 245 | " skip_special_tokens=True\n", 246 | " )\n", 247 | "\n", 248 | "print('ENCODED SENTENCE:')\n", 249 | "print(sentence_encoded[\"input_ids\"][0])\n", 250 | "print('\\nDECODED SENTENCE:')\n", 251 | "print(sentence_decoded)" 252 | ] 253 | }, 254 | { 255 | "cell_type": "markdown", 256 | "metadata": {}, 257 | "source": [ 258 | "Now it's time to explore how well the base LLM summarizes a dialogue without any prompt engineering. **Prompt engineering** is an act of a human changing the **prompt** (input) to improve the response for a given task." 259 | ] 260 | }, 261 | { 262 | "cell_type": "code", 263 | "execution_count": null, 264 | "metadata": { 265 | "tags": [] 266 | }, 267 | "outputs": [], 268 | "source": [ 269 | "for i, index in enumerate(example_indices):\n", 270 | " dialogue = dataset['test'][index]['dialogue']\n", 271 | " summary = dataset['test'][index]['summary']\n", 272 | " \n", 273 | " inputs = tokenizer(dialogue, return_tensors='pt')\n", 274 | " output = tokenizer.decode(\n", 275 | " model.generate(\n", 276 | " inputs[\"input_ids\"], \n", 277 | " max_new_tokens=50,\n", 278 | " )[0], \n", 279 | " skip_special_tokens=True\n", 280 | " )\n", 281 | " \n", 282 | " print(dash_line)\n", 283 | " print('Example ', i + 1)\n", 284 | " print(dash_line)\n", 285 | " print(f'INPUT PROMPT:\\n{dialogue}')\n", 286 | " print(dash_line)\n", 287 | " print(f'BASELINE HUMAN SUMMARY:\\n{summary}')\n", 288 | " print(dash_line)\n", 289 | " print(f'MODEL GENERATION - WITHOUT PROMPT ENGINEERING:\\n{output}\\n')" 290 | ] 291 | }, 292 | { 293 | "cell_type": "markdown", 294 | "metadata": {}, 295 | "source": [ 296 | "You can see that the guesses of the model make some sense, but it doesn't seem to be sure what task it is supposed to accomplish. Seems it just makes up the next sentence in the dialogue. Prompt engineering can help here." 297 | ] 298 | }, 299 | { 300 | "cell_type": "markdown", 301 | "metadata": {}, 302 | "source": [ 303 | "\n", 304 | "## 3 - Summarize Dialogue with an Instruction Prompt\n", 305 | "\n", 306 | "Prompt engineering is an important concept in using foundation models for text generation. You can check out [this blog](https://www.amazon.science/blog/emnlp-prompt-engineering-is-the-new-feature-engineering) from Amazon Science for a quick introduction to prompt engineering." 307 | ] 308 | }, 309 | { 310 | "cell_type": "markdown", 311 | "metadata": {}, 312 | "source": [ 313 | "\n", 314 | "### 3.1 - Zero Shot Inference with an Instruction Prompt\n", 315 | "\n", 316 | "In order to instruct the model to perform a task - summarize a dialogue - you can take the dialogue and convert it into an instruction prompt. This is often called **zero shot inference**. You can check out [this blog from AWS](https://aws.amazon.com/blogs/machine-learning/zero-shot-prompting-for-the-flan-t5-foundation-model-in-amazon-sagemaker-jumpstart/) for a quick description of what zero shot learning is and why it is an important concept to the LLM model.\n", 317 | "\n", 318 | "Wrap the dialogue in a descriptive instruction and see how the generated text will change:" 319 | ] 320 | }, 321 | { 322 | "cell_type": "code", 323 | "execution_count": null, 324 | "metadata": { 325 | "tags": [] 326 | }, 327 | "outputs": [], 328 | "source": [ 329 | "for i, index in enumerate(example_indices):\n", 330 | " dialogue = dataset['test'][index]['dialogue']\n", 331 | " summary = dataset['test'][index]['summary']\n", 332 | "\n", 333 | " prompt = f\"\"\"\n", 334 | "Summarize the following conversation.\n", 335 | "\n", 336 | "{dialogue}\n", 337 | "\n", 338 | "Summary:\n", 339 | " \"\"\"\n", 340 | "\n", 341 | " # Input constructed prompt instead of the dialogue.\n", 342 | " inputs = tokenizer(prompt, return_tensors='pt')\n", 343 | " output = tokenizer.decode(\n", 344 | " model.generate(\n", 345 | " inputs[\"input_ids\"], \n", 346 | " max_new_tokens=50,\n", 347 | " )[0], \n", 348 | " skip_special_tokens=True\n", 349 | " )\n", 350 | " \n", 351 | " print(dash_line)\n", 352 | " print('Example ', i + 1)\n", 353 | " print(dash_line)\n", 354 | " print(f'INPUT PROMPT:\\n{prompt}')\n", 355 | " print(dash_line)\n", 356 | " print(f'BASELINE HUMAN SUMMARY:\\n{summary}')\n", 357 | " print(dash_line) \n", 358 | " print(f'MODEL GENERATION - ZERO SHOT:\\n{output}\\n')" 359 | ] 360 | }, 361 | { 362 | "cell_type": "markdown", 363 | "metadata": {}, 364 | "source": [ 365 | "This is much better! But the model still does not pick up on the nuance of the conversations though." 366 | ] 367 | }, 368 | { 369 | "cell_type": "markdown", 370 | "metadata": {}, 371 | "source": [ 372 | "**Exercise:**\n", 373 | "\n", 374 | "- Experiment with the `prompt` text and see how the inferences will be changed. Will the inferences change if you end the prompt with just empty string vs. `Summary: `?\n", 375 | "- Try to rephrase the beginning of the `prompt` text from `Summarize the following conversation.` to something different - and see how it will influence the generated output." 376 | ] 377 | }, 378 | { 379 | "cell_type": "markdown", 380 | "metadata": {}, 381 | "source": [ 382 | "\n", 383 | "### 3.2 - Zero Shot Inference with the Prompt Template from FLAN-T5\n", 384 | "\n", 385 | "Let's use a slightly different prompt. FLAN-T5 has many prompt templates that are published for certain tasks [here](https://github.com/google-research/FLAN/tree/main/flan/v2). In the following code, you will use one of the [pre-built FLAN-T5 prompts](https://github.com/google-research/FLAN/blob/main/flan/v2/templates.py):" 386 | ] 387 | }, 388 | { 389 | "cell_type": "code", 390 | "execution_count": null, 391 | "metadata": { 392 | "tags": [] 393 | }, 394 | "outputs": [], 395 | "source": [ 396 | "for i, index in enumerate(example_indices):\n", 397 | " dialogue = dataset['test'][index]['dialogue']\n", 398 | " summary = dataset['test'][index]['summary']\n", 399 | " \n", 400 | " prompt = f\"\"\"\n", 401 | "Dialogue:\n", 402 | "\n", 403 | "{dialogue}\n", 404 | "\n", 405 | "What was going on?\n", 406 | "\"\"\"\n", 407 | "\n", 408 | " inputs = tokenizer(prompt, return_tensors='pt')\n", 409 | " output = tokenizer.decode(\n", 410 | " model.generate(\n", 411 | " inputs[\"input_ids\"], \n", 412 | " max_new_tokens=50,\n", 413 | " )[0], \n", 414 | " skip_special_tokens=True\n", 415 | " )\n", 416 | "\n", 417 | " print(dash_line)\n", 418 | " print('Example ', i + 1)\n", 419 | " print(dash_line)\n", 420 | " print(f'INPUT PROMPT:\\n{prompt}')\n", 421 | " print(dash_line)\n", 422 | " print(f'BASELINE HUMAN SUMMARY:\\n{summary}\\n')\n", 423 | " print(dash_line)\n", 424 | " print(f'MODEL GENERATION - ZERO SHOT:\\n{output}\\n')" 425 | ] 426 | }, 427 | { 428 | "cell_type": "markdown", 429 | "metadata": {}, 430 | "source": [ 431 | "Notice that this prompt from FLAN-T5 did help a bit, but still struggles to pick up on the nuance of the conversation. This is what you will try to solve with the few shot inferencing." 432 | ] 433 | }, 434 | { 435 | "cell_type": "markdown", 436 | "metadata": {}, 437 | "source": [ 438 | "\n", 439 | "## 4 - Summarize Dialogue with One Shot and Few Shot Inference\n", 440 | "\n", 441 | "**One shot and few shot inference** are the practices of providing an LLM with either one or more full examples of prompt-response pairs that match your task - before your actual prompt that you want completed. This is called \"in-context learning\" and puts your model into a state that understands your specific task. You can read more about it in [this blog from HuggingFace](https://huggingface.co/blog/few-shot-learning-gpt-neo-and-inference-api)." 442 | ] 443 | }, 444 | { 445 | "cell_type": "markdown", 446 | "metadata": { 447 | "tags": [] 448 | }, 449 | "source": [ 450 | "\n", 451 | "### 4.1 - One Shot Inference\n", 452 | "\n", 453 | "Let's build a function that takes a list of `example_indices_full`, generates a prompt with full examples, then at the end appends the prompt which you want the model to complete (`example_index_to_summarize`). You will use the same FLAN-T5 prompt template from section [3.2](#3.2). " 454 | ] 455 | }, 456 | { 457 | "cell_type": "code", 458 | "execution_count": null, 459 | "metadata": { 460 | "tags": [] 461 | }, 462 | "outputs": [], 463 | "source": [ 464 | "def make_prompt(example_indices_full, example_index_to_summarize):\n", 465 | " prompt = ''\n", 466 | " for index in example_indices_full:\n", 467 | " dialogue = dataset['test'][index]['dialogue']\n", 468 | " summary = dataset['test'][index]['summary']\n", 469 | " \n", 470 | " # The stop sequence '{summary}\\n\\n\\n' is important for FLAN-T5. Other models may have their own preferred stop sequence.\n", 471 | " prompt += f\"\"\"\n", 472 | "Dialogue:\n", 473 | "\n", 474 | "{dialogue}\n", 475 | "\n", 476 | "What was going on?\n", 477 | "{summary}\n", 478 | "\n", 479 | "\n", 480 | "\"\"\"\n", 481 | " \n", 482 | " dialogue = dataset['test'][example_index_to_summarize]['dialogue']\n", 483 | " \n", 484 | " prompt += f\"\"\"\n", 485 | "Dialogue:\n", 486 | "\n", 487 | "{dialogue}\n", 488 | "\n", 489 | "What was going on?\n", 490 | "\"\"\"\n", 491 | " \n", 492 | " return prompt" 493 | ] 494 | }, 495 | { 496 | "cell_type": "markdown", 497 | "metadata": { 498 | "tags": [] 499 | }, 500 | "source": [ 501 | "Construct the prompt to perform one shot inference:" 502 | ] 503 | }, 504 | { 505 | "cell_type": "code", 506 | "execution_count": null, 507 | "metadata": { 508 | "tags": [] 509 | }, 510 | "outputs": [], 511 | "source": [ 512 | "example_indices_full = [40]\n", 513 | "example_index_to_summarize = 200\n", 514 | "\n", 515 | "one_shot_prompt = make_prompt(example_indices_full, example_index_to_summarize)\n", 516 | "\n", 517 | "print(one_shot_prompt)" 518 | ] 519 | }, 520 | { 521 | "cell_type": "markdown", 522 | "metadata": { 523 | "tags": [] 524 | }, 525 | "source": [ 526 | "Now pass this prompt to perform the one shot inference:" 527 | ] 528 | }, 529 | { 530 | "cell_type": "code", 531 | "execution_count": null, 532 | "metadata": { 533 | "tags": [] 534 | }, 535 | "outputs": [], 536 | "source": [ 537 | "summary = dataset['test'][example_index_to_summarize]['summary']\n", 538 | "\n", 539 | "inputs = tokenizer(one_shot_prompt, return_tensors='pt')\n", 540 | "output = tokenizer.decode(\n", 541 | " model.generate(\n", 542 | " inputs[\"input_ids\"],\n", 543 | " max_new_tokens=50,\n", 544 | " )[0], \n", 545 | " skip_special_tokens=True\n", 546 | ")\n", 547 | "\n", 548 | "print(dash_line)\n", 549 | "print(f'BASELINE HUMAN SUMMARY:\\n{summary}\\n')\n", 550 | "print(dash_line)\n", 551 | "print(f'MODEL GENERATION - ONE SHOT:\\n{output}')" 552 | ] 553 | }, 554 | { 555 | "cell_type": "markdown", 556 | "metadata": { 557 | "tags": [] 558 | }, 559 | "source": [ 560 | "\n", 561 | "### 4.2 - Few Shot Inference\n", 562 | "\n", 563 | "Let's explore few shot inference by adding two more full dialogue-summary pairs to your prompt." 564 | ] 565 | }, 566 | { 567 | "cell_type": "code", 568 | "execution_count": null, 569 | "metadata": { 570 | "tags": [] 571 | }, 572 | "outputs": [], 573 | "source": [ 574 | "example_indices_full = [40, 80, 120]\n", 575 | "example_index_to_summarize = 200\n", 576 | "\n", 577 | "few_shot_prompt = make_prompt(example_indices_full, example_index_to_summarize)\n", 578 | "\n", 579 | "print(few_shot_prompt)" 580 | ] 581 | }, 582 | { 583 | "cell_type": "markdown", 584 | "metadata": { 585 | "tags": [] 586 | }, 587 | "source": [ 588 | "Now pass this prompt to perform a few shot inference:" 589 | ] 590 | }, 591 | { 592 | "cell_type": "code", 593 | "execution_count": null, 594 | "metadata": { 595 | "tags": [] 596 | }, 597 | "outputs": [], 598 | "source": [ 599 | "summary = dataset['test'][example_index_to_summarize]['summary']\n", 600 | "\n", 601 | "inputs = tokenizer(few_shot_prompt, return_tensors='pt')\n", 602 | "output = tokenizer.decode(\n", 603 | " model.generate(\n", 604 | " inputs[\"input_ids\"],\n", 605 | " max_new_tokens=50,\n", 606 | " )[0], \n", 607 | " skip_special_tokens=True\n", 608 | ")\n", 609 | "\n", 610 | "print(dash_line)\n", 611 | "print(f'BASELINE HUMAN SUMMARY:\\n{summary}\\n')\n", 612 | "print(dash_line)\n", 613 | "print(f'MODEL GENERATION - FEW SHOT:\\n{output}')" 614 | ] 615 | }, 616 | { 617 | "cell_type": "markdown", 618 | "metadata": { 619 | "tags": [] 620 | }, 621 | "source": [ 622 | "In this case, few shot did not provide much of an improvement over one shot inference. And, anything above 5 or 6 shot will typically not help much, either. Also, you need to make sure that you do not exceed the model's input-context length which, in our case, if 512 tokens. Anything above the context length will be ignored.\n", 623 | "\n", 624 | "However, you can see that feeding in at least one full example (one shot) provides the model with more information and qualitatively improves the summary overall." 625 | ] 626 | }, 627 | { 628 | "cell_type": "markdown", 629 | "metadata": { 630 | "tags": [] 631 | }, 632 | "source": [ 633 | "**Exercise:**\n", 634 | "\n", 635 | "Experiment with the few shot inferencing.\n", 636 | "- Choose different dialogues - change the indices in the `example_indices_full` list and `example_index_to_summarize` value.\n", 637 | "- Change the number of shots. Be sure to stay within the model's 512 context length, however.\n", 638 | "\n", 639 | "How well does few shot inferencing work with other examples?" 640 | ] 641 | }, 642 | { 643 | "cell_type": "markdown", 644 | "metadata": { 645 | "tags": [] 646 | }, 647 | "source": [ 648 | "\n", 649 | "## 5 - Generative Configuration Parameters for Inference" 650 | ] 651 | }, 652 | { 653 | "cell_type": "markdown", 654 | "metadata": { 655 | "tags": [] 656 | }, 657 | "source": [ 658 | "You can change the configuration parameters of the `generate()` method to see a different output from the LLM. So far the only parameter that you have been setting was `max_new_tokens=50`, which defines the maximum number of tokens to generate. A full list of available parameters can be found in the [Hugging Face Generation documentation](https://huggingface.co/docs/transformers/v4.29.1/en/main_classes/text_generation#transformers.GenerationConfig). \n", 659 | "\n", 660 | "A convenient way of organizing the configuration parameters is to use `GenerationConfig` class. " 661 | ] 662 | }, 663 | { 664 | "cell_type": "markdown", 665 | "metadata": { 666 | "tags": [] 667 | }, 668 | "source": [ 669 | "**Exercise:**\n", 670 | "\n", 671 | "Change the configuration parameters to investigate their influence on the output. \n", 672 | "\n", 673 | "Putting the parameter `do_sample = True`, you activate various decoding strategies which influence the next token from the probability distribution over the entire vocabulary. You can then adjust the outputs changing `temperature` and other parameters (such as `top_k` and `top_p`). \n", 674 | "\n", 675 | "Uncomment the lines in the cell below and rerun the code. Try to analyze the results. You can read some comments below." 676 | ] 677 | }, 678 | { 679 | "cell_type": "code", 680 | "execution_count": null, 681 | "metadata": { 682 | "tags": [] 683 | }, 684 | "outputs": [], 685 | "source": [ 686 | "generation_config = GenerationConfig(max_new_tokens=50)\n", 687 | "# generation_config = GenerationConfig(max_new_tokens=10)\n", 688 | "# generation_config = GenerationConfig(max_new_tokens=50, do_sample=True, temperature=0.1)\n", 689 | "# generation_config = GenerationConfig(max_new_tokens=50, do_sample=True, temperature=0.5)\n", 690 | "# generation_config = GenerationConfig(max_new_tokens=50, do_sample=True, temperature=1.0)\n", 691 | "\n", 692 | "inputs = tokenizer(few_shot_prompt, return_tensors='pt')\n", 693 | "output = tokenizer.decode(\n", 694 | " model.generate(\n", 695 | " inputs[\"input_ids\"],\n", 696 | " generation_config=generation_config,\n", 697 | " )[0], \n", 698 | " skip_special_tokens=True\n", 699 | ")\n", 700 | "\n", 701 | "print(dash_line)\n", 702 | "print(f'MODEL GENERATION - FEW SHOT:\\n{output}')\n", 703 | "print(dash_line)\n", 704 | "print(f'BASELINE HUMAN SUMMARY:\\n{summary}\\n')" 705 | ] 706 | }, 707 | { 708 | "cell_type": "markdown", 709 | "metadata": {}, 710 | "source": [ 711 | "Comments related to the choice of the parameters in the code cell above:\n", 712 | "- Choosing `max_new_tokens=10` will make the output text too short, so the dialogue summary will be cut.\n", 713 | "- Putting `do_sample = True` and changing the temperature value you get more flexibility in the output." 714 | ] 715 | }, 716 | { 717 | "cell_type": "markdown", 718 | "metadata": {}, 719 | "source": [ 720 | "As you can see, prompt engineering can take you a long way for this use case, but there are some limitations. Next, you will start to explore how you can use fine-tuning to help your LLM to understand a particular use case in better depth!" 721 | ] 722 | }, 723 | { 724 | "cell_type": "code", 725 | "execution_count": null, 726 | "metadata": {}, 727 | "outputs": [], 728 | "source": [] 729 | } 730 | ], 731 | "metadata": { 732 | "availableInstances": [ 733 | { 734 | "_defaultOrder": 0, 735 | "_isFastLaunch": true, 736 | "category": "General purpose", 737 | "gpuNum": 0, 738 | "hideHardwareSpecs": false, 739 | "memoryGiB": 4, 740 | "name": "ml.t3.medium", 741 | "vcpuNum": 2 742 | }, 743 | { 744 | "_defaultOrder": 1, 745 | "_isFastLaunch": false, 746 | "category": "General purpose", 747 | "gpuNum": 0, 748 | "hideHardwareSpecs": false, 749 | "memoryGiB": 8, 750 | "name": "ml.t3.large", 751 | "vcpuNum": 2 752 | }, 753 | { 754 | "_defaultOrder": 2, 755 | "_isFastLaunch": false, 756 | "category": "General purpose", 757 | "gpuNum": 0, 758 | "hideHardwareSpecs": false, 759 | "memoryGiB": 16, 760 | "name": "ml.t3.xlarge", 761 | "vcpuNum": 4 762 | }, 763 | { 764 | "_defaultOrder": 3, 765 | "_isFastLaunch": false, 766 | "category": "General purpose", 767 | "gpuNum": 0, 768 | "hideHardwareSpecs": false, 769 | "memoryGiB": 32, 770 | "name": "ml.t3.2xlarge", 771 | "vcpuNum": 8 772 | }, 773 | { 774 | "_defaultOrder": 4, 775 | "_isFastLaunch": true, 776 | "category": "General purpose", 777 | "gpuNum": 0, 778 | "hideHardwareSpecs": false, 779 | "memoryGiB": 8, 780 | "name": "ml.m5.large", 781 | "vcpuNum": 2 782 | }, 783 | { 784 | "_defaultOrder": 5, 785 | "_isFastLaunch": false, 786 | "category": "General purpose", 787 | "gpuNum": 0, 788 | "hideHardwareSpecs": false, 789 | "memoryGiB": 16, 790 | "name": "ml.m5.xlarge", 791 | "vcpuNum": 4 792 | }, 793 | { 794 | "_defaultOrder": 6, 795 | "_isFastLaunch": false, 796 | "category": "General purpose", 797 | "gpuNum": 0, 798 | "hideHardwareSpecs": false, 799 | "memoryGiB": 32, 800 | "name": "ml.m5.2xlarge", 801 | "vcpuNum": 8 802 | }, 803 | { 804 | "_defaultOrder": 7, 805 | "_isFastLaunch": false, 806 | "category": "General purpose", 807 | "gpuNum": 0, 808 | "hideHardwareSpecs": false, 809 | "memoryGiB": 64, 810 | "name": "ml.m5.4xlarge", 811 | "vcpuNum": 16 812 | }, 813 | { 814 | "_defaultOrder": 8, 815 | "_isFastLaunch": false, 816 | "category": "General purpose", 817 | "gpuNum": 0, 818 | "hideHardwareSpecs": false, 819 | "memoryGiB": 128, 820 | "name": "ml.m5.8xlarge", 821 | "vcpuNum": 32 822 | }, 823 | { 824 | "_defaultOrder": 9, 825 | "_isFastLaunch": false, 826 | "category": "General purpose", 827 | "gpuNum": 0, 828 | "hideHardwareSpecs": false, 829 | "memoryGiB": 192, 830 | "name": "ml.m5.12xlarge", 831 | "vcpuNum": 48 832 | }, 833 | { 834 | "_defaultOrder": 10, 835 | "_isFastLaunch": false, 836 | "category": "General purpose", 837 | "gpuNum": 0, 838 | "hideHardwareSpecs": false, 839 | "memoryGiB": 256, 840 | "name": "ml.m5.16xlarge", 841 | "vcpuNum": 64 842 | }, 843 | { 844 | "_defaultOrder": 11, 845 | "_isFastLaunch": false, 846 | "category": "General purpose", 847 | "gpuNum": 0, 848 | "hideHardwareSpecs": false, 849 | "memoryGiB": 384, 850 | "name": "ml.m5.24xlarge", 851 | "vcpuNum": 96 852 | }, 853 | { 854 | "_defaultOrder": 12, 855 | "_isFastLaunch": false, 856 | "category": "General purpose", 857 | "gpuNum": 0, 858 | "hideHardwareSpecs": false, 859 | "memoryGiB": 8, 860 | "name": "ml.m5d.large", 861 | "vcpuNum": 2 862 | }, 863 | { 864 | "_defaultOrder": 13, 865 | "_isFastLaunch": false, 866 | "category": "General purpose", 867 | "gpuNum": 0, 868 | "hideHardwareSpecs": false, 869 | "memoryGiB": 16, 870 | "name": "ml.m5d.xlarge", 871 | "vcpuNum": 4 872 | }, 873 | { 874 | "_defaultOrder": 14, 875 | "_isFastLaunch": false, 876 | "category": "General purpose", 877 | "gpuNum": 0, 878 | "hideHardwareSpecs": false, 879 | "memoryGiB": 32, 880 | "name": "ml.m5d.2xlarge", 881 | "vcpuNum": 8 882 | }, 883 | { 884 | "_defaultOrder": 15, 885 | "_isFastLaunch": false, 886 | "category": "General purpose", 887 | "gpuNum": 0, 888 | "hideHardwareSpecs": false, 889 | "memoryGiB": 64, 890 | "name": "ml.m5d.4xlarge", 891 | "vcpuNum": 16 892 | }, 893 | { 894 | "_defaultOrder": 16, 895 | "_isFastLaunch": false, 896 | "category": "General purpose", 897 | "gpuNum": 0, 898 | "hideHardwareSpecs": false, 899 | "memoryGiB": 128, 900 | "name": "ml.m5d.8xlarge", 901 | "vcpuNum": 32 902 | }, 903 | { 904 | "_defaultOrder": 17, 905 | "_isFastLaunch": false, 906 | "category": "General purpose", 907 | "gpuNum": 0, 908 | "hideHardwareSpecs": false, 909 | "memoryGiB": 192, 910 | "name": "ml.m5d.12xlarge", 911 | "vcpuNum": 48 912 | }, 913 | { 914 | "_defaultOrder": 18, 915 | "_isFastLaunch": false, 916 | "category": "General purpose", 917 | "gpuNum": 0, 918 | "hideHardwareSpecs": false, 919 | "memoryGiB": 256, 920 | "name": "ml.m5d.16xlarge", 921 | "vcpuNum": 64 922 | }, 923 | { 924 | "_defaultOrder": 19, 925 | "_isFastLaunch": false, 926 | "category": "General purpose", 927 | "gpuNum": 0, 928 | "hideHardwareSpecs": false, 929 | "memoryGiB": 384, 930 | "name": "ml.m5d.24xlarge", 931 | "vcpuNum": 96 932 | }, 933 | { 934 | "_defaultOrder": 20, 935 | "_isFastLaunch": false, 936 | "category": "General purpose", 937 | "gpuNum": 0, 938 | "hideHardwareSpecs": true, 939 | "memoryGiB": 0, 940 | "name": "ml.geospatial.interactive", 941 | "supportedImageNames": [ 942 | "sagemaker-geospatial-v1-0" 943 | ], 944 | "vcpuNum": 0 945 | }, 946 | { 947 | "_defaultOrder": 21, 948 | "_isFastLaunch": true, 949 | "category": "Compute optimized", 950 | "gpuNum": 0, 951 | "hideHardwareSpecs": false, 952 | "memoryGiB": 4, 953 | "name": "ml.c5.large", 954 | "vcpuNum": 2 955 | }, 956 | { 957 | "_defaultOrder": 22, 958 | "_isFastLaunch": false, 959 | "category": "Compute optimized", 960 | "gpuNum": 0, 961 | "hideHardwareSpecs": false, 962 | "memoryGiB": 8, 963 | "name": "ml.c5.xlarge", 964 | "vcpuNum": 4 965 | }, 966 | { 967 | "_defaultOrder": 23, 968 | "_isFastLaunch": false, 969 | "category": "Compute optimized", 970 | "gpuNum": 0, 971 | "hideHardwareSpecs": false, 972 | "memoryGiB": 16, 973 | "name": "ml.c5.2xlarge", 974 | "vcpuNum": 8 975 | }, 976 | { 977 | "_defaultOrder": 24, 978 | "_isFastLaunch": false, 979 | "category": "Compute optimized", 980 | "gpuNum": 0, 981 | "hideHardwareSpecs": false, 982 | "memoryGiB": 32, 983 | "name": "ml.c5.4xlarge", 984 | "vcpuNum": 16 985 | }, 986 | { 987 | "_defaultOrder": 25, 988 | "_isFastLaunch": false, 989 | "category": "Compute optimized", 990 | "gpuNum": 0, 991 | "hideHardwareSpecs": false, 992 | "memoryGiB": 72, 993 | "name": "ml.c5.9xlarge", 994 | "vcpuNum": 36 995 | }, 996 | { 997 | "_defaultOrder": 26, 998 | "_isFastLaunch": false, 999 | "category": "Compute optimized", 1000 | "gpuNum": 0, 1001 | "hideHardwareSpecs": false, 1002 | "memoryGiB": 96, 1003 | "name": "ml.c5.12xlarge", 1004 | "vcpuNum": 48 1005 | }, 1006 | { 1007 | "_defaultOrder": 27, 1008 | "_isFastLaunch": false, 1009 | "category": "Compute optimized", 1010 | "gpuNum": 0, 1011 | "hideHardwareSpecs": false, 1012 | "memoryGiB": 144, 1013 | "name": "ml.c5.18xlarge", 1014 | "vcpuNum": 72 1015 | }, 1016 | { 1017 | "_defaultOrder": 28, 1018 | "_isFastLaunch": false, 1019 | "category": "Compute optimized", 1020 | "gpuNum": 0, 1021 | "hideHardwareSpecs": false, 1022 | "memoryGiB": 192, 1023 | "name": "ml.c5.24xlarge", 1024 | "vcpuNum": 96 1025 | }, 1026 | { 1027 | "_defaultOrder": 29, 1028 | "_isFastLaunch": true, 1029 | "category": "Accelerated computing", 1030 | "gpuNum": 1, 1031 | "hideHardwareSpecs": false, 1032 | "memoryGiB": 16, 1033 | "name": "ml.g4dn.xlarge", 1034 | "vcpuNum": 4 1035 | }, 1036 | { 1037 | "_defaultOrder": 30, 1038 | "_isFastLaunch": false, 1039 | "category": "Accelerated computing", 1040 | "gpuNum": 1, 1041 | "hideHardwareSpecs": false, 1042 | "memoryGiB": 32, 1043 | "name": "ml.g4dn.2xlarge", 1044 | "vcpuNum": 8 1045 | }, 1046 | { 1047 | "_defaultOrder": 31, 1048 | "_isFastLaunch": false, 1049 | "category": "Accelerated computing", 1050 | "gpuNum": 1, 1051 | "hideHardwareSpecs": false, 1052 | "memoryGiB": 64, 1053 | "name": "ml.g4dn.4xlarge", 1054 | "vcpuNum": 16 1055 | }, 1056 | { 1057 | "_defaultOrder": 32, 1058 | "_isFastLaunch": false, 1059 | "category": "Accelerated computing", 1060 | "gpuNum": 1, 1061 | "hideHardwareSpecs": false, 1062 | "memoryGiB": 128, 1063 | "name": "ml.g4dn.8xlarge", 1064 | "vcpuNum": 32 1065 | }, 1066 | { 1067 | "_defaultOrder": 33, 1068 | "_isFastLaunch": false, 1069 | "category": "Accelerated computing", 1070 | "gpuNum": 4, 1071 | "hideHardwareSpecs": false, 1072 | "memoryGiB": 192, 1073 | "name": "ml.g4dn.12xlarge", 1074 | "vcpuNum": 48 1075 | }, 1076 | { 1077 | "_defaultOrder": 34, 1078 | "_isFastLaunch": false, 1079 | "category": "Accelerated computing", 1080 | "gpuNum": 1, 1081 | "hideHardwareSpecs": false, 1082 | "memoryGiB": 256, 1083 | "name": "ml.g4dn.16xlarge", 1084 | "vcpuNum": 64 1085 | }, 1086 | { 1087 | "_defaultOrder": 35, 1088 | "_isFastLaunch": false, 1089 | "category": "Accelerated computing", 1090 | "gpuNum": 1, 1091 | "hideHardwareSpecs": false, 1092 | "memoryGiB": 61, 1093 | "name": "ml.p3.2xlarge", 1094 | "vcpuNum": 8 1095 | }, 1096 | { 1097 | "_defaultOrder": 36, 1098 | "_isFastLaunch": false, 1099 | "category": "Accelerated computing", 1100 | "gpuNum": 4, 1101 | "hideHardwareSpecs": false, 1102 | "memoryGiB": 244, 1103 | "name": "ml.p3.8xlarge", 1104 | "vcpuNum": 32 1105 | }, 1106 | { 1107 | "_defaultOrder": 37, 1108 | "_isFastLaunch": false, 1109 | "category": "Accelerated computing", 1110 | "gpuNum": 8, 1111 | "hideHardwareSpecs": false, 1112 | "memoryGiB": 488, 1113 | "name": "ml.p3.16xlarge", 1114 | "vcpuNum": 64 1115 | }, 1116 | { 1117 | "_defaultOrder": 38, 1118 | "_isFastLaunch": false, 1119 | "category": "Accelerated computing", 1120 | "gpuNum": 8, 1121 | "hideHardwareSpecs": false, 1122 | "memoryGiB": 768, 1123 | "name": "ml.p3dn.24xlarge", 1124 | "vcpuNum": 96 1125 | }, 1126 | { 1127 | "_defaultOrder": 39, 1128 | "_isFastLaunch": false, 1129 | "category": "Memory Optimized", 1130 | "gpuNum": 0, 1131 | "hideHardwareSpecs": false, 1132 | "memoryGiB": 16, 1133 | "name": "ml.r5.large", 1134 | "vcpuNum": 2 1135 | }, 1136 | { 1137 | "_defaultOrder": 40, 1138 | "_isFastLaunch": false, 1139 | "category": "Memory Optimized", 1140 | "gpuNum": 0, 1141 | "hideHardwareSpecs": false, 1142 | "memoryGiB": 32, 1143 | "name": "ml.r5.xlarge", 1144 | "vcpuNum": 4 1145 | }, 1146 | { 1147 | "_defaultOrder": 41, 1148 | "_isFastLaunch": false, 1149 | "category": "Memory Optimized", 1150 | "gpuNum": 0, 1151 | "hideHardwareSpecs": false, 1152 | "memoryGiB": 64, 1153 | "name": "ml.r5.2xlarge", 1154 | "vcpuNum": 8 1155 | }, 1156 | { 1157 | "_defaultOrder": 42, 1158 | "_isFastLaunch": false, 1159 | "category": "Memory Optimized", 1160 | "gpuNum": 0, 1161 | "hideHardwareSpecs": false, 1162 | "memoryGiB": 128, 1163 | "name": "ml.r5.4xlarge", 1164 | "vcpuNum": 16 1165 | }, 1166 | { 1167 | "_defaultOrder": 43, 1168 | "_isFastLaunch": false, 1169 | "category": "Memory Optimized", 1170 | "gpuNum": 0, 1171 | "hideHardwareSpecs": false, 1172 | "memoryGiB": 256, 1173 | "name": "ml.r5.8xlarge", 1174 | "vcpuNum": 32 1175 | }, 1176 | { 1177 | "_defaultOrder": 44, 1178 | "_isFastLaunch": false, 1179 | "category": "Memory Optimized", 1180 | "gpuNum": 0, 1181 | "hideHardwareSpecs": false, 1182 | "memoryGiB": 384, 1183 | "name": "ml.r5.12xlarge", 1184 | "vcpuNum": 48 1185 | }, 1186 | { 1187 | "_defaultOrder": 45, 1188 | "_isFastLaunch": false, 1189 | "category": "Memory Optimized", 1190 | "gpuNum": 0, 1191 | "hideHardwareSpecs": false, 1192 | "memoryGiB": 512, 1193 | "name": "ml.r5.16xlarge", 1194 | "vcpuNum": 64 1195 | }, 1196 | { 1197 | "_defaultOrder": 46, 1198 | "_isFastLaunch": false, 1199 | "category": "Memory Optimized", 1200 | "gpuNum": 0, 1201 | "hideHardwareSpecs": false, 1202 | "memoryGiB": 768, 1203 | "name": "ml.r5.24xlarge", 1204 | "vcpuNum": 96 1205 | }, 1206 | { 1207 | "_defaultOrder": 47, 1208 | "_isFastLaunch": false, 1209 | "category": "Accelerated computing", 1210 | "gpuNum": 1, 1211 | "hideHardwareSpecs": false, 1212 | "memoryGiB": 16, 1213 | "name": "ml.g5.xlarge", 1214 | "vcpuNum": 4 1215 | }, 1216 | { 1217 | "_defaultOrder": 48, 1218 | "_isFastLaunch": false, 1219 | "category": "Accelerated computing", 1220 | "gpuNum": 1, 1221 | "hideHardwareSpecs": false, 1222 | "memoryGiB": 32, 1223 | "name": "ml.g5.2xlarge", 1224 | "vcpuNum": 8 1225 | }, 1226 | { 1227 | "_defaultOrder": 49, 1228 | "_isFastLaunch": false, 1229 | "category": "Accelerated computing", 1230 | "gpuNum": 1, 1231 | "hideHardwareSpecs": false, 1232 | "memoryGiB": 64, 1233 | "name": "ml.g5.4xlarge", 1234 | "vcpuNum": 16 1235 | }, 1236 | { 1237 | "_defaultOrder": 50, 1238 | "_isFastLaunch": false, 1239 | "category": "Accelerated computing", 1240 | "gpuNum": 1, 1241 | "hideHardwareSpecs": false, 1242 | "memoryGiB": 128, 1243 | "name": "ml.g5.8xlarge", 1244 | "vcpuNum": 32 1245 | }, 1246 | { 1247 | "_defaultOrder": 51, 1248 | "_isFastLaunch": false, 1249 | "category": "Accelerated computing", 1250 | "gpuNum": 1, 1251 | "hideHardwareSpecs": false, 1252 | "memoryGiB": 256, 1253 | "name": "ml.g5.16xlarge", 1254 | "vcpuNum": 64 1255 | }, 1256 | { 1257 | "_defaultOrder": 52, 1258 | "_isFastLaunch": false, 1259 | "category": "Accelerated computing", 1260 | "gpuNum": 4, 1261 | "hideHardwareSpecs": false, 1262 | "memoryGiB": 192, 1263 | "name": "ml.g5.12xlarge", 1264 | "vcpuNum": 48 1265 | }, 1266 | { 1267 | "_defaultOrder": 53, 1268 | "_isFastLaunch": false, 1269 | "category": "Accelerated computing", 1270 | "gpuNum": 4, 1271 | "hideHardwareSpecs": false, 1272 | "memoryGiB": 384, 1273 | "name": "ml.g5.24xlarge", 1274 | "vcpuNum": 96 1275 | }, 1276 | { 1277 | "_defaultOrder": 54, 1278 | "_isFastLaunch": false, 1279 | "category": "Accelerated computing", 1280 | "gpuNum": 8, 1281 | "hideHardwareSpecs": false, 1282 | "memoryGiB": 768, 1283 | "name": "ml.g5.48xlarge", 1284 | "vcpuNum": 192 1285 | }, 1286 | { 1287 | "_defaultOrder": 55, 1288 | "_isFastLaunch": false, 1289 | "category": "Accelerated computing", 1290 | "gpuNum": 8, 1291 | "hideHardwareSpecs": false, 1292 | "memoryGiB": 1152, 1293 | "name": "ml.p4d.24xlarge", 1294 | "vcpuNum": 96 1295 | }, 1296 | { 1297 | "_defaultOrder": 56, 1298 | "_isFastLaunch": false, 1299 | "category": "Accelerated computing", 1300 | "gpuNum": 8, 1301 | "hideHardwareSpecs": false, 1302 | "memoryGiB": 1152, 1303 | "name": "ml.p4de.24xlarge", 1304 | "vcpuNum": 96 1305 | } 1306 | ], 1307 | "instance_type": "ml.m5.2xlarge", 1308 | "kernelspec": { 1309 | "display_name": "Python 3 (Data Science)", 1310 | "language": "python", 1311 | "name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-east-1:081325390199:image/datascience-1.0" 1312 | }, 1313 | "language_info": { 1314 | "codemirror_mode": { 1315 | "name": "ipython", 1316 | "version": 3 1317 | }, 1318 | "file_extension": ".py", 1319 | "mimetype": "text/x-python", 1320 | "name": "python", 1321 | "nbconvert_exporter": "python", 1322 | "pygments_lexer": "ipython3", 1323 | "version": "3.7.10" 1324 | } 1325 | }, 1326 | "nbformat": 4, 1327 | "nbformat_minor": 4 1328 | } 1329 | --------------------------------------------------------------------------------