dlmastery/data_science_examples/nano-llm-transformer

Claude Code and agent skill by dlmastery/data_science_examples

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Comprehensive guide and autonomous runbook for building, training, and deploying NanoLlama — a from-scratch Modern Transformer Language Model and Chatbot. Covers Rotary Position Embeddings (RoPE), SwiGLU Gated Feed-Forward Networks, RMSNorm, Stateful KV-Cache O(1) decoding, subword tokenizer training, AdamW Cosine Annealing scheduler, FastAPI SSE streaming, attention heatmaps visualizer, and React Tokenizer Studio.

Install

npx vskill@latest install dlmastery/data_science_examples/nano-llm-transformer

SKILL.md

The same SKILL.md was published earlier as dlmastery/data_science_examples/nano-llm-transformer.

NanoLlama — Modern Transformer LLM & Chatbot Platform Reproduction Runbook

This skill provides the complete end-to-end instructions to build, train, deploy, and verify NanoLlama from scratch using state-of-the-art transformer primitives.


1. Mathematical Primitives & Model Specifications

  1. Rotary Position Embeddings (RoPE):

$$(x \cos m\theta) + (\text{rotate\_half}(x) \sin m\theta)$$ Enables relative distance awareness across sequence lengths without learned absolute position embeddings.

  1. SwiGLU Gated Activation:

$$\text{SwiGLU}(x) = (\text{silu}(x W_{\text{gate}}) \odot x W_{\text{up}}) W_{\text{down}}$$

  1. RMSNorm Pre-Normalization:

$$\text{RMSNorm}(x) = \frac{x}{\text{RMS}(x)} \odot \gamma$$

  1. Key-Value Cache (KV-Cache):

Maintains key and value state tensors across sequential token generation steps for $O(1)$ autoregressive decoding.

  1. Dimensions: 3 Layers, 4 Heads, $d_{\text{model}} = 128$, FFN hidden dim $= 384$, context window $= 96$, total parameters $= 672,512$.

2. Step-by-Step Reproduction Workflow

Step 1: Tokenizer & Dataset Generation

Run subword tokenizer training and build synthetic multi-task conversational dataset:

bash
cd core
python tokenizer.py
python dataset.py
Step 2: Model Training Loop

Train NanoLlama on CPU / GPU with AdamW and Cosine Learning Rate Schedule:

bash
python train.py
  • Target Metrics: Validation Perplexity $< 1.10$, Loss $< 0.06$.
  • Checkpoints: Exports server/checkpoints/model.pt and telemetry.json.
Step 3: Run Automated API Tests

Verify streaming endpoints, attention tensor extraction, and tokenizer analysis:

bash
cd ../server
python test_api.py
Step 4: Launch Microservices
  1. FastAPI Streaming Microservice (Port 8002):

``bash python -m uvicorn main:app --host 127.0.0.1 --port 8002 ``

  1. React 18 + Vite Quantum Neural Web App (Port 5175):

``bash cd ../client npm install npm run dev ``

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/dlmastery/data_science_examples/nano-llm-transformer/badge)](https://verified-skill.com/skills/dlmastery/data_science_examples/nano-llm-transformer)

Something wrong with this skill or its page? Tell us.