How salesforce/omnixai works
Project Type and Purpose
• OmniXAI is an open-source Python library for Explainable AI (XAI), not a web app.
• It also offers a Dash-based dashboard for interactive visualization and BentoML integration for serving explanation APIs.
High-Level File Structure
• Top-level packages:
• omnixai/data – data abstraction classes (Tabular, Image, Text, TimeSeries)
• omnixai/preprocessing – data transforms & pipelines
• omnixai/explainers – core explainer implementations, organized by data type and method
• omnixai/explanations – post-processing of explainer outputs into generic Explanation objects
• omnixai/visualization – Dash app, callbacks, pages, assets for interactive dashboards
• omnixai/deployment – BentoML save & init_service adapters
• omnixai/utils & sampler – misc helpers and sampling utilities
• Support directories:
• tutorials, docs, tests
• build/config files (setup.py, CI, mkdocs)
Key Components
• User Layer
• Jupyter notebooks / CLI scripts / Python code that import OmniXAI
• Data Layer
• Raw data (tabular CSV, images, text, time-series)
• Data wrappers: Tabular, Image, Text, TimeSeries
• Preprocessing Layer
• Preprocessing pipelines (base, encode, normalize, fill)
• User-provided preprocess/postprocess functions
• Model Layer (External)
• Scikit-learn models
• XGBoost, LightGBM
• PyTorch / TensorFlow deep nets
• Explainer Core
• Factory classes: TabularExplainer, VisionExplainer, NLPExplainer, TimeseriesExplainer
• Base classes & method registry (base.py)
• Plugin-style modules per method (shap, lime, mace, ig, gradcam, gpt, etc.)
• Explanation Objects
• LocalExplanation, GlobalExplanation, PredictionExplanation
• JSON (for REST) ↔ Python objects converter
• Visualization
• Dashboard (Dash)
– Layout, callbacks, pages for local/global/prediction/what-if panels
– Static assets (CSS, JS, fonts)
• Deployment
• BentoML save_model & init_service
• REST endpoints: /predict, /explain
• Multipart/form data handler
• External Services
• OpenAI GPT API (optional)
• BentoML model store
• Hosting environments (Heroku, AWS, GCP)
Interactions and Data Flow
• 1. User code creates Data object → applies Preprocessing → passes to Model
2. User initializes Explainer factory with Model, Data, preprocess/postprocess
3. Explainer factory invokes specific method modules → returns Explanation objects
4. Explanation objects can be:
• Plotted in‐line (IPython)
• Passed to Dashboard
5. Dashboard renders via callbacks → user interacts
6. For deployment: Explainer serialized via BentoML → Bento service exposes REST API
7. Clients send JSON/Multipart requests → service loads Explainer → returns JSON explanations
Important Architectural Patterns
• Modular plugin architecture for explanation methods under omnixai/explainers
• Factory pattern (TabularExplainer, VisionExplainer, etc.)
• Separation of concerns: data → preprocessing → explainers → visualization → deployment
• Extensibility points: adding a new explainer module and registering it in base.py
• Standard interfaces: all explainers implement .explain()/.explain_global()
Technologies and Frameworks
• Python 3.7–3.10
• Core ML libs: scikit-learn, XGBoost, PyTorch, TensorFlow
• Explainability: SHAP, LIME
• Visualization: Dash (Plotly)
• Deployment: BentoML
• External API: OpenAI GPT models