A tiny character-level decoder-only Transformer (no cross-attention) trained on Eminem songs using the kaggle dataset.
- Generate rap lyrics based on user specified token count
- Configurable maximum number of generated tokens
backend/
- train.py – trains the Transformer model
- inference.py – loads the trained model and runs inference
- model_weights.pth – pretrained model weights
- main.py - starts the backend server and exposes the api
frontend/
- React application
- Python 3.8 or newer
- PyTorch
- Fast API
- Node.js
- React
git clone https://github.com/nithinbharathi/rapgpt.git
cd rapgpt
cd backend
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python main.pycd frontend
npm install
npm run devThe repository already includes backend/model_weights.pth, so you can run the application immediately without training the model.
If you'd like to train the model yourself,
cd backend
python train.pyThe trained model will be saved as
model_weights.pth
which is automatically loaded by the backend during inference.
This application is deployed on a serverless platform. If the app has not received any requests for a while, the first request may take a little longer to process due to server initialization (cold start).
Subsequent requests will be significantly faster once the server is active.
If you experience a longer-than-usual wait on your first request, please wait a few seconds and try again — the application is warming up.
Inspired by Andrej Karpathy's nanoGPT and related educational resources.

