GPT class
Properties
- config → GPTConfig
-
final
- embedDrop → Dropout
-
final
- encoder → TransformerEncoder
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- posEmb → LearnedPositionalEmbedding
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- tokenEmb → Embedding
-
final
- training ↔ bool
-
Whether this module is in training mode. Layers that behave
differently between training and inference (e.g.
Dropout) read this flag in theircallmethod. Defaults to training mode.getter/setter pairinherited - untiedHead → Linear?
-
Only populated when
config.tieWeights == false. When tied, the output head is computed inline ash @ tokenEmb.weight.T.final
Methods
-
call(
Tensor tokens) → Tensor -
Forward pass.
tokensis either 1D[seqLen](single sequence, output[seqLen, vocabSize]) or 2D[batch, seqLen](batched, output[batch, seqLen, vocabSize]). A causal mask is applied inside the encoder. KV caching is not used on this path. -
eval(
) → void -
Put this module (and any registered submodules) into evaluation mode.
inherited
-
generate(
List< double> prompt, {required int maxNewTokens, double temperature = 1.0, int? topK, Random? rng, bool useCache = true}) → List<double> -
Autoregressive sampling. Returns the full sequence
prompt + generated tokensas a Dart list of doubles (matches the float32 index convention used everywhere else). The model is put into eval mode for the duration of the call and restored on exit. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
parameters(
) → List< Tensor> -
Trainable tensors owned by this module (and its submodules).
override
-
submodules(
) → List< Module> -
Submodules owned by this module. Subclasses that compose other
modules should override this so
train()/eval()propagate. Default: empty.override -
toString(
) → String -
A string representation of this object.
inherited
-
train(
) → void -
Put this module (and any registered submodules) into training mode.
inherited
-
zeroGrad(
) → void -
Zero every parameter's gradient. Safe to call before each
backward.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited