karpathy/char-rnn ? reverse-engineered prompt

Reverse engineered prompt

Build me a small Lua Torch app that trains a character level text generator from a single input text file, then samples new text from the saved model.

I want it to support plain RNN, LSTM, and GRU, with multi layer training, checkpoints, and a separate sampling script. It should work on CPU by default, but also use GPU if available, and let me switch between them with a simple flag. The training script should read data from a folder under data, preprocess it the first time, split it into train and validation data, and save checkpoints with the validation loss in the filename so I can pick the best one later.

Please also include a way to inspect a checkpoint and convert it between GPU and CPU if needed. If you need to look up current Torch or LuaRocks docs online, feel free to do that. Keep the interface simple, with helpful command line flags for things like model type, hidden size, number of layers, sequence length, dropout, and temperature for sampling.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab