MyLLM isn’t just another library — it’s a playground for learning and building LLMs from scratch. This project was born out of a desire to fully understand every line of a transformer stack, from tokenization to RLHF.
Here's what's inside right now:
| Area | Status | Description |
|---|---|---|
| Notebooks | ✅ Stable | Step-by-step guided learning |
| Modules | ✅ Stable | Mini-projects for experimentation |
| Core Framework | ⚙️ Active Development | Pure PyTorch, lightweight, transparent |
| MetaBot | 🛠 Coming Soon | A chatbot that explains itself |
Warning: Some parts are stable, others are actively evolving.
Use this repo to explore, experiment, and break things safely — that's how you learn deeply.
There are plenty of libraries out there (Hugging Face, Lightning, etc.), but they hide too much of the magic. I wanted something different:
- Minimal – no unnecessary abstractions, no magic.
- Hackable – every part of the stack is visible and editable.
- Research-Friendly – a place to experiment with cutting-edge techniques like LoRA, QLoRA, PPO, and DPO.
- From Scratch – so you truly understand the internals.
This is a framework for engineers who want to think like researchers and researchers who want to ship real systems.
MyLLM is structured into three progressive layers:
The notebooks/ directory is where you’ll start your journey.
Each notebook builds from scratch, step-by-step, with theory + code.
git clone https://github.com/silvaxxx1/MyLLM101.git
cd MyLLM101
pip install -r requirements.txt
jupyter notebook notebooks/0.0.WELCOME.ipynbTopics covered:
- Building a transformer from first principles
- Attention optimizations (Flash Attention, MQA, GQA)
- Efficient fine-tuning with LoRA & QLoRA
- RLHF algorithms like PPO & DPO
- Inference optimizations (KV caching, quantization)
💡 Modify the attention mask in the notebook and see how outputs change — hands-on learning at its best.
The modules/ folder is a collection of self-contained experiments.
MyLLM/
└── modules/
├── data/
├── models/
├── training/
├── finetuning/
└── inference/
Example: Train a small GPT from scratch
python modules/train_gpt.py --config configs/basic.ymlThis lets you experiment on one piece of the puzzle without touching the whole pipeline.
The myllm/ folder is where everything comes together.
Goals:
- Clean, minimal APIs
- Full transparency
- Designed for scaling, research, and production
Example usage:
from myllm import LLM, SFTTrainer, DPOTrainer, PPOTrainer, Quantizer
# Load model
llm = LLM.load("checkpoints/my_model.pt")
# Generate
output = llm.generate("Once upon a time in a world of AI,")
print(output)
# Fine-tune with LoRA
sft = SFTTrainer(model=llm, dataset=my_dataset)
sft.train(epochs=3, batch_size=32)
# Preference Optimization
dpo = DPOTrainer(model=llm, dataset=preference_dataset)
dpo.train(epochs=5)
# RLHF with PPO
ppo = PPOTrainer(model=llm, environment=rlhf_env)
ppo.train(iterations=10)
# Quantize for faster inference
quantizer = Quantizer(model=llm)
llm_int8 = quantizer.apply(precision="int8")💡 Every line here maps to real, visible code — no magic.
The final vision is MetaBot — an interactive chatbot built entirely with MyLLM.
A chatbot that not only answers your questions but also shows you exactly how it works under the hood.
Built with:
- MyLLM core framework
- Gradio for UI
- Fully open source
| Status | Milestone | Details |
|---|---|---|
| ✅ | Interactive Notebooks | Learn LLM fundamentals hands-on |
| ✅ | Modular Mini-Projects | Build reusable, composable components |
| ⚙️ | MyLLM Core Framework | Fine-tuning, DPO, PPO, quantization |
| 🛠 | MetaBot + Gradio UI | Interactive chatbot & deployment |
- Run a notebook → tweak hyperparameters → watch how the model changes.
- Build a mini GPT that writes haiku poems.
- Add a new trainer to the framework (e.g., TRL variant).
- Quantize a model and measure speedup in inference.
- Fork the repo and contribute a new attention mechanism.
This project wouldn’t exist without the incredible work of others:
- Andrej Karpathy — NanoGPT minimalism
- Umar Jamil — Practical LLM tutorials
- Sebastian Raschka — Deep transformer insights
The end goal: A transparent, educational, and production-ready LLM stack built entirely from scratch, by and for engineers who want to own every line of their AI system.
Let's strip away the black boxes and build the future of LLMs — together.
MyLLM isn’t about copying Hugging Face. It’s about understanding it — and then building something new, from first principles.
This version emphasizes:
- Learning path clarity — beginner → advanced → framework.
- Hackable research — not just another wrapper library.
- Engineering depth — you’re not just calling
.fit(); you’re building.fit()yourself. - Positioning MyLLM as a foundation for serious engineers.