TorchLean API

NN.Examples.Models.Sequence.Lstm

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

python3 scripts/datasets/download_example_data.py --tiny-shakespeare
lake -R -K cuda=true exe torchlean lstm --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 LSTM cell.

              Instances For
                @[reducible, inline]

                Shared shape/config record for the reusable LSTM-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

                      LSTM 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 LSTM with the public Trainer surface.

                          Instances For

                            CLI entrypoint for the LSTM text command.

                            Instances For