Open-source project
rasbt/LLMs-from-scratch avatar
rasbt/LLMs-from-scratch

LLMs-from-scratch: the dependency markers decide what actually installs on your machine

GitHub describes it as Implement a ChatGPT-like LLM in PyTorch from scratch, step by step. The repository metadata lists Jupyter Notebook as its primary language. The metadata lists the NOASSERTION license. This article stays within the project description and details documented in the GitHub repository README.

105,755 stars16,230 forksJupyter NotebookNOASSERTION

At a glance

What is it?
rasbt/LLMs-from-scratch is the code that accompanies Sebastian Raschka's book Build a Large Language Model (From Scratch), one directory per chapter. Its pyproject.toml encodes four separate torch markers and five TensorFlow ones, and the gap between what those markers resolve to on an Intel Mac and on Python 3.13 is the practical part of adopting it.
Who is it for?
Take this repository if you are working through the book and want each chapter runnable on your own interpreter, and take the GitHub copy rather than the Manning bundle so your code matches the current state. Do not take it as a library: chapter 1 and Appendix B ship no code at all, the bonus dependency group is not installed by default, and nothing here is a service you can point a product at.
Can I use it commercially?
Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
Is it still maintained?
Yes. The repository last received commits 8 days ago.
What is it written in?
Mainly Jupyter Notebook, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 29, 2026, and from our analysis. They are not legal advice.

Editorial analysis

Two distributions of one codebase, and the bundle can fall behind

There are two ways to hold this code, and the README does not pretend they are the same. One is the bundle you get from Manning, the publisher of Build a Large Language Model (From Scratch), ISBN 9781633437166. The other is the GitHub repository, and the instruction given to bundle holders is to visit the GitHub copy for the latest updates. That sentence is the entire versioning story: the book artifact and the repository can drift apart, and the project positions GitHub as the fresher of the two.

There is a second reason to take the repository. The README warns that its own file is Markdown and renders badly in a plain text viewer, suggesting Ghostwriter or letting GitHub render it in the browser. A bundle unpacked onto a laptop without an editor shows a wall of table pipes, and the chapter table is the part you need first.

Consequence for the reader: if your plan is to follow the chapters offline, the Manning bundle gives you code that may predate the repository, while the repository gives you a README that needs a Markdown viewer to read comfortably. The clone command costs one line and removes the drift.

Each chapter keeps a 01_main-chapter-code folder and its own solutions notebook

Every chapter is a directory containing a subdirectory named 01_main-chapter-code, and that subdirectory is a slice rather than the whole thing. The quick-access column of the chapter table points at ch02.ipynb, dataloader.ipynb and exercise-solutions.ipynb under ch02, at multihead-attention.ipynb under ch03, at gpt.py under ch04, at gpt_train.py and gpt_generate.py under ch05, at gpt_class_finetune.py under ch06, and at gpt_instruction_finetuning.py with ollama_evaluate.py under ch07. The last column links each chapter directory itself for the version with supplementary material.

Two rows in that table are prose. Chapter 1, Understanding Large Language Models, is marked No code, and Appendix B, References and Further Reading, is also marked No code. Both directories still exist among the top-level entries, so the absence is a decision about what ships, not a missing folder.

Consequence for the reader: exercise solutions appear twice, once inside each chapter's quick-access folder and once as the separate appendix-C list, and nothing in the names says which copy is authoritative. If you are checking whether a solution changed after an update, you have two files to compare and no signal about which one to believe.

requirements.txt names the chapters, and psutil is the one pyproject drops

requirements.txt carries comments naming the chapters that need each dependency, which makes it the fastest map of what a chapter imports. tiktoken is marked ch02, ch04, ch05. matplotlib is marked ch04, ch06, ch07. tensorflow is marked ch05, ch06, ch07. tqdm is marked ch05, ch07, pandas is marked ch06, and psutil is marked ch07 with a note that it is already installed automatically as a dependency of torch.

That note is where the two dependency files disagree. psutil does not appear in the dependencies list of pyproject.toml at all. A repository that annotates its own imports down to the chapter has still left one chapter's runtime helper to be pulled in transitively by torch, with a comment acknowledging it.

Consequence for the reader: installing from pyproject.toml gets you a working ch07 only for as long as torch keeps carrying psutil. An environment assembled from a different torch build, a slimmed container image, or a resolver that honours only the declared dependencies leaves ch07 without a library the requirements file says it needs, and the failure shows up at import time rather than at install time.

Only Intel macOS carries a torch ceiling below 2.6

The torch entries in pyproject.toml are four separate environment markers rather than one range, and the reason is Intel Macs. The line for sys_platform darwin with platform_machine x86_64 is capped at torch>=2.2.2,<2.6. The lines for darwin arm64, linux, and win32 each read torch>=2.2.2 with no upper bound at all. All four also carry python_version <= '3.14', so on Python 3.14 the interpreter part of the marker stops matching and none of the four lines applies.

