whatisgithub

What is minillm?

solocalm/minillm — explained in plain English

Analysis updated 2026-05-18

13PythonAudience · researcherComplexity · 4/5Setup · moderate

In one sentence

An educational project that teaches you to build a small language model from scratch, covering pretraining, fine-tuning, and alignment, on a single consumer GPU.

Mindmap

mindmap
  root((MiniLLM))
    What it does
      Build LLM from scratch
      Runs on one 6GB GPU
      Every step reproducible
    Tech stack
      Python
      PyTorch
      HuggingFace export
    Use cases
      Learn transformer internals
      Run full training pipeline
      Compare against QLoRA baseline
    Audience
      ML researchers
      Students
    Training stages
      Pretraining
      SFT
      LoRA
      DPO alignment

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Learn how a LLaMA2-style transformer works by reading a hand-written implementation.

USE CASE 2

Run a full pretrain, SFT, LoRA, and DPO training pipeline on a single 6GB GPU.

USE CASE 3

Compare a small from-scratch model against a QLoRA fine-tune of a larger existing model.

USE CASE 4

Study annotated code-analysis documents that explain each core training file.

What is it built with?

PythonPyTorchHuggingFace

How does it compare?

solocalm/minillm1lystore/awaekactashui/sjtu-ppt-template-skill
Stars131313
LanguagePythonPythonPython
Setup difficultymoderatemoderatemoderate
Complexity4/52/52/5
Audienceresearchervibe coderresearcher

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 1h+

Needs a CUDA GPU with at least 6GB of memory and dataset downloads before training starts.

The README does not state a license for this repository.

So what is it?

MiniLLM is an educational project that walks through building a small language model entirely from scratch using Python and PyTorch. The goal is to make every step of modern AI training reproducible and understandable on consumer hardware. The entire pipeline runs on a single graphics card with 6 GB of memory, such as an RTX 4050. The model itself has about 38 million parameters and uses the same architectural style as LLaMA2, a well-known open AI model. This means it uses grouped-query attention (a way of organizing how the model attends to different parts of text), a specific type of feed-forward network called SwiGLU, rotary position encoding, and layer normalization via RMSNorm. All of these components are written by hand in the codebase rather than imported from existing libraries, so readers can follow exactly what each piece does. Training proceeds through four stages that mirror what large commercial AI labs do at much larger scale. First, pre-training teaches the model basic language patterns by predicting the next token across a large text dataset for 50,000 steps. Second, supervised fine-tuning (SFT) loads the pre-trained model and trains it on instruction-following examples so it learns to respond to prompts. Third, LoRA fine-tuning applies a parameter-efficient technique that updates only a small fraction of the weights (about 2.28%) rather than the whole model. Fourth, DPO (direct preference optimization) trains the model to prefer human-approved responses over rejected ones, which is a technique used to align AI outputs with human preferences. The repository also includes a baseline track using QLoRA on Qwen2.5-1.5B, a much larger existing model, for comparison. Five ablation experiments cover choices like learning rate, LoRA rank, and the effect of the DPO alignment step. Eleven annotated code analysis documents walk through each major source file in detail. The model can be exported in HuggingFace format and used via a command-line chat interface.

Copy-paste prompts

Prompt 1
Walk me through setting up MiniLLM and running the full pretrain to DPO pipeline on my GPU.
Prompt 2
Explain what grouped-query attention, SwiGLU, and RoPE are using MiniLLM's implementation as a reference.
Prompt 3
Help me compare the QLoRA baseline on Qwen2.5-1.5B against the from-scratch 38M model.
Prompt 4
Show me how DPO alignment works and how MiniLLM applies it after SFT.

Frequently asked questions

What is minillm?

An educational project that teaches you to build a small language model from scratch, covering pretraining, fine-tuning, and alignment, on a single consumer GPU.

What language is minillm written in?

Mainly Python. The stack also includes Python, PyTorch, HuggingFace.

What license does minillm use?

The README does not state a license for this repository.

How hard is minillm to set up?

Setup difficulty is rated moderate, with roughly 1h+ to a first successful run.

Who is minillm for?

Mainly researcher.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.