Text Workflow Configuration #
Display helpers, generation and corpus option records, training-log metadata, and CLI parsers for text workflows.
Causal LM Display Helpers #
Return a fixed-length token window from a text string.
offset = 0 is the model prompt window; offset = 1 is the usual next-token target window for
causal language modeling. Missing tokens are padded with paddingTokenId, matching
Data.CausalLM.oneHotSample.
Example:
-- `offset = 0` is the prompt window and `offset = 1` is its next-token target. That pair is the
-- whole of causal language-model supervision.
def prompt : Tensor Nat [8] :=
text.tokenWindow text.Tokenizer.byte 8 "hello world"
def target : Tensor Nat [8] :=
text.tokenWindow text.Tokenizer.byte 8 "hello world" (offset := 1)
Instances For
Decode a fixed token window extracted by tokenWindow.
Instances For
Escape a short text fragment for one-line terminal output.
Display-only: this does not change tokenizer semantics. Quotes and backslashes use their usual
escapes, common whitespace controls use \\n, \\r, and \\t, and every other ASCII control
character is written as \\xNN. Thus byte-token predictions cannot turn a log into a binary file.
The argument is called fragment rather than text so it cannot shadow the text namespace inside
the body; a local named text makes every text.foo spelling in scope resolve to a field access
instead, which is a genuinely confusing error to read.
Instances For
Sampling Helpers (Top-k) #
Shared text-generation flags for GPT-style examples.
Example:
-- `topK := 1` is greedy decoding; anything larger samples, and `seed` is what makes that sampling
-- reproducible from one run to the next.
def greedy : text.GenerationOptions :=
{ prompt := "Once upon a time"
newTokenCount := 64
temperature := 1.0
topK := 1
repeatPenalty := 0.0
repeatWindow := 0
seed := 0
asciiOnly := true }
- prompt : String
Prompt used to seed autoregressive generation.
- newTokenCount : ℕ
Number of new tokens to append.
- temperature : Float
Softmax temperature. Must be finite and positive for sampling; ignored by greedy decoding.
- topK : ℕ
Top-k cutoff.
0samples the full vocabulary;1gives greedy decoding. - repeatPenalty : Float
Finite nonnegative penalty subtracted for repeated recent tokens.
0disables it. - repeatWindow : ℕ
Number of recent tokens considered by the repeat penalty.
0disables the window. - seed : ℕ
Deterministic RNG seed for sampling.
- asciiOnly : Bool
Restrict generated ids to a model-specific ASCII allow-list.
Instances For
Instances For
Parse --ascii-only, accepting either a bare flag or a true/false value.
Internal on purpose: GenerationOptions.parse is the entry point, and parsing this flag on its own
would let a command accept it without recording it in the training log.
Instances For
Parse the generation flags shared by GPT-style examples.
The model command supplies its concrete default prompt and sampling policy. This parser owns only the stable generation flags and returns arguments belonging to the caller.
Instances For
Text Workflow Option Records #
Required text-corpus path plus the explicit small-data option used by local corpus trainers.
- dataFile : System.FilePath
UTF-8 or raw-byte corpus path selected by
--data-file. - allowSmallData : Bool
Allow local runs below the normal corpus-size floor.
Instances For
Instances For
Optional text-corpus path selected by --data-file, with caller-supplied default.
- path : System.FilePath
Local text corpus path.
Instances For
Instances For
Parse an optional --data-file flag using the supplied default path.
Instances For
Optional second corpus pass after the main training run.
- finetuneFile? : Option System.FilePath
Optional corpus used for a second fine-tuning pass.
- finetuneSteps : ℕ
Number of optimizer steps used on that second corpus when present.
Instances For
Instances For
Parse the optional --finetune-file / --finetune-steps pair.
The caller supplies the default step count so commands can reuse their main training-step default.
Instances For
Optional GPT-2 BPE tokenizer bundle plus an optional bounded-text cap.
- vocabularyFile? : Option System.FilePath
Optional GPT-2
vocab.jsonpath. Must be paired withmergesFile?. - mergesFile? : Option System.FilePath
Optional GPT-2
merges.txtpath. Must be paired withvocabularyFile?. Optional text-character cap for bounded local BPE runs.
Instances For
Instances For
Parse the optional GPT-2 BPE tokenizer bundle.
--bpe-vocab and --bpe-merges must appear together; --max-chars is independent.
Instances For
Shared terminal-REPL toggle used by interactive text examples.
- interactive : Bool
Keep the trained model alive and read prompts from stdin.
Instances For
Instances For
Parse the shared --interactive flag used by text examples with a terminal prompt loop.
Instances For
Instances For
Parse the shared --prompt / --generate flags.
Instances For
Text TrainLog Notes #
TrainLog note fields for generation-capable text commands.
The stable generation surface is prompt, continuation length, temperature/top-k, repetition
control, RNG seed, and ASCII-only filtering. Model commands can prepend dataset or architecture
notes through extra.
Internal on purpose: these note arrays only make sense inside the Log.write* wrappers below,
which pair them with the matching loss comparison.
Instances For
Training logs #
text.Log is the whole logging surface for text commands. It lives in its own namespace so that
text. completion shows tokenizers, sampling, and option parsers rather than a pair of long
write*TrainLog names.
Write a before/after loss log for a generation-capable text training command.
Instances For
Write a before/after loss log for a prompt-based text training command.
Instances For
Text Training Option Combinators #
Number of corpus windows used by a finite or cyclic text-training command.
- windowCount : ℕ
Number of windows available to the training sampler.
Instances For
Optional model-checkpoint paths for text training and generation.
- loadCheckpoint? : Option System.FilePath
Checkpoint loaded before training or generation.
- saveCheckpoint? : Option System.FilePath
Checkpoint written after training.
Instances For
Instances For
Parse --load-checkpoint and --save-checkpoint.