AIAny
Icon for item

Train LLM From Scratch

Provides end-to-end PyTorch scripts to download/prepare data, implement a transformer from scratch, train LLMs (13M→billion-scale) and generate text. Emphasizes educational clarity and single‑GPU experiments; useful for researchers or hobbyists, but large-scale training still requires substantial compute and engineering.

Introduction

Why this matters

Training large language models is often opaque: tooling, data plumbing, and model code live in different repos and papers. This project bundles a minimal, pedagogical transformer implementation with scripts that cover data download (the Pile), tokenization, HDF5 storage, training loops, and generation—so an individual with a single GPU can reproduce small (≈13M) experiments and explore scaling trade-offs to larger sizes.

What Sets It Apart
  • End-to-end, from raw Pile .jsonl.zst files to trained checkpoints and a simple generate script; focuses on reproducibility and learning rather than production performance. This makes it easy to trace how data → tokens → batches → model → sampling behave.
  • Minimal-from-scratch implementation: transformer blocks, single/multi-head attention, MLP and training loop are implemented in plain PyTorch (no heavy library abstractions), which helps users inspect internals and experiment with architecture/hyperparameter changes.
  • Explicit scaling discussion and config presets: the README documents experiments at ~13M and up to multi-billion parameter setups and lists practical GPU-memory expectations for different consumer/pro data cards, so users can plan based on their hardware.
Who It's For & Trade-offs

Great fit if you want a teaching‑focused, forkable repo to learn transformer internals, run quick LLM experiments on a single GPU, or prototype tokenizer/data pipelines. Look elsewhere if you need production‑grade training (distributed optimization, mixed precision engineering, checkpointing at scale, datasets/legal hygiene) — the code is intentionally simple and lacks many engineering optimizations (memory-efficient attention, advanced schedulers, robust sharding, or curated licensing checks). Also note: training beyond small models still requires significant compute, careful hyperparameter tuning, and dataset/legal considerations.

More Items

Hugging Face
AI Model2026

Answers structured decision questions (choice / yes-no / score) about text, images and videos in one call and returns probabilities for every option. A 27B multimodal model (includes a 0.46B vision encoder), supports zero-shot classification, image/video inputs and integrates with vLLM / vLLM Semantic Router for high-throughput serving. Apache-2.0.

Hugging Face
AI Model2026

Generates calibrated decisions (choice/score/noul) from a prompt and optional images, up to 256 options. Routed MoE experts are quantized to NVIDIA NVFP4 to reduce weights to ~25.6 GB and GPU memory to ~23.3 GiB; provided as a vLLM-compatible System 1 decision model with a /v1/decide endpoint.

Hugging Face
AI Model2026

Runs a 24B-parameter mixture-of-experts reasoning model with only ~2B active parameters per token for fast on-device agentic workflows; provides a 131K-token context and 128K vocabulary, post-trained for tool calling and agentic RL—pair with retrieval for knowledge-heavy tasks.