Add PyPI package (#576)

* Add PyPI package

* fixes

* fixes
This commit is contained in:
Sebastian Raschka
2025-03-23 19:28:49 -05:00
committed by GitHub
parent 85f2bc0a58
commit 7114ccd10d
52 changed files with 2173 additions and 2585 deletions

View File

@@ -198,6 +198,16 @@
" create_balanced_dataset,\n",
" random_split\n",
")\n",
"# If the `previous_chapters.py` file is not available locally,\n",
"# you can import it from the `llms-from-scratch` PyPI package.\n",
"# For details, see: https://github.com/rasbt/LLMs-from-scratch/tree/main/pkg\n",
"# E.g.,\n",
"# from llms_from_scratch.ch06 import (\n",
"# download_and_unzip_spam_data,\n",
"# create_balanced_dataset,\n",
"# random_split\n",
"# )\n",
"\n",
"\n",
"\n",
"url = \"https://archive.ics.uci.edu/static/public/228/sms+spam+collection.zip\"\n",
@@ -409,6 +419,10 @@
"source": [
"from gpt_download import download_and_load_gpt2\n",
"from previous_chapters import GPTModel, load_weights_into_gpt\n",
"# Alternatively:\n",
"# from llms_from_scratch.ch04 import GPTModel\n",
"# from llms_from_scratch.ch05 import load_weights_into_gpt\n",
"\n",
"\n",
"\n",
"CHOOSE_MODEL = \"gpt2-small (124M)\"\n",
@@ -577,6 +591,9 @@
],
"source": [
"from previous_chapters import calc_accuracy_loader\n",
"# Alternatively:\n",
"# from llms_from_scratch.ch06 import calc_accuracy_loader\n",
"\n",
"\n",
"\n",
"torch.manual_seed(123)\n",
@@ -1387,6 +1404,8 @@
"source": [
"import time\n",
"from previous_chapters import train_classifier_simple\n",
"# Alternatively:\n",
"# from llms_from_scratch.ch06 import train_classifier_simple\n",
"\n",
"\n",
"start_time = time.time()\n",
@@ -1442,6 +1461,8 @@
],
"source": [
"from previous_chapters import plot_values\n",
"# Alternatively:\n",
"# from llms_from_scratch.ch06 import plot_values\n",
"\n",
"epochs_tensor = torch.linspace(0, num_epochs, len(train_losses))\n",
"examples_seen_tensor = torch.linspace(0, examples_seen, len(train_losses))\n",