Shared Simple Sequence Text Runner #
This file is the shared runner for the small RNN/LSTM/Transformer text smoke tests.
Both examples have the same public shape:
- read a real text corpus, usually Tiny Shakespeare;
- turn one short byte window into a supervised sequence sample;
- train a reusable API model for a few steps; and
- optionally write a before/after loss log.
The actual architecture still lives in the calling file. This helper owns only the runnable example
infrastructure, so readers can compare Rnn.lean, Lstm.lean, and Transformer.lean without reading
three copies of the same runtime wrapper.
Configuration for a small real-text sequence training example.
- exeName : String
CLI subcommand name, e.g.
torchlean rnn. - defaultLogJson : System.FilePath
Default JSON log path.
- modelName : String
Human-readable model name used in banners.
- logTitle : String
Human-readable training log title.
- mkModel : API.nn.M (API.nn.Sequential σ τ)
Construct the model under test.
- mkSample {α : Type} [API.Semantics.Scalar α] [API.Runtime.Scalar α] : String → API.sample.Supervised α σ τ
Build the supervised sample from corpus text.
- lr : Float
SGD learning rate. Kept per-example because attention/recurrent examples have different scale.
Instances For
Train one small sequence model for steps optimizer updates.
This is intentionally a smoke-scale routine: one fixed corpus-derived sample, one optimizer, and a before/after loss. More realistic streaming/minibatch examples live elsewhere; this helper is for architecture sanity checks that should run quickly on CPU or CUDA.
Instances For
Shared main implementation for the small RNN/LSTM text examples.