Skip to content
JM-BrunPublic

About

LLM investigation and experimentations

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

LLM Lab

LLM Lab is a bilingual, code-first learning and experimentation project for people who want to understand how language models work, build their components, and investigate their behavior. It connects intuition, mathematics, readable implementations, tests, and controlled experiments—from text and tokenization through attention and generation, with training, adaptation, evaluation, and efficiency as longer-term goals.

The aim is to learn from small, inspectable models and evidence, not to train a production-scale LLM from scratch.

Explore LLM Lab in French · Explore in English

How the lab is designed

  • Understand before scaling. Follow inference through a small model before studying how its parameters learn. The guided build, pretrained-model adaptation, and cross-cutting evaluation have distinct dependencies; advanced mathematics is available when needed, not a blanket prerequisite.
  • Learn at different depths. The site connects conceptual explanations, a guided build, optional deep dives, exercises, and experiments. It supports non-linear navigation and progressive disclosure while keeping necessary definitions and caveats visible.
  • Test the mathematics and code. Use worked examples, explicit shapes and conventions, numerical edge cases, invariants, gradients, and reference comparisons where appropriate. Readable teaching implementations take priority over optimized kernels.
  • Measure and challenge claims. Define questions and baselines; record data provenance, configurations, seeds, metrics, compute costs, and limitations. Use counterexamples and failure analysis, and distinguish an illustration, a passing test, and an experimental result.
  • Keep the public material complete and bilingual. French and English should preserve the same claims and qualifications. The public lab must stand on its own even when general concepts are also developed in a separate private knowledge base; no private repository is a reading or build dependency.
  • Respect provenance and reuse. Cite the work that supports a claim, check rights for code, data, and figures, and avoid committing secrets, raw datasets, or model weights.

See the learning path for the authoritative module-level objectives and evidence gates, the Foundations architecture for the approved first-class theoretical and mathematical component, the content-section map for destination boundaries and page ownership, the roadmap for priorities and acceptance criteria, and the experiment protocol for reporting requirements. The interactive learning route and exploratory graphs are reader-facing projections; their source ownership and maintenance are indexed in information architecture. The broader knowledge and learning ecosystem architecture explains how Understand, Review, Practice, Build, Deepen and editorial collections share canonical knowledge while retaining specialized models. Its implementation backlog records the remaining work. The 2026 advent-calendar redesign specifies 24 independent scientific stories; implementation and migration remain tracked in the editorial redesign and the session handoff. The thematic landscape and future story candidates records complementary perspectives for later editions without changing the approved 2026 slate.

Knowledge management and cross-project architecture

The extraction locator inventory workflow provides a read-only audit of the locator types and value shapes used in source extractions before type-specific validation rules are introduced.

The comparative analysis of knowledge-management practices from Society Lab, including the transfer boundaries, provenance model, graph semantics, quality controls, scalability recommendations and existing follow-up issues, is documented in the cross-project knowledge-management transfer analysis. The first evidence-traced scientific pilot across attention, information theory and compression is documented in the cross-graph pilot report. The separate scalability and capacity audit evaluates current bottlenecks and defines synthetic growth tests before the project claims readiness for thousands of sources. The focused test and CI performance plan records measured test timings, completed first optimizations and the remaining latency backlog without weakening validation gates. The first opt-in concept-registry validation benchmark provides a reproducible starting point for measuring in-memory graph-validation growth; it does not yet provide measured performance results. This complements rather than replaces the information architecture, source-lineage architecture, and source-process audit.

Inspiration and sources

Sebastian Raschka's Build a Large Language Model (From Scratch) provides a major implementation and scope reference, not a mandatory table of contents. The lab also draws on visual explanations such as Jay Alammar's Illustrated GPT-2 and the practical perspective of the Hugging Face LLM Course. The annotated references describe these and other sources, their roles, and reuse boundaries; the source lineage architecture defines how source identity, inspection history and evidence-linked provenance are maintained. Primary papers and official documentation remain important for checking technical claims.

For how this lab positions itself against comparable public learning projects, see the comparable-projects landscape.

Current state

The NumPy reference implements inference with a small, randomly initialized decoder-only GPT, plus loss, training-window, and decoding helpers. Its output demonstrates generation mechanics, not learned language quality. A complete tokenizer/corpus pipeline, training loop, and trained-model evaluation are still planned. See project status for evidence and limitations.

Run locally

You need Python 3.12 or later and uv. Core exercises use small inputs and run on CPU.

uv sync --locked --dev
uv pip install --python .venv/bin/python -r docs/requirements-tokenizer-example.txt
uv pip install --python .venv/bin/python -r docs/requirements-history-validation.txt
uv run --locked pytest
uv run --locked python experiments/decoding-distribution/run.py

The two documentation requirements files supply dependencies used by site checks and tests; reinstall them after a fresh uv sync --locked --dev. The last command compares decoding distributions for fixed synthetic logits. Its report explains the baseline, results, and limits; it does not measure language quality.

The core implementation uses NumPy. The lockfile records the resolved Python dependencies; optional PyTorch support can be installed with uv sync --locked --dev --extra ml. Reusable code lives in src/llm_lab/, tests in tests/, and experiment definitions and evidence in experiments/ and reports/. Notebooks are explanatory rather than the sole home of reusable logic.

Render the site

Install Quarto separately; CI uses version 1.11.9. From the repository root:

uv run --no-project --with-requirements docs/requirements-history-validation.txt --python 3.12 python site/tools/build_learning_map.py
uv run --no-project --with-requirements docs/requirements-history-validation.txt --python 3.12 python site/tools/render_history_pilot.py
quarto render site

The first command validates the canonical page/concept metadata and generates the bilingual learning-map data and guided-route Markdown partials. The route is maintained in data/guided-route.yml; the generated partials are tracked because Quarto expands their includes before project pre-render hooks run. The second command generates the bilingual history timeline includes. The site is written to site/_site/.

Contribute

Architecture and maintenance entry point: Information architecture and metadata governance. It is the index for the canonical sources, their ownership boundaries, the generated projections, and the maintenance workflow. Use the contributor guide for the practical change workflow; detailed rules remain in their owning documents.

For pedagogical reviews, the project includes two focused agent skills under .agents/skills/: Understand Path Audit reviews the conceptual reader journey, page-to-page transitions, readability and editorial harmonization; Build Path Audit reviews implementation dependencies, milestone handoffs, code, tests and reproducibility. They preserve the distinction between the two pathways in the learning path; neither treats one as a prerequisite for the other.

See CONTRIBUTING.md for contribution modes, setup, Git hooks, and checks. The toolchain uses pytest for tests, Ruff for linting and formatting, mypy for type checking, pre-commit hooks, and GitHub Actions for Python and site checks. Passing these checks or rendering the site does not by itself establish scientific correctness, learner understanding, or visual quality.

The roadmap records priorities; the information architecture indexes the metadata, page composition, and audit contracts. Site sources are in site/; project guidance and research notes are in docs/.

License

Project code is released under the MIT License. CC BY-SA 4.0 applies only to original project-authored prose in Quarto pages and documentation. All non-text assets (including local SVGs, diagrams, images, screenshots and fonts) are excluded from these project grants unless a separate asset-level licence is explicitly recorded. Third-party materials retain their own terms. See LICENSE.md, licensing scope, and the visual asset register.

About

LLM investigation and experimentations

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages