OnnxFullModelAdapter<T>
Models & Types · AiDotNet.ModelLoading.Pretrained
Adapts an OnnxModel (an IOnnxModel that runs an ONNX graph through the
ONNX runtime) to the IFullModel, ILanguageModel, and
IIncrementalCausalLanguageModel contracts so ConfigureModel(PretrainedSource.Onnx(path))
supports full-context and KV-cached causal language model generation behind the AiModelResult facade.
Implements: IFullModel<T, Tensor<T>, Tensor<T>>, IIncrementalCausalLanguageModel<T>, ILanguageModel<T>
Constructors
| Constructor | Summary |
|---|---|
OnnxFullModelAdapter(byte[] onnxBytes, OnnxModelOptions options) |
Creates an adapter over the ONNX graph in onnxBytes. |
Properties
| Property | Summary |
|---|---|
ILossFunction<T> DefaultLossFunction { get; } |
|
OnnxModel<T> Model { get; } |
The wrapped ONNX runtime model. |
bool SupportsParameterInitialization { get; } |
Always false: a frozen ONNX graph cannot be initialized from a flat vector. |
int VocabularySize { get; } |
|
long ParameterCount { get; } |
Always zero: the graph owns its weights, this adapter does not. |
Methods
| Method | Summary |
|---|---|
Dictionary<string, T> GetFeatureImportance() |
|
IEnumerable<int> GetActiveFeatureIndices() |
|
IFullModel<T, Tensor<T>, Tensor<T>> Clone() |
|
IFullModel<T, Tensor<T>, Tensor<T>> DeepCopy() |
|
IFullModel<T, Tensor<T>, Tensor<T>> WithParameters(Vector<T> parameters) |
|
ModelMetadata<T> GetModelMetadata() |
|
OnnxFullModelAdapter<T> FromFile(string path, OnnxModelOptions options) |
Creates an adapter over the ONNX graph at path. |
Tensor<T> ForwardLogits(Tensor<T> tokenIds) |
|
Tensor<T> Predict(Tensor<T> input) |
|
Vector<T> AppendToken(int tokenId) |
|
Vector<T> GetParameters() |
An empty vector, matching ParameterCount. |
Vector<T> NextTokenLogits(IReadOnlyList<int> tokenIds) |
|
Vector<T> SanitizeParameters(Vector<T> parameters) |
|
Vector<T> StartSequence(IReadOnlyList<int> promptTokenIds) |
|
bool IsFeatureUsed(int featureIndex) |
|
byte[] Serialize() |
|
void Deserialize(byte[] data) |
|
void Dispose() |
|
void LoadModel(string filePath) |
|
void LoadState(Stream stream) |
|
void ResetCache() |
|
void SaveModel(string filePath) |
|
void SaveState(Stream stream) |
|
void SetActiveFeatureIndices(IEnumerable<int> featureIndices) |
|
void SetParameters(Vector<T> parameters) |
Writes a parameter vector into this adapter. |
void Train(Tensor<T> input, Tensor<T> expectedOutput) |