
local-llm
A comprehensive guide for building and configuring a high-end local machine to run state-of-the-art LLMs, with detailed hardware choices, BIOS tuning, and Docker-based model serving.
It implements the full LLM stack from scratch rather than wrapping existing model code, including RoPE, RMSNorm, SwiGLU, GQA, weight tying, KV caching, a custom BPE tokenizer, data pipeline, training, inference, chat, and tests.
Zen-2 is an original, from-scratch, decoder-only transformer language model (~123M parameters) built for the workflow of a lightweight chat assistant: instruction following, Q&A, multi-turn conversation, summarization, concept explanation, basic code completion, and creative writing.
It is not a GPT-2 clone. The architecture follows the design choices of modern open-weight LLMs (LLaMA/Mistral/Qwen-style models):
Every module is independently implemented, documented, and unit-tested. See
docs/architecture.md for the full design writeup, including the math
intuition, complexity analysis, advantages, and limitations of each
component.
Zen-2/
├── configs/ model + training YAML configs
├── zen2/
│ ├── config.py ModelConfig / TrainConfig dataclasses
│ ├── model/ RMSNorm, RoPE, GQA attention, SwiGLU, transformer, KV cache
│ ├── tokenizer/ byte-level BPE tokenizer
│ ├── data/ cleaning/filtering/dedup pipeline, binary dataset packer/loader
│ ├── training/ Trainer, optimizer, cosine scheduler, checkpoint manager
│ ├── inference/ sampling strategies, generation engine (KV-cache + streaming)
│ ├── chat/ multi-turn chat engine
│ ├── evaluation/ perplexity/throughput metrics, quality benchmark harness
│ └── utils/ seeding, logging
├── scripts/ CLI entry points (see below)
├── tests/ pytest unit + integration tests
├── docs/ design docs (architecture, training, tokenizer, inference, data)
├── examples/ quickstart walkthrough
└── weights/, logs/, datasets/ run outputs (empty by default)
pip install -r requirements.txt
# 1. Train a tokenizer on your corpus
python scripts/train_tokenizer.py --files my_corpus/*.txt --vocab-size 32000 \
--out tokenizer/zen2_tokenizer.json
# 2. Clean, tokenize, and pack your training
A modern 124M-parameter decoder-only LLM built from scratch. RoPE · RMSNorm · SwiGLU · GQA · KV Cache · BPE Tokenizer · Full training pipeline. Research-grade, production-quality.
Similar projects matched by category, topics, and programming language.

A comprehensive guide for building and configuring a high-end local machine to run state-of-the-art LLMs, with detailed hardware choices, BIOS tuning, and Docker-based model serving.
A 28.9 million parameter language model runs on an $8 ESP32-S3 microcontroller entirely on-device, generating simple stories at about 9.5 tokens per second.
Deltafin is a research project that runs the 2.8-trillion-parameter Mixture-of-Experts model Kimi K3 on a single Apple Silicon Mac (e.g., M1 Max with 64 GB) at about 16 seconds per token, using exact, reproducible inference with local or streaming expert loading.