# Saving and loading

Alibi includes experimental support for saving and loading a subset of explainers to disk using the `dill` module.

To save an explainer, simply call the `save` method and provide a path to a directory (a new one will be created if it doesn't exist):

```python
explainer.save('path')
```

Alibi doesn't save the model/prediction function that is passed into the explainer so when loading the explainer you will need to provide it again:

```python
from alibi.saving import load_explainer
explainer = load_explainer('path', predictor=predictor)
```

## Details and limitations

Every explainer will save the following artifacts as a minimum:

```bash
path/meta.dill
path/explainer.dill
```

Here `meta.dill` is the metadata of the explainer (including the Alibi version used to create it) and `explainer.dill` is the serialized explainer. Some explainers may save more artifacts, e.g. `AnchorText` additionally saves `path/nlp` which is the `spacy` model used to initialize the explainer using the native `spacy` saving functionality (`pickle` based) whilst `AnchorImage` also saves the custom Python segmentation function under `path/segmentation_fn.dill`.

When loading a saved explainer, a warning will be issued if the runtime Alibi version is different from the version used to save the explainer. **It is highly recommended to use the same Alibi, Python and dependency versions as were used to save the explainer to avoid potential bugs and incompatibilities**.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.seldon.ai/alibi-explain/overview/saving.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
