LSTM Text Example #
Runnable torchlean lstm example. It reads a local text corpus, takes a short byte window from the
front, and trains an LSTM plus a time-distributed linear head.
The model constructor is exposed as TorchLean.nn.models.LSTMWithLinearHead. The local code names the
architecture, builds the text dataset, and trains through the public Trainer surface.
Scope #
This is the gated recurrent baseline. It keeps the text window short so the example stays focused on
the LSTM cell, the time-distributed head, and the public Trainer API. For generation and
longer-context language-model behavior, use one of:
torchlean chargpt(Karpathy-style, single-file char-level GPT),torchlean gpt2(byte-level GPT-2-style model + save/reload),torchlean text_gpt2(CUDA corpus trainer).
python3 scripts/datasets/download_example_data.py --tiny-shakespeare
lake build -R -K cuda=true && lake exe torchlean lstm --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
Shared shape/config record for the reusable LSTM-with-head constructor.
Instances For
Input shape: one token vector per timestep.
Instances For
Output shape: one prediction row per timestep.
Instances For
LSTM followed by a time-distributed linear output head.
Instances For
Build one next-token training sample from the loaded corpus prefix.
Instances For
Train the LSTM with the public Trainer surface.