Table of Contents

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

T

The numeric data type used for calculations (e.g., float, double).

TInput
TOutput

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

modelName string

The name of the model.

version int

The version to archive.

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

modelName string

The name of the model.

version int

The version to attach the Model Card to.

modelCard ModelCard

The 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

modelName string

The name of the model.

version1 int

First version to compare.

version2 int

Second 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

modelName string

The name of the model to version.

model IModel<TInput, TOutput, TMetadata>

The new version of the model.

metadata ModelMetadata<T>

Metadata for this version.

description string

Description 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

modelName string

The name of the model to delete.

DeleteModelVersion(string, int)

Deletes a specific model version.

void DeleteModelVersion(string modelName, int version)

Parameters

modelName string

The name of the model.

version int

The version to delete.

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

modelName string

The name of the model.

version int

The version to generate a Model Card for.

developers string

Optional 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

modelName string

The 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

modelName string

The name of the model.

version int?

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

modelName string

The name of the model.

stage ModelStage

The 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

modelName string

The name of the model.

version int

The version number.

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

modelName string

The name of the model.

version int

The version to get lineage for.

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

modelName string

The name of the model.

version int

The version number.

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

modelName string

The 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

filter string

Optional filter expression.

tags Dictionary<string, string>

Optional tags to filter by.

Returns

List<string>

List of model names matching the criteria.

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

name string

The name for this model.

model IModel<TInput, TOutput, TMetadata>

The trained model to register.

metadata ModelMetadata<T>

Metadata about the model (training data, hyperparameters, etc.).

tags Dictionary<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

modelName string

The name of the model.

version int

The version number.

filePath string

The 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

searchCriteria ModelSearchCriteria<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

modelName string

The name of the model.

version int

The version to transition.

targetStage ModelStage

The stage to transition to.

archivePrevious bool

Whether 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

modelName string

The name of the model.

version int

The version to update.

metadata ModelMetadata<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

modelName string

The name of the model.

version int

The version to tag.

tags Dictionary<string, string>

Tags to add or update.