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

@@ -147,6 +147,11 @@
"source": [
"import torch\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",
@@ -212,6 +217,9 @@
"import tiktoken\n",
"from previous_chapters import generate_text_simple\n",
"\n",
"# Alternatively:\n",
"# from llms_from_scratch.ch04 import generate_text_simple\n",
"\n",
"def text_to_token_ids(text, tokenizer):\n",
" encoded = tokenizer.encode(text, allowed_special={'<|endoftext|>'})\n",
" encoded_tensor = torch.tensor(encoded).unsqueeze(0) # add batch dimension\n",
@@ -924,6 +932,8 @@
"outputs": [],
"source": [
"from previous_chapters import create_dataloader_v1\n",
"# Alternatively:\n",
"# from llms_from_scratch.ch02 import create_dataloader_v1\n",
"\n",
"# Train/validation ratio\n",
"train_ratio = 0.90\n",
@@ -2548,7 +2558,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.8"
"version": "3.10.16"
}
},
"nbformat": 4,