TorchLean API

NN.Examples.Models.Sequence.Rnn

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.RNNWithLinearHead. 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 build -R -K cuda=true && lake exe torchlean rnn --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

          Hidden state width of the vanilla recurrent cell.

          Instances For

            Shared shape/config record for the reusable RNN-with-head constructor.

            Instances For
              @[reducible, inline]

              Input shape: one token vector per timestep.

              Instances For
                @[reducible, inline]

                Output shape: one prediction row per timestep.

                Instances For

                  Vanilla RNN 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 vanilla RNN with the public Trainer surface.

                      Instances For

                        CLI entrypoint for the vanilla RNN text command.

                        Instances For