Downloads · 30 days
0
geeteshcodes/sllm
sllm is a text generation model from geeteshcodes. Use it when you need the model to write or continue text. The card lists the license as mit.
A GPT-style decoder-only transformer built and trained from scratch in PyTorch. Two model sizes are available (100M and 150M parameters), designed to fit on consumer GPUs as small as a 4 GB VRAM card (e.g. RTX 3050).
Downloads · 30 days
0
Access
Public
Updated Jun 3, 2026
Repo size
—
Likes
1
Public
Click a slice to open those files.
.json6.6 MB · 97%
From the Hugging Face model README
A GPT-style decoder-only transformer built and trained from scratch in PyTorch. Two model sizes are available (100M and 150M parameters), designed to fit on consumer GPUs as small as a 4 GB VRAM card (e.g. RTX 3050).
F.scaled_dot_product_attention (O(T²) memory avoided)--resume, --extra_steps)finetune/sllm/
├── model/ # Model architecture
│ ├── config.py # ModelConfig dataclass (SLLM_100M, SLLM_150M presets)
│ ├── model.py # SLLM — full model assembly, weight init, gradient checkpointing
│ ├── block.py # TransformerBlock (pre-norm, residual)
│ ├── attention.py # Causal multi-head self-attention + RoPE
│ ├── mlp.py # SwiGLU feed-forward network
│ ├── norm.py # RMSNorm
│ └── rope.py # Rotary Position Embeddings
│
├── tokenizer/ # Custom BPE tokenizer
│ ├── normalizer.py # HTML stripping, unicode NFC, whitespace cleanup
│ ├── pretokenizer.py # Regex pre-tokenizer (code-aware, contraction-aware)
│ ├── bpe.py # BPE model config with byte fallback (32k vocab)
│ ├── traintokenizer.py # Train on FineWeb-Edu stream
│ ├── post_processor.py # Append <|endoftext|> to every sequence
│ ├── wrap_tokenizer.py # Wrap into PreTrainedTokenizerFast
│ └── tokenize_dataset.py # Pack tokens into flat binary .bin shards
│
├── data/
│ └── dataloader.py # Memory-mapped shard dataloader
│
├── finetune/ # Supervised fine-tuning (SFT) pipeline
│ ├── prepare_data.py # Prepare chat data
│ ├── sft_train.py # SFT training loop
│ ├── sft_dataset.py # Chat dataset
│ └── chat.py # Interactive chat with the fine-tuned model
│
├── train.py # Pre-training loop
├── plot_training.py # Training dashboard (static + live mode)
├── requirements.txt
├── model_explained.md # Deep-dive into every model component
└── tokenizer_walkthrough.md # Tokenizer design and pipeline walkthrough
| Config | d_model | Heads | Layers | Parameters |
|---|---|---|---|---|
SLLM_100M | 768 | 12 | 12 | ~109.5M |
SLLM_150M | 1024 | 16 | 9 | ~148.4M |
Both configs use:
round_up_256(⌊2/3 × 4 × d_model⌋)Requires: Python 3.10+, PyTorch 2.3+, CUDA-capable GPU (bf16 recommended)
# Create and activate a conda environment
conda create -n pytorch python=3.11
conda activate pytorch
# Install dependencies
pip install -r requirements.txt
python train.py \
--config 150M \
--data_dir tokenizer/data \
--batch_size 2 \
--grad_accum 16 \
--grad_checkpoint \
--dtype bf16 \
--max_steps 5000 \
--run_dir runs/sllm_150m \
--log_every 10 \
--save_every 500 \
--val_every 500 \
--warmup_steps 200
python train.py \
--resume \
--run_dir runs/sllm_150m \
--extra_steps 5000 \
--data_dir tokenizer/data \
--batch_size 2 \
--grad_accum 16 \
--grad_checkpoint \
--dtype bf16
| Flag | Default | Description |
|---|---|---|
--config | 100M | Model size (100M or 150M) |
--batch_size | 4 | Per-device micro-batch size |
--grad_accum | 8 | Gradient accumulation steps |
--max_steps | unlimited | Absolute step target |
--extra_steps | — | Run N more steps from current checkpoint |
--resume | — | Resume from latest checkpoint in --run_dir |
--grad_checkpoint | — | Enable gradient checkpointing (saves VRAM) |
--dtype | bf16 | Mixed precision dtype (fp32, fp16, bf16) |
--synthetic | — | Use random data (for testing without real shards) |
Visualize training metrics in a dark-mode 6-panel dashboard:
# Static plot
python plot_training.py --run_dir runs/sllm_150m
# Live mode — refresh every 30 seconds while training
python plot_training.py --run_dir runs/sllm_150m --live --interval 30
# Compare two runs
python plot_training.py --run_dir runs/run_a runs/run_b
# Save to file
python plot_training.py --run_dir runs/sllm_150m --save dashboard.png
Dashboard panels: Training Loss (raw + EMA) · Validation Loss · Learning Rate · Tokens/sec · VRAM usage · Gradient norm
After pre-training, you can fine-tune with supervised instruction data:
# 1. Prepare chat data
python finetune/prepare_data.py
# 2. Fine-tune
python finetune/sft_train.py \
--base_ckpt runs/sllm_150m/ckpt_0011500.pt \
--run_dir runs/sllm_150m_chat \
--max_steps 2500 \
--batch_size 4 \
--grad_accum 8 \
--grad_checkpoint
# 3. Chat interactively
python finetune/chat.py --run_dir runs/sllm_150m_chat
A custom BPE tokenizer trained on the educational subset of FineWeb-Edu:
snake_case, operators (==, ->, **), and indentationdon't, I've, they're are split correctlyPreTrainedTokenizerFast (HuggingFace-compatible)Training data is packed into flat binary .bin shards (np.uint16, 100M tokens each) for fast memory-mapped loading.
See tokenizer_walkthrough.md for a full pipeline deep-dive.
See model_explained.md for a plain-language walkthrough of every model component, including:
<run_dir>/ckpt_NNNNNNN.pt every --save_every steps and on clean exit (Ctrl+C)<run_dir>/train_log.jsonl (one JSON line per log step)torch>=2.3.0
datasets>=2.14.0 # HuggingFace datasets (streaming)
tokenizers>=0.15.0 # Fast BPE tokenizer
transformers>=4.40.0 # PreTrainedTokenizerFast
numpy>=1.26.0
tqdm
matplotlib
This project is released for educational purposes.