Skip to content

Repository files navigation

Bitspect — xai-rai

Model-agnostic XAI + RAI middleware layer for Python | Bitstek.io

Multi-modal Explainable and Responsible AI Python package — v0.1.5

A modular Python SDK for Explainable AI (XAI) and Responsible AI (RAI), combining model explainability, trust diagnostics, and multi-modal routing in a unified framework.

PyPI package name: xai-rai


Description

Python SDK for modular explainable and responsible AI: model adapters, explainers, risk diagnostics, and multi-modal routing in one framework.


Developer

Developed and maintained by @8bitjawad


Overview

xai-rai provides a structured framework for building, testing, and extending explainability and responsible AI workflows.

Instead of using isolated tools for explanations, fairness checks, and robustness analysis, the SDK unifies them under a layered architecture.

It provides:

  • Explainability algorithms (SHAP, LIME, counterfactuals, etc.)
  • Responsible AI diagnostics (bias, drift, robustness)
  • Pluggable model adapters for multiple modalities
  • Routing and orchestration across components
  • Visualization and reporting support

Supported modalities:

  • Tabular models
  • NLP
  • Vision models
  • LLMs
  • Text-to-image (TTI) models

Why xai-rai instead of individual libraries?

Libraries like SHAP or LIME solve explanation problems individually.

xai-rai aims to provide:

  • A unified SDK abstraction
  • Explainability and responsible AI in one system
  • Multi-modal support via adapters
  • Routing logic across models and modalities
  • An extensible architecture for research and deployment
  • LLM explanations for ease of understanding

Architecture

xai-rai follows a layered, result-centric architecture:

Facade
  ↓
Pipeline
  ↓
Analyzers / Explainers
  ↓
Inference Engines / Adapters
  ↓
Unified Result Objects
  ↓
Charts / Reports / UI

Core features

Explainability

  • SHAP feature attribution
  • LIME local explanations
  • Counterfactual explanations
  • Natural language narratives
  • Multi-modal explanation pipelines

Responsible AI

  • Fairness diagnostics
  • Population Stability Index (PSI) drift detection
  • Robustness checks
  • Confidence and anomaly scoring

Installation

Base

pip install xai-rai

Optional extras

pip install xai-rai[tabular]
pip install xai-rai[tti]
pip install xai-rai[vision]
pip install xai-rai[nlp]
pip install xai-rai[llm]
pip install xai-rai[full]

Quickstart — Text-to-Image XAI

from PIL import Image

from xai_rai import TextToImageExplainer

explainer = TextToImageExplainer(
    device="cpu",
    enable_caption_analysis=True,
)

image = Image.open("generated.png")

result = explainer.explain(
    image=image,
    prompt="a futuristic cyberpunk city",
)

print(result.summary())

See demo_tests/ and tti_demo.py for runnable examples.


Public APIs

from xai_rai import (
    TabularExplainer,
    VisionExplainer,
    NLPExplainer,
    LLMExplainer,
    TextToImageExplainer,
)

Design philosophy

Modular architecture

Each concern lives in its own layer.

Adapter pattern

Models are accessed through standardized interfaces.

Separation of concerns

Explainability and responsible AI diagnostics are distinct modules.

Extensibility

New modalities, explainers, diagnostics, and visualization layers can be added without changing the whole system.


Roadmap

Current

  • Tabular explainability
  • NLP explainability
  • Vision explainability
  • LLM explainability
  • Text-to-image explainability
  • SHAP / LIME integration
  • Counterfactual explanations
  • Multi-modal result objects
  • RAI diagnostics
  • Trust and alignment analysis

Example use cases

xai-rai can support:

  • Explainable healthcare models
  • Explainable and responsible AI for businesses
  • Responsible AI and toxicity screens

Contributing

See CONTRIBUTING.md.

This project is in beta. If you wish to contribute:

  • Keep modules modular and loosely coupled
  • Follow the layered architecture
  • Add type hints where possible
  • Prefer result-centric APIs over raw dictionaries
  • Include lightweight tests for new features
  • Keep public APIs clean and stable

For major architectural changes or new modality integrations, open an issue or discussion first.


License

MIT — see LICENSE.

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages