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 7757c3d308
commit c21bfe4a23
52 changed files with 2173 additions and 2585 deletions

View File

@@ -68,6 +68,11 @@
"\n",
"\n",
"from previous_chapters import GPTModel\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.ch04 import GPTModel\n",
"\n",
"GPT_CONFIG_124M = {\n",
" \"vocab_size\": 50257, # Vocabulary size\n",
@@ -139,6 +144,9 @@
"outputs": [],
"source": [
"from previous_chapters import create_dataloader_v1\n",
"# Alternatively:\n",
"# from llms_from_scratch.ch02 import create_dataloader_v1\n",
"\n",
"\n",
"# Train/validation ratio\n",
"train_ratio = 0.90\n",
@@ -454,6 +462,9 @@
"outputs": [],
"source": [
"from previous_chapters import calc_loss_batch\n",
"# Alternatively:\n",
"# from llms_from_scratch.ch05 import calc_loss_batch\n",
"\n",
"\n",
"torch.manual_seed(123)\n",
"model = GPTModel(GPT_CONFIG_124M)\n",
@@ -551,6 +562,9 @@
"outputs": [],
"source": [
"from previous_chapters import evaluate_model, generate_and_print_sample\n",
"# Alternatively:\n",
"# from llms_from_scratch.ch05 import evaluate_model, generate_and_print_samplee\n",
"\n",
"\n",
"ORIG_BOOK_VERSION = False\n",
"\n",
@@ -790,6 +804,9 @@
],
"source": [
"from previous_chapters import plot_losses\n",
"# Alternatively:\n",
"# from llms_from_scratch.ch05 import plot_losses\n",
"\n",
"\n",
"epochs_tensor = torch.linspace(1, n_epochs, len(train_losses))\n",
"plot_losses(epochs_tensor, tokens_seen, train_losses, val_losses)\n",
@@ -823,7 +840,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.10.16"
}
},
"nbformat": 4,