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.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

              Hidden state width of the vanilla recurrent cell.

              Instances For
                @[reducible, inline]

                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 a finite next-token dataset from evenly spaced corpus windows.

                        Instances For

                          Train the vanilla RNN with the public Trainer surface.

                          Instances For

                            CLI entrypoint for the vanilla RNN text command.

                            Instances For