Models

  1. Create a model
  2. Install models
  3. Get model help
  4. List models
  5. Uninstall models

A model in Guild AI is a representation of a machine learning model. A model may be as simple, like a linear regression, or complex, like a deep neural network.

Models in Guild are characterized by their support of operations, which are actions that can be performed on the model. One of the most common model operations is train, which iteratively modifies model parameters to optimize the model’s predictive or generative capability. Other common operations include evaluate, predict, deploy, and generate.

Guild does not implement model operations. That task is the responsibility of the model developer. Guild instead manages the work flow associated with running operations and tracking results.

Consider the following Guild command:

guild run train mnist

When this command is run, Guild will look for a model named mnist and then for an operation associated with that model named train. With this information, Guild will start a run. Guild tracks run metadata and output so you can access it later.

Guild looks for models in Guild files, which are files named guild.yml that contain model definitions.

Here’s what a guild.yml that defines an mnist model might look like:

model: mnist
operations:
  train:
    main: train_mnist

This file tells Guild that the model mnist has an operation train that is performed by running a Python module train_mnist.

Here’s what train_mnist.py might look like:

import mnist_data
import mnist_model

def train():
    data = mnist_data.load()
    model = mnist_model.init()
    model.train(data)

if __name__ == "__main__":
    train()

Models in Guild are flexible and can be used to manage any type of operation associated with the model.

Create a model

To create a model, create a file named guild.yml in your model project directory.

Using a text editor, paste the following code sample into guild.yml:

- model: my-model
  description: My model
  operations:
    train:
      main: train_my_model
  • Replace the values for model and description to reflect the attributes of your model.

  • Replace train_my_model with the Python module used to train your model.

  • Save guild.yml.

For more information on defining models and operations, see Guile file reference.

For a detailed step-by-step example of creating a Guild model, see Add Guild to a project.

You can experiment with training your model by running:

guild run train

For information on working with runs generated by operations, see Runs.

Install models

Guild AI is a package manager that can be used to install models from the deep learning ecosystem. Models are distributed in standard Python packages that can be installed with pip or Guild.

To install a package, run:

guild install PACKAGE

You can lookup packages by running:

guild search TERM

For example, to install a package that contains ResNet models, search for resnet by running:

guild search resnet

You can also browse Guild AI packages or PyPI.

After reviewing the list of available packages, if you decide to install tensorflow.reset, you can install it by running:

guild install tensorflow.resnet

For more information, see Install packages and the install command.

Get model help

To view help for models defined in the current directory (i.e. models defined in ./guild.yml) run:

guild help

To view help for models defined in another directory, run:

guild help DIRECTORY

Note

DIRECTORY must contain a Guild file (i.e. guild.yml).

To view help for models defined in a package, run:

guild help PACKAGE

For example, to view help for the models provided by tensorflow.resnet, run:

guild help tensorflow.resnet

For more information, see the help command.

List models

List available models by running:

guild models

You can filter the results using a term. For example, to list available models that contain cnn, run:

guild models cnn

For more information, see the models command.

Uninstall models

You can remove models defined in packages by uninstalling the packages.

guild uninstall PACKAGE

The package that a model is associated with is displayed when you run guild models in the form PACKAGE/MODEL.

For more information, see Uninstall packages and the uninstall command.