Skip to content

Commit

Permalink
Merge pull request #25 from ruivieira/main
Browse files Browse the repository at this point in the history
Update explainers payload schema
  • Loading branch information
ruivieira authored Jul 4, 2024
2 parents 30f9aa8 + f85a8d1 commit 285d976
Showing 1 changed file with 54 additions and 4 deletions.
58 changes: 54 additions & 4 deletions docs/modules/ROOT/pages/saliency-explanations-on-odh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,40 @@ curl -sk -X POST -H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d "{
\"predictionId\": \"$INFERENCE_ID\",
\"modelConfig\": {
\"target\": \"modelmesh-serving.${NAMESPACE}.svc.cluster.local:8033\",
\"name\": \"explainer-test\",
\"version\": \"v1\"
\"config\": {
\"model\": {
\"target\": \"modelmesh-serving.${NAMESPACE}.svc.cluster.local:8033\",
\"name\": \"explainer-test\",
\"version\": \"v1\"
}
}
}" \
https://${TRUSTYAI_ROUTE}/explainers/local/lime
----

If the explainer needs to be configured, additional options can be added under `config.explainer`. For instance, to configure the number of samples used by LIME we can issue:

[source,shell]
----
curl -sk -X POST -H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d "{
\"predictionId\": \"$INFERENCE_ID\",
\"config\": {
\"model\": { <1>
\"target\": \"modelmesh-serving.${NAMESPACE}.svc.cluster.local:8033\",
\"name\": \"explainer-test\",
\"version\": \"v1\"
},
\"explainer\": { <2>
\"n_samples\": 100
}
}
}" \
https://${TRUSTYAI_ROUTE}/explainers/local/lime
----
<1> The `model` field specifies configuration regarding the model to be used.
<2> The `explainer` field specifies the configuration of the explainer itself. In this instance, the number of samples.

=== Results

Expand Down Expand Up @@ -211,3 +236,28 @@ The output will show the saliency scores and confidence for each input feature u
}
}
----

=== Request a SHAP Explanation

Requesting a SHAP explanation is done using a similar call, but replacing the endpoint with SHAP's. For instance

[source,shell]
----
curl -sk -X POST -H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d "{
\"predictionId\": \"$INFERENCE_ID\",
\"config\": {
\"model\": {
\"target\": \"modelmesh-serving.${NAMESPACE}.svc.cluster.local:8033\",
\"name\": \"explainer-test\",
\"version\": \"v1\"
},
\"explainer\": {
\"n_samples\": 100
}
}
}" \
https://${TRUSTYAI_ROUTE}/explainers/local/shap <1>
----
<1> The endpoint now refers to SHAP, instead of LIME.

0 comments on commit 285d976

Please sign in to comment.