gitwtfhub

wtf is shahd-llm-stack?

sabrydawood/shahd-llm-stack — explained in plain English

Analysis updated 2026-05-18

6TypeScriptAudience · developerComplexity · 5/5LicenseSetup · moderate

TL;DR

A from scratch large language model stack built in TypeScript, covering data collection, tokenization, training, and agent serving with visible reasoning.

Mindmap

mindmap
  root((shahd))
    What it does
      Builds LLM stack from scratch
      Data to training to serving
      Visible reasoning trace
    Tech stack
      TypeScript and Bun
      Go and C kernels
      Zod validation
    Trained models
      MicroChat 6.56M
      NanoChat variants
      CPU trained only
    Use cases
      Study transformer internals
      Train tiny models locally
      Experiment with agents
    Audience
      ML developers
      Systems programmers

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

Why would anyone build with this?

REASON 1

Study how a transformer, tokenizer, and training loop work by reading an implementation built from scratch

REASON 2

Train a tiny chat model on your own CPU using the built in data pipeline and training scripts

REASON 3

Experiment with agent tool calling and visible reasoning traces on a small local model

What's in the stack?

TypeScriptBunGoZod

How it stacks up

sabrydawood/shahd-llm-stackatomicstrata/atomicmemoryazerdsq131/mcpm
Stars666
LanguageTypeScriptTypeScriptTypeScript
Setup difficultymoderatemoderateeasy
Complexity5/54/52/5
Audiencedeveloperdeveloperdeveloper

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

How do you spin it up?

Difficulty · moderate Time to first run · 30min

Requires the Bun runtime plus Go and C toolchains for native compute kernels.

Proprietary: all rights reserved by the author, not open source.

Wtf does this do

Shahd is a from scratch language model stack built in TypeScript, using the Bun runtime along with native Go and C compute kernels. Rather than starting from someone else's model weights or fine tuning an existing model, the project builds every layer itself: a data pipeline, a tokenizer, a training loop, supervised fine tuning, and agent serving with a visible reasoning trace that shows how the model thinks before it answers. The codebase is organized into layers under a Brain folder, covering configuration, tensors and automatic differentiation, core math operations, the transformer itself, an optimizer, a tokenizer that mixes character and byte level encoding, a data collection pipeline with license checks and deduplication, a training loop, sampling with a key value cache, checkpointing, a safety filter, supervised fine tuning support, evaluation tools, a serving layer with tool calling and an agent loop, and reasoning techniques such as speculative decoding and self consistency. As of the current release, the project has trained four small checkpoints entirely on CPU, ranging from about 1 million to about 6.5 million parameters. The flagship model, called MicroChat, can greet a user, call a built in calculator tool with correct arguments, answer basic identity questions, hold short multi turn conversations, and display its reasoning steps live in a dashboard. The author is upfront that these are tiny, CPU trained models that perform well only within what they were trained on, not general purpose chat models, and that real capability would require much more scale. To try it, you install dependencies with Bun and can run commands to train a small model, sample from a saved checkpoint, or launch a local dashboard that walks through collecting data, training, and chatting with the result. The project enforces its own coding conventions through continuous integration, including naming rules and a file length limit. The license is proprietary: all rights are reserved by the author, so this is not an open source project you can freely reuse.

Yoink these prompts

Prompt 1
Explain how the autograd engine in shahd-llm-stack computes gradients for the transformer
Prompt 2
Walk me through running bun run train to train a small model on my own machine
Prompt 3
Show me how the KV cache sampling works in the Sampling folder
Prompt 4
Help me understand the difference between MicroChat and NanoChat in this repo

Frequently asked questions

wtf is shahd-llm-stack?

A from scratch large language model stack built in TypeScript, covering data collection, tokenization, training, and agent serving with visible reasoning.

What language is shahd-llm-stack written in?

Mainly TypeScript. The stack also includes TypeScript, Bun, Go.

What license does shahd-llm-stack use?

Proprietary: all rights reserved by the author, not open source.

How hard is shahd-llm-stack to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is shahd-llm-stack for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.