AriaLM / README.md
krishnah27's picture
Upload README.md with huggingface_hub
bbc981d verified
|
Raw
History Blame Contribute Delete
4.17 kB
---
license: mit
tags:
- music
- music-generation
- midi
- pytorch
- onnx
- custom
datasets:
- drengskapur/midi-classical-music
pipeline_tag: text-generation
---
# Music Generation LLM
A LLaMA-style Transformer model for symbolic music generation, trained on MIDI data.
## Architecture
- **Model**: LLaMA-style Transformer with RoPE, GQA, SwiGLU, RMSNorm
- **Tokenizer**: REMI (REvamped MIDI-derived) β€” SOTA for symbolic music
- **Dataset**: `drengskapur/midi-classical-music` β€” 4,796 classical MIDI files (~50MB)
- **Training**: AdamW + Cosine LR warmup + AMP + Gradient Checkpointing
## Key Features
- **Memory Efficient**: Grouped Query Attention, gradient checkpointing, mixed precision
- **OOM Safe**: Conservative batch sizes, AMP, lazy data loading
- **SOTA Techniques**: RoPE, SwiGLU, RMSNorm, KV-cache, top-p/top-k sampling
## Quick Start
```bash
# Install dependencies
pip install -r requirements.txt
# Train + Generate (default)
python3 -m src.s00_main train+generate
# Train only
python3 -m src.s00_main train --epochs 20 --batch-size 4
# Generate from checkpoint
python3 -m src.s00_main generate --temperature 0.85
```
## Project Structure
```
music_gen_llm/
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ s00_main.py # Entry point β€” orchestrates pipeline
β”‚ β”œβ”€β”€ s01_config.py # All configuration dataclasses
β”‚ β”œβ”€β”€ s02_tokenizer.py # REMI MIDI tokenizer
β”‚ β”œβ”€β”€ s03_dataset.py # Data download + tokenization + DataLoader
β”‚ β”œβ”€β”€ s04_model.py # MusicTransformer (LLaMA-style)
β”‚ β”œβ”€β”€ s05_trainer.py # Training loop with AMP + checkpointing
β”‚ β”œβ”€β”€ s06_generator.py # Autoregressive generation with KV-cache
β”‚ └── s07_utils.py # Logging, memory monitoring, seeding
β”œβ”€β”€ tests/
β”‚ └── test_pipeline.py # 7 unit tests covering all components
β”œβ”€β”€ scripts/
β”‚ β”œβ”€β”€ download_data.sh # Dataset setup
β”‚ β”œβ”€β”€ train.sh # Training launcher
β”‚ └── generate.sh # Generation launcher
β”œβ”€β”€ docs/
β”‚ β”œβ”€β”€ README.md # This file
β”‚ β”œβ”€β”€ HLD.md # High-Level Design
β”‚ β”œβ”€β”€ LLD.md # Low-Level Design
β”‚ └── flow_diagram.drawio # Execution flow diagram
β”œβ”€β”€ data/ # Downloaded MIDI + tokenized cache
β”œβ”€β”€ checkpoints/ # Saved model weights
β”œβ”€β”€ output/ # Generated MIDI files
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ Dockerfile
└── .gitignore
```
## Execution Flow
```
s00_main.py β†’ s01_config.py β†’ s02_tokenizer.py β†’ s03_dataset.py β†’ s04_model.py β†’ s05_trainer.py β†’ s06_generator.py
β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
Entry point Load configs Init tokenizer Download & tokenize Build model Train loop Generate MIDI
```
## Model Specifications
| Parameter | Value |
|---------------|-------------------------------------|
| Dim | 256 |
| Layers | 6 |
| Heads | 8 (Q) / 4 (KV) β€” GQA |
| Hidden (FFN) | 448 (SwiGLU) |
| Max Seq Len | 1024 |
| Vocab Size | 485 (REMI tokens) |
| Parameters | ~5M |
| Precision | BF16/FP16 (AMP) |
## Algorithms Used
1. **Rotary Position Embeddings (RoPE)** β€” Su et al. 2021
2. **Grouped Query Attention (GQA)** β€” Ainslie et al. 2023, from LLaMA-2
3. **SwiGLU Activation** β€” Shazeer 2020, from LLaMA
4. **RMS Layer Normalization** β€” Zhang & Sennrich 2019
5. **REMI Tokenization** β€” Huang & Yang 2020
6. **Cosine Annealing with Warmup** β€” Loshchilov & Hutter 2017
7. **Gradient Checkpointing** β€” Chen et al. 2016
8. **KV-Cache** β€” Standard for efficient autoregressive decoding
9. **Nucleus (Top-p) + Top-k Sampling** β€” Holtzman et al. 2020
10. **Repetition Penalty** β€” Keskar et al. 2019