Skip to main content
Glama
Cappybara12

OpenXAI MCP Server

by Cappybara12

evaluate_explanation

Assess AI explanation quality using OpenXAI metrics like PGI, PGU, and RIS to measure faithfulness, robustness, and completeness for model transparency.

Instructions

Evaluate explanation quality using OpenXAI metrics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
metricYesEvaluation metric to use (PGI, PGU, RIS, RRS, ROS, etc.)
explanationYesJSON string of the explanation to evaluate
model_infoYesInformation about the model

Implementation Reference

  • The core handler function for the 'evaluate_explanation' tool. It validates the metric, constructs a Python code example for evaluating explanations using OpenXAI's Evaluator class, and returns formatted response with evaluation details.
    async evaluateExplanation(metric, explanation, modelInfo) { const validMetrics = ['PGI', 'PGU', 'RIS', 'RRS', 'ROS', 'FA', 'RA', 'SA', 'SRA', 'RC', 'PRA']; if (!validMetrics.includes(metric)) { throw new Error(`Metric '${metric}' not supported. Available metrics: ${validMetrics.join(', ')}`); } const codeExample = ` # Example usage with OpenXAI: from openxai import Evaluator from openxai import LoadModel from openxai import Explainer from openxai.dataloader import ReturnLoaders # Load model and data model = LoadModel(data_name='${modelInfo.data_name}', ml_model='${modelInfo.ml_model}', pretrained=True) trainloader, testloader = ReturnLoaders(data_name='${modelInfo.data_name}', download=True) # Generate explanations explainer = Explainer(method='lime', model=model) inputs, labels = next(iter(testloader)) explanations = explainer.get_explanations(inputs) # Evaluate explanations evaluator = Evaluator(model, metric='${metric}') score = evaluator.evaluate( inputs=inputs, labels=labels, explanations=explanations ) print(f"${metric} score: {score}") `; return { content: [ { type: 'text', text: `Evaluated explanation using ${metric} metric\n\n` + `Metric: ${metric}\n` + `Dataset: ${modelInfo.data_name}\n` + `Model: ${modelInfo.ml_model}\n` + `Explanation: ${explanation}\n\n` + `Python code example:\n\`\`\`python${codeExample}\`\`\`` } ] }; }
  • index.js:172-198 (registration)
    The tool registration entry in the list_tools response, including name, description, and input schema definition.
    { name: 'evaluate_explanation', description: 'Evaluate explanation quality using OpenXAI metrics', inputSchema: { type: 'object', properties: { metric: { type: 'string', description: 'Evaluation metric to use (PGI, PGU, RIS, RRS, ROS, etc.)', enum: ['PGI', 'PGU', 'RIS', 'RRS', 'ROS', 'FA', 'RA', 'SA', 'SRA', 'RC', 'PRA'] }, explanation: { type: 'string', description: 'JSON string of the explanation to evaluate' }, model_info: { type: 'object', description: 'Information about the model', properties: { data_name: { type: 'string' }, ml_model: { type: 'string' } } } }, required: ['metric', 'explanation', 'model_info'] } },
  • The input schema defining parameters for the evaluate_explanation tool: metric (enum), explanation (string), model_info (object).
    inputSchema: { type: 'object', properties: { metric: { type: 'string', description: 'Evaluation metric to use (PGI, PGU, RIS, RRS, ROS, etc.)', enum: ['PGI', 'PGU', 'RIS', 'RRS', 'ROS', 'FA', 'RA', 'SA', 'SRA', 'RC', 'PRA'] }, explanation: { type: 'string', description: 'JSON string of the explanation to evaluate' }, model_info: { type: 'object', description: 'Information about the model', properties: { data_name: { type: 'string' }, ml_model: { type: 'string' } } } }, required: ['metric', 'explanation', 'model_info'] }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Cappybara12/mcpopenxAI'

If you have feedback or need assistance with the MCP directory API, please join our Discord server