shap.models.TransformersPipeline

class shap.models.TransformersPipeline(pipeline, rescale_to_logits=False)

This wraps a transformers pipeline object for easy explanations.

By default transformers pipeline object output lists of dictionaries, not standard tensors as expected by SHAP. This class wraps pipelines to make them output nice tensor formats.

__init__(pipeline, rescale_to_logits=False)

Build a new model by wrapping the given pipeline object.

Methods

__init__(pipeline[, rescale_to_logits])

Build a new model by wrapping the given pipeline object.

load(in_file[, instantiate])

This is meant to be overridden by subclasses and called with super.

save(out_file)

Save the model to the given file stream.

classmethod load(in_file, instantiate=True)

This is meant to be overridden by subclasses and called with super.

We return constructor argument values when not being instantiated. Since there are no constructor arguments for the Serializable class we just return an empty dictionary.

save(out_file)

Save the model to the given file stream.