Abstract
Scaling small language models effectively requires architectures that optimize hardware constraints. Yeti Nepal v1 is a hybrid 483-million parameter model that integrates Mamba-2 SSMs for long-context linear scaling, Grouped-Query Attention (GQA) for optimized memory retrieval, and a 2-Expert Mixture-of-Experts (MoE) routing system. Designed specifically for training on a free-tier Google Colab T4 GPU (16 GB VRAM), this project demonstrates cost-efficient pretraining, instruction tuning, and DPO alignment pipelines.
π¦ Download Project Files & Model
Get the complete source code, configurations, training pipelines, and export scripts for Yeti Nepal v1 (approx. 41 KB).
1. Architecture Specification
Yeti Nepal v1 is designed with a hybrid topology that distributes sequence processing between state-space modeling and attention-based blocks. Every 4th layer uses Grouped-Query Attention (GQA) to maintain key-value cache efficiency, while the rest are Mamba-2 State Space Model (SSM) blocks. Additionally, a sparse 2-expert Mixture-of-Experts (MoE) layer replaces standard feed-forward networks, optimizing active parameter capacity at run-time.
| Component / Metric | Specification Details |
|---|---|
| Total Layers | 24 (18 Mamba-2 SSM + 6 GQA, every 4th layer) |
| Hidden Size | 1024 |
| SSM State Dimension | 64 |
| Attention Heads | 8 Query (Q) / 2 Key-Value (KV) β GQA 4:1 ratio |
| Mixture-of-Experts (MoE) | 2 SwiGLU Experts (Top-1 inference / Top-2 training) |
| FFN Width | 2048 |
| Vocabulary Size | 32,000 (LLaMA-compatible Byte Pair Encoding) |
| Max Sequence Length | 4096 tokens |
| Total Parameters | ~483 Million |
2. Project Structure
The codebase is highly modular, written in pure PyTorch to avoid external compiled SSM dependencies while maintaining compatibility with hardware accelerators:
yeti_nepal_v1/
βββ config/
β βββ model_config.py # Architecture hyperparams + presets
β βββ train_config.py # Phase 1/2/3 training hyperparams
βββ model/
β βββ mamba_block.py # Mamba-2 SSM layer (pure PyTorch)
β βββ attention_block.py # GQA + RoPE (FlashAttn via SDPA)
β βββ moe_layer.py # 2-expert MoE + Top-1/Top-2 router
β βββ yeti_core.py # Full model + causal LM head
βββ data/
β βββ processor.py # Text cleaning, tokenisation, CoT formatting
β βββ loader.py # Streaming DataLoaders for all 3 phases
βββ train/
β βββ loss_functions.py # CE + MoE load-balance + router z-loss
β βββ trainer.py # Phase 1/2/3 training loops + DPO
βββ evaluate.py # Perplexity, accuracy, generation eval
βββ export_gguf.py # Export β safetensors β GGUF (llama.cpp)
βββ run_colab.py # Main entry: paste each cell into Colab
βββ requirements.txt # Dependency manifest
3. Training & Alignment Pipeline
Training Yeti Nepal v1 proceeds through three distinct stages, carefully structured to optimize learning rate schedules, dataset sequences, and loss formulations:
| Phase | Dataset Source | Tokens / Pairs | Primary Objective |
|---|---|---|---|
| 1 β Pretraining | FineWeb-Edu | 20 Billion Tokens | Acquire base factual knowledge & grammar |
| 2 β Supervised Fine-Tuning | OpenHermes-2.5 + Dolphin CoT | 5 Billion Tokens | Instruction following & multi-step reasoning |
| 3 β Direct Preference Optimization | UltraFeedback | 20K Preference Pairs | Safety alignment & human preference matching |
Checkpointing and Resuming
Due to the risk of connection drops in free-tier Google Colab environments, checkpoints are serialized periodically. You can resume pretraining seamlessly with:
RESUME_FROM = "./checkpoints/phase1/ckpt_step500.pt"
model = run_phase1(model, pretrain_loader, train_cfg.phase1, DEVICE, resume_from=RESUME_FROM)
4. Evaluation Metrics & Targets
Evaluation is performed using `evaluate.py`, assessing both perplexity and targeted reasoning capabilities:
python evaluate.py --checkpoint ./checkpoints/phase2_final_step1000.pt
Key benchmarks and targets for the 500M parameter model:
- GSM8K: β₯ 70% accuracy using chain-of-thought extraction.
- TruthfulQA: Marked improvement in factual truthfulness metrics over pretraining baseline.
- Perplexity: < 20 on held-out FineWeb validation subsets.
5. Local Inference and GGUF Export
To run the model on standard CPU and mobile devices, it can be exported to GGUF format for use with
llama.cpp:
python export_gguf.py \
--checkpoint ./checkpoints/phase2_final_step1000.pt \
--output_dir ./gguf_export \
--quant Q4_K_M
Once exported, inference is executed locally using the following CLI call:
./llama-cli -m ./gguf_export/yeti-Q4_K_M.gguf -n 256 \
-p "<|user|>\nWhat is machine learning?\n<|assistant|>\n"
6. Development Roadmap
The project follows a progressive scaling strategy to validate components before launching full training runs:
- June 2026: 50M parameter debug build validation β
- August 2026: 120M scale benchmark run
- October 2026: 300M scale pretraining stage
- December 2026: 500M full model launch
7. Key Design Decisions
- Zero-Dependency SSM: Built a pure PyTorch State Space Model scanning kernel. It
falls back gracefully if the official compiled
mamba-ssmpackage is unavailable. - Progressive Scaling Validation: Always run the pipeline at a 20M parameter "debug" scale first to guarantee mathematical and memory correctness before launching full pretraining.
- Optional Unsloth Accel: Designed the model class to integrate with Unsloth if present, enabling faster training without locking out other GPU environments.