A collection of my from-scratch implementation of various models deployed on HF Spaces
See the codeBuilding powerful small language models (100-300M parameters) completely from scratch!
SmolHub is a collection of small but mighty language models implemented entirely from scratch using PyTorch. This repository focuses on creating efficient, lightweight LLMs that can run on modest hardware while still delivering impressive performance. All models are designed to be in the 100-300M parameter range, making them perfect for research, experimentation, and resource-constrained environments.
| Model | Parameters | Architecture | Key Features | Training Dataset |
|---|---|---|---|---|
| SmolMixtral | ~124M (8x12M) | Mixture of Experts | Sparse activation, Flash Attention, SwiGLU | TinyStories (1M texts, 14K steps) |
| SmolTransformer | ~150M | Standard Transformer | Classic attention mechanism, RMSNorm | FineWeb |
| StoryLlama | ~88M | Llama-inspired | RoPE, SwiGLU, MQA/GQA, RMSNorm | TinyStories (4B tokens, 5K steps) |
| StoryMixtral | ~200M | Mixtral variant | Story-focused MoE training | Custom story dataset |
| StoryKimi | ~180M | Custom architecture | Optimized for narrative generation | Story corpus |
pip install torch torchvision transformers datasets wandb tqdm
# Navigate to any model directory
cd SmolMixtral
# Install dependencies
bash install.sh
# Start training
python trainer.py
from inference import generate_text
# Load your trained model
model = load_model("path/to/checkpoint")
# Generate text
output = generate_text(
model=model,
prompt="Once upon a time",
max_length=100,
temperature=0.7
)
print(output)
All models are optimized for:
SmolHub/
├── SmolMixtral/ # Mixture of Experts implementation
├── SmolTransformer/ # Standard transformer architecture
├── StoryLlama/ # Llama-inspired model for stories
├── StoryMixtral/ # Mixtral variant for narratives
├── StoryKimi/ # Custom story-focused architecture
├── smolhub_hub/ # Package management utilities
└── README.md # This file
Each model directory contains:
model.py - Core architecture implementationtrainer.py - Training loop and optimizationinference.py - Text generation utilitiesconfig.py - Model configurationtokenizer.py - Tokenization utilitiesgradio/ - Interactive web demosEach model comes with a Gradio-powered web interface for easy experimentation:
cd SmolMixtral/gradio
python app.py
This repository serves as a research platform for:
Contributions are welcome! Whether you want to:
Please feel free to open issues and pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
"Small models, big possibilities!" 🌟
152 followers · starred Sep 2025
A collection of my from-scratch implementation of various models deployed on HF Spaces
See the codeBuilding powerful small language models (100-300M parameters) completely from scratch!
SmolHub is a collection of small but mighty language models implemented entirely from scratch using PyTorch. This repository focuses on creating efficient, lightweight LLMs that can run on modest hardware while still delivering impressive performance. All models are designed to be in the 100-300M parameter range, making them perfect for research, experimentation, and resource-constrained environments.
| Model | Parameters | Architecture | Key Features | Training Dataset |
|---|---|---|---|---|
| SmolMixtral | ~124M (8x12M) | Mixture of Experts | Sparse activation, Flash Attention, SwiGLU | TinyStories (1M texts, 14K steps) |
| SmolTransformer | ~150M | Standard Transformer | Classic attention mechanism, RMSNorm | FineWeb |
| StoryLlama | ~88M | Llama-inspired | RoPE, SwiGLU, MQA/GQA, RMSNorm | TinyStories (4B tokens, 5K steps) |
| StoryMixtral | ~200M | Mixtral variant | Story-focused MoE training | Custom story dataset |
| StoryKimi | ~180M | Custom architecture | Optimized for narrative generation | Story corpus |
pip install torch torchvision transformers datasets wandb tqdm
# Navigate to any model directory
cd SmolMixtral
# Install dependencies
bash install.sh
# Start training
python trainer.py
from inference import generate_text
# Load your trained model
model = load_model("path/to/checkpoint")
# Generate text
output = generate_text(
model=model,
prompt="Once upon a time",
max_length=100,
temperature=0.7
)
print(output)
All models are optimized for:
SmolHub/
├── SmolMixtral/ # Mixture of Experts implementation
├── SmolTransformer/ # Standard transformer architecture
├── StoryLlama/ # Llama-inspired model for stories
├── StoryMixtral/ # Mixtral variant for narratives
├── StoryKimi/ # Custom story-focused architecture
├── smolhub_hub/ # Package management utilities
└── README.md # This file
Each model directory contains:
model.py - Core architecture implementationtrainer.py - Training loop and optimizationinference.py - Text generation utilitiesconfig.py - Model configurationtokenizer.py - Tokenization utilitiesgradio/ - Interactive web demosEach model comes with a Gradio-powered web interface for easy experimentation:
cd SmolMixtral/gradio
python app.py
This repository serves as a research platform for:
Contributions are welcome! Whether you want to:
Please feel free to open issues and pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
"Small models, big possibilities!" 🌟
152 followers · starred Sep 2025