Storing models on disk

The model store feature is in the alpha tier.

The model catalog exists as long as the Neo4j instance is running. When Neo4j is restarted, models are no longer available in the catalog and need to be trained again. This can be prevented by storing a model on disk.

The location of the stored models can be configured via the configuration parameter gds.model.store_location in the neo4j.conf. The location must be a directory and writable by the Neo4j process.

The gds.model.store_location parameter must be configured for this feature.

1. Storing models from the catalog on disk

Models that can be stored

Models that cannot be stored

1.1. Syntax

Remove a model from the catalog:
CALL gds.alpha.model.store(
    modelName: String,
    failIfUnsupportedType: Boolean
)
YIELD
    modelName: String,
    storeMillis: Integer
Table 1. Parameters
Name Type Default Optional Description

modelName

String

n/a

no

The name of a model.

failIfUnsupportedType

Boolean

true

yes

By default, the library will raise an error when trying to store a non-supported model. When set to false, the procedure returns an empty result.

Table 2. Results
Name Type Description

modelName

String

The name of the stored model.

storeMillis

Integer

The number of milliseconds it took to store the model.

1.2. Example

Store a model on disk:
CALL gds.alpha.model.store('my-model')
YIELD
  modelName,
  storeMillis

2. Loading models from disk

GDS will discover available models from the configured store location upon database startup. During discovery, only model metadata is loaded, not the actual model data. In order to use a stored model, it has to be explicitly loaded.

2.1. Syntax

Remove a model from the catalog:
CALL gds.alpha.model.load(modelName: String)
YIELD
    modelName: String,
    loadMillis: Integer
Table 3. Parameters
Name Type Default Optional Description

modelName

String

n/a

no

The name of a model.

Table 4. Results
Name Type Description

modelName

String

The name of the loaded model.

loadMillis

Integer

The number of milliseconds it took to load the model.

2.2. Example

Store a model on disk:
CALL gds.alpha.model.load('my-model')
YIELD
  modelName,
  loadMillis

To verify if a model is loaded, we can use the gds.beta.model.list procedure. The procedure returns flags to indicate if the model is stored and if the model is loaded into memory. The operation is idempotent, and skips loading if the model is already loaded.

3. Deleting models from disk

To remove a stored model from disk, it has to be deleted. This is different from dropping a model. Dropping a model will remove it from the in-memory model catalog, but not from disk. Deleting a model will remove it from disk, but keep it in the in-memory model catalog if it was already loaded.

3.1. Syntax

Remove a model from the catalog:
CALL gds.alpha.model.delete(modelName: String)
YIELD
    modelName: String,
    deleteMillis: Integer
Table 5. Parameters
Name Type Default Optional Description

modelName

String

n/a

no

The name of a model.

Table 6. Results
Name Type Description

modelName

String

The name of the loaded model.

deleteMillis

Integer

The number of milliseconds it took to delete the model.

3.2. Example

Store a model on disk:
CALL gds.alpha.model.delete('my-model')
YIELD
  modelName,
  deleteMillis