Views
No views yet
generated_data/ directory, these examples showcase the model's capabilities in text generation and understanding.
epochs: Number of training epochs (default: 4)block_size: Maximum sequence length (default: 1024)batch_size: Training batch size (default: 16)embeddings_dims: Model embedding dimensions (default: 512)no_of_heads: Number of attention heads (default: 8)no_of_decoder_layers: Number of decoder layers (default: 8)attn_dropout: Attention dropout rate (default: 0.1)dropout: General dropout rate (default: 0.1)experts: Number of MoE experts (default: 8)top_experts: Number of experts to route to (default: 2)noisy_topk: Use noisy top-k routing (default: False)max_lr: Maximum learning rate (default: 6e-4)weight_decay_optim: Weight decay for optimizer (default: 0.01)beta_1: Beta1 for optimizer (default: 0.9)beta_2: Beta2 for optimizer (default: 0.95)eps: Epsilon for optimizer (default: 1e-8)clip: Gradient clipping value (default: 1.0)device: Device to use (default: 'cuda:9')use_checkpointing: Use gradient checkpointing (default: False)use_liger: Use Liger kernels for optimization (default: True)use_flash_attention: Use Flash Attention (default: True)use_compile: Use torch.compile (default: True)vocab_size: Vocabulary size (default: based on tokenizer + 768)val_epochs: Validation frequency (default: 2)1chmod +x install.sh
2./install.shTOKEN = 'your_token_here'checkpoints/ directory1# Using the Gradio web interface
2cd gradio
3python app.py
4
5# Or use in your own code
6python inference.pypython trainer.py1# Train with larger model (modify config.py)
2python trainer.py
3
4# Train with different dataset (modify data.py)
5python trainer.py1# 2 GPUs
2torchrun --nproc_per_node=2 trainer.py
3
4# 4 GPUs
5torchrun --nproc_per_node=4 trainer.py
6
7# 8 GPUs
8torchrun --nproc_per_node=8 trainer.pyconfig.py to use the Gradio interface. Moreover, set your token as follows: export HF_TOKEN=<TOKEN_HERE>1# Run the Gradio app
2cd gradio
3python app.py
4
5# With custom checkpoint (edit app.py to point to your checkpoint)
6cd gradio
7python app.pySmolMixtral/
├── config.py # Model configuration and hyperparameters
├── model.py # Model architecture (Mixtral, MoE, Attention, etc.)
├── data.py # Data loading and preparation
├── inference.py # Inference functions and text generation
├── trainer.py # Main training loop with DDP support
├── install.sh # Setup script
├── requirements.txt # Python dependencies
├── model_summary.py # Model architecture summary
├── gradio/
│ └── app.py # Gradio web interface
├── checkpoints/ # Model checkpoints
├── generated_data/ # Generated text outputs
├── images/ # Project images
└── old/ # Original filesconfig.py:1@dataclass
2class ModelArgs:
3 epochs = 4
4 block_size = 1024
5 batch_size = 16
6 embeddings_dims = 512
7 # ... other parametersdata.py to use different datasets:1# TinyStories (default)
2tinystories = True
3fw = False
4
5# FineWeb
6tinystories = False
7fw = Trueuse_liger = True for optimized operationsuse_flash_attention = True for memory efficiencyuse_checkpointing = True for memory-constrained setups1# Make sure you have accepted the Llama-2 license and have a valid token
2# Visit: https://huggingface.co/meta-llama/Llama-2-7b-hf
3# Then set your token in config.py1# Reduce batch size and enable checkpointing in config.py
2batch_size = 8
3use_checkpointing = True1# Enable optimizations in config.py
2use_liger = True
3use_flash_attention = True
4use_compile = True