Melody Generator
AI models for generating original musical melodies, trained on MIDI data across multiple genres. These models power melodygenerator.fun.
Models
| Version | Architecture | Genre | Vocab Size | Training Data | Format |
|---|---|---|---|---|---|
| v2 | LSTM (3-layer) | R&B / 90s Hip Hop | 59 | 24 songs | PyTorch + Keras |
| v3 | LSTM (3-layer) | Dance | 635 | ~200 songs | PyTorch + Keras |
| v4 | LSTM (3-layer) | Jazz | 635 | ~120 songs | PyTorch + Keras |
| v5 | LSTM (3-layer) | Various | 629 | 275 songs | PyTorch + Keras |
| v6 | LSTM + Embeddings | Various | 362 | 275 songs | PyTorch |
| v7 | Transformer | Various | 512 | 275 songs | PyTorch |
| v8 | Transformer | Various + Classical | 1024 | 275 songs + MAESTRO | PyTorch |
Architecture Details
LSTM Models (v2-v6)
- 3-layer LSTM with configurable hidden sizes (256/512)
- v2-v5: Legacy pitch-string tokenization
- v6: REMI tokenization with learned embeddings (128-dim) and optional attention
Transformer Models (v7-v8)
- 8 layers, 8 attention heads, 512-dim embeddings, 2048-dim feed-forward
- RoPE (Rotary Position Embeddings)
- RMSNorm (Root Mean Square Layer Normalization)
- SwiGLU activation in feed-forward layers
- KV-cache support for efficient autoregressive generation
- REMI tokenization with BPE compression (v7: 512 vocab, v8: 1024 vocab)
File Structure
Each version directory contains:
model.ptโ PyTorch model weightsmetadata.jsonโ Model configuration and vocabulary infoseeds.jsonโ Pre-computed seed sequences for generationtokenizer/tokenizer.jsonโ MidiTok REMI tokenizer (v6-v8 only)model.h5/model.h5_data.pklโ Legacy Keras weights (v2-v5 only)
Usage
import torch
# Load a model
checkpoint = torch.load("v8/model.pt", map_location="cpu")
For full inference with generation, MIDI conversion, and audio rendering, see the melodygenerator repository.
Links
- Live demo: melodygenerator.fun
- Source code: github.com/niallone/melodygenerator