|
198 | 198 | " create_balanced_dataset,\n", |
199 | 199 | " random_split\n", |
200 | 200 | ")\n", |
| 201 | + "# If the `previous_chapters.py` file is not available locally,\n", |
| 202 | + "# you can import it from the `llms-from-scratch` PyPI package.\n", |
| 203 | + "# For details, see: https://github.com/rasbt/LLMs-from-scratch/tree/main/pkg\n", |
| 204 | + "# E.g.,\n", |
| 205 | + "# from llms_from_scratch.ch06 import (\n", |
| 206 | + "# download_and_unzip_spam_data,\n", |
| 207 | + "# create_balanced_dataset,\n", |
| 208 | + "# random_split\n", |
| 209 | + "# )\n", |
| 210 | + "\n", |
201 | 211 | "\n", |
202 | 212 | "\n", |
203 | 213 | "url = \"https://archive.ics.uci.edu/static/public/228/sms+spam+collection.zip\"\n", |
|
409 | 419 | "source": [ |
410 | 420 | "from gpt_download import download_and_load_gpt2\n", |
411 | 421 | "from previous_chapters import GPTModel, load_weights_into_gpt\n", |
| 422 | + "# Alternatively:\n", |
| 423 | + "# from llms_from_scratch.ch04 import GPTModel\n", |
| 424 | + "# from llms_from_scratch.ch05 import load_weights_into_gpt\n", |
| 425 | + "\n", |
412 | 426 | "\n", |
413 | 427 | "\n", |
414 | 428 | "CHOOSE_MODEL = \"gpt2-small (124M)\"\n", |
|
577 | 591 | ], |
578 | 592 | "source": [ |
579 | 593 | "from previous_chapters import calc_accuracy_loader\n", |
| 594 | + "# Alternatively:\n", |
| 595 | + "# from llms_from_scratch.ch06 import calc_accuracy_loader\n", |
| 596 | + "\n", |
580 | 597 | "\n", |
581 | 598 | "\n", |
582 | 599 | "torch.manual_seed(123)\n", |
|
1387 | 1404 | "source": [ |
1388 | 1405 | "import time\n", |
1389 | 1406 | "from previous_chapters import train_classifier_simple\n", |
| 1407 | + "# Alternatively:\n", |
| 1408 | + "# from llms_from_scratch.ch06 import train_classifier_simple\n", |
1390 | 1409 | "\n", |
1391 | 1410 | "\n", |
1392 | 1411 | "start_time = time.time()\n", |
|
1442 | 1461 | ], |
1443 | 1462 | "source": [ |
1444 | 1463 | "from previous_chapters import plot_values\n", |
| 1464 | + "# Alternatively:\n", |
| 1465 | + "# from llms_from_scratch.ch06 import plot_values\n", |
1445 | 1466 | "\n", |
1446 | 1467 | "epochs_tensor = torch.linspace(0, num_epochs, len(train_losses))\n", |
1447 | 1468 | "examples_seen_tensor = torch.linspace(0, examples_seen, len(train_losses))\n", |
|
0 commit comments