Interface IModelRegistry<T, TInput, TOutput>
- Namespace
- AiDotNet.Interfaces
- Assembly
- AiDotNet.dll
Defines the contract for model registry systems that manage trained model storage and versioning.
public interface IModelRegistry<T, TInput, TOutput>
Type Parameters
TThe numeric data type used for calculations (e.g., float, double).
TInputTOutput
Remarks
A model registry serves as a centralized repository for trained models, managing their lifecycle from development through production deployment.
For Beginners: Think of a model registry like a library for your trained models. Just like a library catalogs books and tracks which are checked out, a model registry:
- Stores all your trained models in one place
- Tracks different versions of the same model
- Records which models are being used in production
- Helps you find and retrieve the right model when you need it
Key features include:
- Model versioning (keeping track of model evolution)
- Metadata tracking (when trained, by whom, with what data)
- Stage management (development, staging, production)
- Model comparison and lineage tracking
Why model registries matter:
- Prevents losing track of trained models
- Enables rollback to previous versions if needed
- Provides audit trail for compliance
- Facilitates collaboration between team members
- Simplifies deployment process
Methods
ArchiveModel(string, int)
Archives a model version.
void ArchiveModel(string modelName, int version)
Parameters
Remarks
For Beginners: Archiving makes a model read-only and marks it as no longer active, but keeps it available for reference.
AttachModelCard(string, int, ModelCard)
Attaches a Model Card to a registered model version.
void AttachModelCard(string modelName, int version, ModelCard modelCard)
Parameters
modelNamestringThe name of the model.
versionintThe version to attach the Model Card to.
modelCardModelCardThe Model Card to attach.
Remarks
For Beginners: A Model Card is like a nutrition label for AI models. It documents the model's intended use, limitations, performance metrics, and ethical considerations. Attaching a Model Card helps maintain transparency and responsible AI practices.
CompareModels(string, int, int)
Compares two model versions.
ModelComparison<T> CompareModels(string modelName, int version1, int version2)
Parameters
modelNamestringThe name of the model.
version1intFirst version to compare.
version2intSecond version to compare.
Returns
- ModelComparison<T>
Comparison results showing differences.
Remarks
For Beginners: This shows you the differences between two versions of a model, helping you understand what changed and which performs better.
CreateModelVersion<TMetadata>(string, IModel<TInput, TOutput, TMetadata>, ModelMetadata<T>, string?)
Creates a new version of an existing model.
int CreateModelVersion<TMetadata>(string modelName, IModel<TInput, TOutput, TMetadata> model, ModelMetadata<T> metadata, string? description = null) where TMetadata : class
Parameters
modelNamestringThe name of the model to version.
modelIModel<TInput, TOutput, TMetadata>The new version of the model.
metadataModelMetadata<T>Metadata for this version.
descriptionstringDescription of changes in this version.
Returns
- int
The version number assigned.
Type Parameters
TMetadata
Remarks
For Beginners: This saves a new version of a model you've already registered, like publishing a new edition of a book.
DeleteModel(string)
Deletes all versions of a model.
void DeleteModel(string modelName)
Parameters
modelNamestringThe name of the model to delete.
DeleteModelVersion(string, int)
Deletes a specific model version.
void DeleteModelVersion(string modelName, int version)
Parameters
GenerateModelCard(string, int, string?)
Generates a Model Card from the registered model's metadata and evaluation results.
ModelCard GenerateModelCard(string modelName, int version, string? developers = null)
Parameters
modelNamestringThe name of the model.
versionintThe version to generate a Model Card for.
developersstringOptional developers or organization to attribute the model to.
Returns
- ModelCard
A generated Model Card populated with available information.
Remarks
For Beginners: This automatically creates a Model Card from the model's existing metadata. It fills in performance metrics, robustness information, and other details that are already tracked in the registry.
GetLatestModel(string)
Gets the latest version of a model.
RegisteredModel<T, TInput, TOutput> GetLatestModel(string modelName)
Parameters
modelNamestringThe name of the model.
Returns
- RegisteredModel<T, TInput, TOutput>
The latest version of the model.
GetModel(string, int?)
Retrieves a specific model version from the registry.
RegisteredModel<T, TInput, TOutput> GetModel(string modelName, int? version = null)
Parameters
modelNamestringThe name of the model.
versionint?The version number to retrieve. If null, gets latest.
Returns
- RegisteredModel<T, TInput, TOutput>
The registered model version.
GetModelByStage(string, ModelStage)
Gets the model currently in a specific stage (e.g., production).
RegisteredModel<T, TInput, TOutput>? GetModelByStage(string modelName, ModelStage stage)
Parameters
modelNamestringThe name of the model.
stageModelStageThe stage to get the model from.
Returns
- RegisteredModel<T, TInput, TOutput>
The model in that stage, or null if none.
Remarks
For Beginners: Models go through stages like Development → Staging → Production. This gets the model currently in a specific stage.
GetModelCard(string, int)
Gets the Model Card for a registered model version.
ModelCard? GetModelCard(string modelName, int version)
Parameters
Returns
- ModelCard
The Model Card if one exists, null otherwise.
GetModelLineage(string, int)
Gets the lineage information for a model (how it was created).
ModelLineage GetModelLineage(string modelName, int version)
Parameters
Returns
- ModelLineage
Lineage information.
Remarks
For Beginners: Lineage shows the "family tree" of a model - what data was used, what experiment it came from, and how it's related to other models.
GetModelStoragePath(string, int)
Gets the storage location for a model version.
string GetModelStoragePath(string modelName, int version)
Parameters
Returns
- string
File path or URI where the model is stored.
ListModelVersions(string)
Lists all versions of a specific model.
List<ModelVersionInfo<T>> ListModelVersions(string modelName)
Parameters
modelNamestringThe name of the model.
Returns
- List<ModelVersionInfo<T>>
List of all versions with metadata.
ListModels(string?, Dictionary<string, string>?)
Lists all models in the registry.
List<string> ListModels(string? filter = null, Dictionary<string, string>? tags = null)
Parameters
filterstringOptional filter expression.
tagsDictionary<string, string>Optional tags to filter by.
Returns
RegisterModel<TMetadata>(string, IModel<TInput, TOutput, TMetadata>, ModelMetadata<T>, Dictionary<string, string>?)
Registers a new model in the registry.
string RegisterModel<TMetadata>(string name, IModel<TInput, TOutput, TMetadata> model, ModelMetadata<T> metadata, Dictionary<string, string>? tags = null) where TMetadata : class
Parameters
namestringThe name for this model.
modelIModel<TInput, TOutput, TMetadata>The trained model to register.
metadataModelMetadata<T>Metadata about the model (training data, hyperparameters, etc.).
tagsDictionary<string, string>Tags for categorizing the model.
Returns
- string
The unique identifier for the registered model.
Type Parameters
TMetadata
Remarks
For Beginners: This adds a trained model to the registry with all its information, like adding a new book to a library catalog.
SaveModelCard(string, int, string)
Saves the Model Card for a model version to a file.
void SaveModelCard(string modelName, int version, string filePath)
Parameters
modelNamestringThe name of the model.
versionintThe version number.
filePathstringThe file path to save the Model Card to.
SearchModels(ModelSearchCriteria<T>)
Searches for models based on criteria.
List<RegisteredModel<T, TInput, TOutput>> SearchModels(ModelSearchCriteria<T> searchCriteria)
Parameters
searchCriteriaModelSearchCriteria<T>Search criteria (name patterns, tags, metrics, etc.).
Returns
- List<RegisteredModel<T, TInput, TOutput>>
List of models matching the criteria.
TransitionModelStage(string, int, ModelStage, bool)
Transitions a model version to a different stage.
void TransitionModelStage(string modelName, int version, ModelStage targetStage, bool archivePrevious = true)
Parameters
modelNamestringThe name of the model.
versionintThe version to transition.
targetStageModelStageThe stage to transition to.
archivePreviousboolWhether to archive the previous model in that stage.
Remarks
For Beginners: This moves a model between stages, like promoting a model from Staging to Production after testing it.
UpdateModelMetadata(string, int, ModelMetadata<T>)
Updates the metadata for a model version.
void UpdateModelMetadata(string modelName, int version, ModelMetadata<T> metadata)
Parameters
modelNamestringThe name of the model.
versionintThe version to update.
metadataModelMetadata<T>New metadata.
UpdateModelTags(string, int, Dictionary<string, string>)
Adds or updates tags for a model.
void UpdateModelTags(string modelName, int version, Dictionary<string, string> tags)
Parameters
modelNamestringThe name of the model.
versionintThe version to tag.
tagsDictionary<string, string>Tags to add or update.