TorchLean API

NN.Examples.Models.Sequence.Transformer

Causal Transformer Text Example #

Runnable torchlean transformer example. It reads a local text corpus, builds a shifted next-byte feature sample, and trains a compact causal Transformer on that real text window.

This command uses the same public causal model family as the GPT examples. Future tokens are masked, so a position cannot read the byte it is being trained to predict.

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

      Short multi-token window for the quick encoder training run.

      Instances For

        Transformer feature width.

        Instances For

          Default number of distinct corpus windows exposed to the trainer.

          Instances For

            Compact byte vocabulary: encode byte id b as b % 4; collisions are intentional.

            Instances For

              Number of attention heads.

              Instances For

                Feed-forward hidden width inside the encoder block.

                Instances For
                  @[reducible, inline]

                  Causal language-model configuration.

                  Instances For
                    @[reducible, inline]

                    Input shape: batched one-hot byte buckets.

                    Instances For
                      @[reducible, inline]

                      Output shape: one next-byte logit row per token position.

                      Instances For

                        Compact causal Transformer used by the runnable text example.

                        Instances For

                          Build a finite next-byte dataset from evenly spaced corpus windows.

                          Instances For

                            Train the causal Transformer with the public Trainer surface.

                            Instances For

                              CLI entrypoint for the causal Transformer text command.

                              Instances For