From f85a8d140f3584a96e01cc04931b91edb8f9043d Mon Sep 17 00:00:00 2001 From: Rui Vieira Date: Wed, 3 Jul 2024 10:59:05 +0100 Subject: [PATCH] Update explainers payload schema --- .../pages/saliency-explanations-on-odh.adoc | 58 +++++++++++++++++-- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/docs/modules/ROOT/pages/saliency-explanations-on-odh.adoc b/docs/modules/ROOT/pages/saliency-explanations-on-odh.adoc index baa06d9..848680e 100644 --- a/docs/modules/ROOT/pages/saliency-explanations-on-odh.adoc +++ b/docs/modules/ROOT/pages/saliency-explanations-on-odh.adoc @@ -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 @@ -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.