RNN Text Example #
Runnable torchlean rnn example. It reads a local text corpus, takes a short byte window from the
front, and trains a vanilla RNN plus a time-distributed linear head.
The model constructor is exposed as TorchLean.nn.models.rnn. The local code names the
architecture, builds the text dataset, and trains through the public Trainer surface.
Scope #
This is the plain recurrent baseline. It keeps the text window short so the example stays focused on
the recurrent cell, the time-distributed head, and the public Trainer API. For generation and
longer contexts, use chargpt, gpt2, or text_gpt2.
python3 scripts/datasets/download_example_data.py --tiny-shakespeare
lake -R -K cuda=true exe torchlean rnn --device cuda --tiny-shakespeare --steps 1
CLI subcommand name used in terminal banners and error messages.
Instances For
Default JSON loss-curve path for this command.
Instances For
Number of byte-level timesteps in the training window.
Instances For
Tiny one-hot token width for the example dataset.
Instances For
Default number of distinct corpus windows exposed to the trainer.
Instances For
Compact byte vocabulary: encode byte id b as b % 8; collisions are intentional.
Instances For
Shared shape/config record for the reusable RNN-with-head constructor.
Instances For
Input shape: one token vector per timestep.
Instances For
Output shape: one prediction row per timestep.
Instances For
Vanilla RNN followed by a time-distributed linear output head.
Instances For
Build a finite next-token dataset from evenly spaced corpus windows.
Instances For
Train the vanilla RNN with the public Trainer surface.