Skip to main content
The Model class represents a loaded ONNX Runtime GenAI model. It is the primary entry point for loading models and creating other components like tokenizers and generators.

Constructor

Model(string modelPath)

Creates a new Model instance from a model directory.
string
required
Path to the directory containing the model files
Model.cs:14-17

Model(Config config)

Creates a new Model instance from a configuration object.
Config
required
Configuration object with model settings and provider options
Model.cs:19-22

Methods

GetModelType()

Returns the type of the model (e.g., “phi3v”, “phi4mm”, “qwen2_5_vl”). Returns: string - The model type identifier
Model.cs:26-38

Dispose()

Releases the resources used by the model. Models implement IDisposable and should be disposed when no longer needed.

Complete Example

Here’s a complete example of loading a model and using it with a tokenizer and generator:

Example with Custom Configuration

Load a model with custom execution provider settings:
examples/csharp/ModelChat/Program.cs:586-590

See Also