Consequence for the reader: the ceiling exists for exactly one platform, so a reader on an Intel Mac resolves a materially older torch than a reader on Apple silicon, Linux, or Windows reading the same file on the same day. If you are comparing behaviour between two machines to decide something, the torch build is not the same experiment on both, and pyproject.toml is the only place in the repository that tells you so.

Every TensorFlow marker stops at Python 3.12 while the torch markers run to 3.14

requires-python is >=3.10,<3.15, which leaves room for interpreter versions the dependency markers do not cover. The torch lines hold through python_version 3.14. All five tensorflow lines stop one step earlier, at python_version < '3.13'. Read together, the project claims support for Python 3.13 and 3.14 while pinning TensorFlow only where the interpreter is 3.12 or older.

TensorFlow is not optional dressing for the chapters that need it. requirements.txt names it for ch05, ch06, and ch07, which cover pretraining on unlabeled data and the two finetuning stages. Consequence for the reader: install on Python 3.13 and the resolver skips every TensorFlow line, which leaves the three chapters that requirements.txt itself labels as TensorFlow chapters without the library their code expects. Nothing in the repository's top-level README tells you to pin an older interpreter for those chapters, so the mismatch surfaces when the import runs rather than when the environment is built.

.gitmodules is declared and the documented clone leaves it empty

Among the top-level entries there is a .gitmodules file, which means the repository declares at least one submodule. The command given for getting the code is a shallow clone with no submodule handling:

bash
git clone --depth 1 https://github.com/rasbt/LLMs-from-scratch.git

Consequence for the reader: following that command exactly leaves any submodule directory present but unpopulated, and the README does not document what sits behind .gitmodules or how to initialise it. A reader who opens an empty directory has no instruction to follow and no way to tell whether the content is missing from their checkout or was never in this repository. The --depth 1 flag is a deliberate trade, since the commit history is not what this project is for, but it means the code arrives as a snapshot with no upstream to diff against later.

pytest and pip sit in the runtime dependencies, not the dev group

The dependencies list in pyproject.toml puts pytest>=9.1.1 and pip>=25.0.1 in the project's own requirements rather than in a development group. The dev group holds build and twine, the tools for producing and uploading a package. So a plain install of llms-from-scratch version 1.0.18 brings a test runner and a package installer in alongside torch, jupyterlab, tiktoken, matplotlib, tqdm, numpy, and pandas, and that test runner is what gives the top-level conftest.py something to do.

A separate bonus group holds the rest: blobfile, chainlit, huggingface_hub, ipywidgets, llms_from_scratch at 1.0.18, openai, requests, safetensors, scikit-learn, and sentencepiece. The [tool.uv.sources] entry points llms-from-scratch back at the workspace, so the group resolves the package against the checkout rather than an index.

Consequence for the reader: the bonus group is where anything touching a hosted model or a served endpoint lives, and it is not installed by default. Code that reaches for a remote model fails at import, not at configuration, and no chapter table row marks which files need the group before you run them.

Editorial conclusion

Take this repository if you are working through the book and want each chapter runnable on your own interpreter, and take the GitHub copy rather than the Manning bundle so your code matches the current state. Do not take it as a library: chapter 1 and Appendix B ship no code at all, the bonus dependency group is not installed by default, and nothing here is a service you can point a product at. Before you start, check three things on your own machine: which torch version the four markers resolve to, whether your Python is 3.13 or 3.14 and therefore skips every TensorFlow line, and whether the directory you expected to contain code is a submodule that the documented clone command left empty.

Frequently asked questions

How do I get the code for Build a Large Language Model (From Scratch)?

The repository is cloned with git clone --depth 1 https://github.com/rasbt/LLMs-from-scratch.git, or downloaded as a ZIP from the repository page. Readers who got the code bundle from the Manning website are pointed back to the GitHub copy for the latest updates.

What Python versions does LLMs-from-scratch support?

pyproject.toml sets requires-python to >=3.10,<3.15. The torch dependency markers additionally require python_version <= '3.14', and every tensorflow marker requires python_version < '3.13', so TensorFlow is not installed on Python 3.13 or 3.14.

Why is my torch install older on an Intel Mac?

One marker in pyproject.toml pins torch>=2.2.2,<2.6 where sys_platform is darwin and platform_machine is x86_64. The markers for darwin arm64, linux, and win32 require only torch>=2.2.2, with no upper bound.

Which chapters have no code in the LLMs-from-scratch repository?

Chapter 1, Understanding Large Language Models, and Appendix B, References and Further Reading, are both marked No code in the chapter table. Their directories still exist among the repository's top-level entries.

Official sources

  1. Official documentation
  2. Official README
  3. Project repository
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/rasbt-llms-from-scratch.svg)](https://hysenlabs.com/projects/rasbt-llms-from-scratch)