divakar-yadav/transformer-1b-chat
0163
Transformer-1B-Chat
A 1.1 billion parameter decoder-only language model trained entirely from scratch -- pretraining, supervised fine-tuning, and preference alignment -- on 8x NVIDIA H100 GPUs.
Model Details
Architecture Highlights
- RoPE (Rotary Position Embeddings) with theta=10,000
- Grouped Query Attention (GQA) -- 4:1 query-to-KV head ratio for efficient inference
- SwiGLU Feed-Forward Network
- RMSNorm in a pre-norm configuration
- Flash Attention 2 via PyTorch SDPA
Training Pipeline
This model was built through a complete 3-stage training pipeline:
Stage 1: Pretraining
Stage 2: Supervised Fine-Tuning (SFT)
Stage 3: Direct Preference Optimization (DPO)
Hardware
- 8x NVIDIA H100 80GB HBM3
- Distributed Strategy: PyTorch DDP (DistributedDataParallel)
- Communication: NCCL
- Mixed Precision: BF16 autocast
- Total Training Time: ~13.5 hours (all 3 stages)
Chat Template
The model uses a simple chat template with special tokens:
<|user|>
Your message here
<|end|>
<|assistant|>
Model response here
<|end|>Special Tokens
Limitations
- 1.1B parameters -- smaller models have inherent limitations in reasoning depth and factual accuracy
- Trained on English data only
- May generate plausible-sounding but incorrect information
- The DPO alignment is single-epoch; additional iterations could improve quality
- Not safety-tuned beyond what the UltraFeedback dataset provides
Training Code
The full training code is open-sourced alongside this model.
model/
config.py # Model and training hyperparameters
transformer.py # Full transformer implementation from scratch
data.py # Pretraining data pipeline (FineWeb-Edu)
sft_data.py # SFT data pipeline (UltraChat)
dpo_data.py # DPO data pipeline (UltraFeedback)
train.py # Pretraining script (DDP, 8-GPU)
train_sft.py # SFT script
train_dpo.py # DPO script
chat.py # Interactive chat interface
export_to_hf.py # Export to HuggingFace formatLicense
Apache 2.0
