TorchLean API

NN.Examples.Models.Sequence.Mamba

Mamba Text Training #

Runnable byte-level language-model training with the public Mamba API constructor.

The model is trainable end-to-end:

mamba(contextLength, vocabularySize, stateWidth) → linear(stateWidth → vocabularySize)

and the same code runs on CPU or CUDA through TorchLean autograd.

python3 scripts/datasets/download_example_data.py --tiny-shakespeare
lake -R -K cuda=true exe torchlean mamba --device cuda --tiny-shakespeare --steps 1 --windows 1 \
  --generate 0

CLI subcommand name used in terminal banners and error messages.

Instances For

    Default JSON loss-curve path for this command.

    Instances For

      Complete command help, including the text and training flags parsed after runtime selection.

      Instances For

        Training and generation context length for the Mamba text example.

        Instances For

          Byte tokenizer used by this sequence model.

          Instances For

            Number of byte-token classes.

            Instances For

              Width of each token embedding and of the Mamba block's output.

              Instances For

                Byte value used to pad short text windows.

                Instances For
                  @[reducible, inline]

                  Mamba text-model configuration shared by shapes and the constructor.

                  Instances For

                    Embed a byte id in the complete 256-entry byte vocabulary.

                    Instances For
                      @[reducible, inline]

                      Input shape: one sequence of one-hot byte tokens.

                      Instances For
                        @[reducible, inline]

                        Output shape: one vocabulary-logit row per input position.

                        Instances For

                          Public Mamba language-model constructor specialized to the example config.

                          Instances For

                            Command-local training, sampling, and corpus-window controls.

                            Instances For

                              Parse the Mamba command's training and sampling flags.

                              Instances For

                                Convert a token window into the one-hot next-token sample consumed by the Mamba model.

                                Instances For

                                  Build a finite training set from approximately evenly spaced corpus windows.

                                  Instances For

                                    Print the current argmax prediction beside the prompt and shifted target text.

                                    Instances For

                                      Convert a prompt window into the typed one-hot input tensor used during generation.

                                      Instances For

                                        Autoregressively extend a prompt using the trained Mamba parameters.

                                        Instances For

                                          Train the Mamba language model and print before/after prediction and generation reports.

                                          Instances For

                                            CLI entrypoint for the Mamba text command.

                                            Instances For