Model Explanations with Text Data

In this demo we will:

  • Launch a movie sentiment pipeline which takes text input

  • Send a request to get a sentiment prediction

  • Create an explainer for the model

  • Send the same request and then get an explanation for it

The explainer uses the anchor technique to provide insight into why a particular classification was made by the model. We’ll see patterns in input text that are most relevant to the prediction outcome.

Create Model

  1. Click on Create new deployment.

  2. Enter the deployment details as follows:

    - Name: movie
    - Namespace: seldon
    - Type: Seldon ML Pipeline
    
  3. Configure the default predictor as follows:

    - Runtime: Scikit Learn
    - Model Project: default
    - Model URI: gs://seldon-models/scv2/examples/moviesentiment/classifier
    - Storage Secret: (leave blank/none)
    

    Default predictor spec

  4. Skip to the end and click Launch.

  5. If your deployment is launched successfully, it will have Available status.

Get Predictions

  1. Click on the movie deployment created in the previous section to enter the deployment dashboard.

  2. Inside the deployment dashboard, click on the Predict button.

  3. On the Predict page, enter the following text:

    {
      "parameters": {
        "content_type": "str"
      },
      "inputs": [{
        "name": "text review",
        "shape": [1],
        "datatype": "BYTES",
        "data": ["this film has bad actors"]
      }]
    }
    
  4. Click the Predict button. A screenshot showing the Predict page with the textarea pre-populated

Add a Anchor Text Explainer

  1. From the movie deployment dashboard, click Add inside the Model Explanation card.

  2. For step 1 of the Explainer Configuration Wizard, select Text then click Next.

  3. For step 2, set the following details:

    - Explainer Algorithm: Anchor
    
  4. For step 3, set the following details

    - Explainer URI: gs://seldon-models/scv2/examples/moviesentiment/explainer
    - Explainer Project: default
    

    Next button clicked

  5. Skip step 4.

  6. For step 5, set following details

    - Memory: 1Gi
    
  7. Skip the remaining steps without changing fields, and click Launch.

After a short while, the explainer should become available.

Get Explanation for one Request

Resend a single request using the JSON below and then explain it:

{
  "parameters": {
    "content_type": "str"
  },
  "inputs": [{
    "name": "text review",
    "shape": [1],
    "datatype": "BYTES",
    "data": ["this film has bad actors"]
  }]
}

Navigate to the Requests page using the left navigation drawer.

navigating to the Requests page

Click on the View explanation button to generate explanations for the request.

Explaining the request

Congratulations, you’ve created an explanation for the request! 🥳

Next Steps

Why not try our other demos? Ready to dive in? Read our operations guide to learn more about how to use Enterprise Platform.