ILanguageModel<T>

Interfaces · AiDotNet.Interfaces

Marker interface for models with a language-model-shaped inference contract: token-tensor input [B, T] → next-token-logits output [B, T, V]. Implemented by Transformer and any custom transformer / decoder-only / encoder-decoder model that follows the same shape.

Known implementations: NeuralNetworkCausalLanguageModel<T>, OnnxFullModelAdapter<T>, Transformer<T>

How It Works

Introduced to replace the Tensor-shape heuristic in AiModelResultTransformerExtensions: extension methods now gate on this interface so custom transformer subclasses can plug in without needing to derive from the concrete Transformer type. Reference impls (HF generate, llama.cpp) all encode this contract via ad-hoc type checks; expressing it as an interface is beyond industry standard.

Methods

Method Summary
Tensor<T> ForwardLogits(Tensor<T> tokenIds) Runs one forward pass through the LM and returns next-token logits.