# jsenk347/ai-bench architecture

> Architecture diagram of the GitHub repository jsenk347/ai-bench, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jsenk347/ai-bench
- Repository: https://github.com/jsenk347/ai-bench

## Overview

ai-bench is a research benchmarking pipeline that generates explanations for NLP, classical ML, vision, and generative language models, then evaluates explanation consistency and fidelity. The principal workflow is CLI input → RunRequest → model resolution/loading and group detection → group-specific protocols → report rendering. The graph also retains the documented sweep experiments and the shared explanation, metric, and report layers. Some source is unsampled; links to those areas are limited to relationships shown in the README or SOURCE INDEX.

Main entry points: [`xai_pipeline/pipeline/run.py`](https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/pipeline/run.py) (Benchmark runner), [`xai_pipeline/pipeline/protocols.py`](https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/pipeline/protocols.py) (Group protocols), [`main.py`](https://github.com/jsenk347/ai-bench/blob/main/main.py) (CLI entry), [`xai_pipeline/explanation_generators`](https://github.com/jsenk347/ai-bench/tree/main/xai_pipeline/explanation_generators) (IG, SHAP, Ablation CAM)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_entry["CLI entry<br/>[main.py]"]
  node_cli_inputs["Input selection<br/>[input_paths.py]"]
  node_cli_render["Briefing and rendering<br/>[render.py]"]
end

subgraph group_orchestration["Benchmark orchestration"]
  node_request["Run request<br/>[requests.py]"]
  node_registry["Model registry<br/>[registry.py]"]
  node_detection["Model detection<br/>[detection.py]"]
  node_loaders["Model and data loading<br/>[loaders.py]"]
  node_run["Benchmark runner<br/>[run.py]"]
  node_protocols["Group protocols<br/>[protocols.py]"]
end

subgraph group_evaluation["Explanation and evaluation"]
  node_explainers["IG, SHAP, Ablation CAM"]
  node_explanation_objects["Explanation objects"]
  node_consistency["Consistency metrics<br/>[consistency.py]"]
  node_fidelity["Fidelity masking<br/>[fidelity_core.py]"]
  node_validity["Metric validity<br/>[validity.py]"]
  node_preflight["Dataset preflight<br/>[preflight.py]"]
  node_sampling["Confidence sampling<br/>[sampling.py]"]
end

subgraph group_results["Reports"]
  node_report_schema["Report schema<br/>[schema.py]"]
  node_glossary["Plain-language glossary<br/>[glossary.py]"]
end

subgraph group_experiments["Research sweeps"]
  node_sweep_common["Sweep utilities<br/>[common.py]"]
  node_sweep_classical["Classical sweep<br/>[classical_sweep.py]"]
  node_sweep_nlp["NLP sweeps<br/>[nlp_sweep.py]"]
  node_sweep_vision["Vision sweep<br/>[vision_sweep.py]"]
  node_sweep_genllm["Generative LLM sweep<br/>[genllm_sweep.py]"]
end

node_user(("Researcher"))
node_dataset_source[("JIRA dataset source")]

node_user -->|"starts"| node_entry
node_entry -->|"collects input"| node_cli_inputs
node_entry -->|"renders output"| node_cli_render
node_cli_inputs -->|"builds request"| node_request
node_cli_inputs -->|"resolves model"| node_registry
node_entry -->|"starts benchmark"| node_run
node_run -->|"accepts request"| node_request
node_run -->|"resolves spec"| node_registry
node_run -->|"detects group"| node_detection
node_run -->|"loads subject"| node_loaders
node_run -->|"dispatches protocol"| node_protocols
node_protocols -->|"uses explainers"| node_explainers
node_protocols -->|"computes consistency"| node_consistency
node_protocols -->|"computes fidelity"| node_fidelity
node_protocols -->|"checks capability"| node_validity
node_protocols -->|"checks dataset"| node_preflight
node_protocols -.->|"samples instances"| node_sampling
node_explainers -->|"produces explanations"| node_explanation_objects
node_explainers -->|"uses masking"| node_fidelity
node_explainers -->|"uses consistency"| node_consistency
node_run -->|"returns report"| node_report_schema
node_cli_render -->|"renders report"| node_report_schema
node_cli_render -->|"explains scores"| node_glossary
node_loaders -->|"downloads data"| node_dataset_source
node_sweep_nlp -->|"uses utilities"| node_sweep_common
node_sweep_vision -->|"uses utilities"| node_sweep_common
node_sweep_genllm -->|"uses utilities"| node_sweep_common
node_sweep_genllm -->|"runs benchmark"| node_run
node_sweep_nlp -->|"runs benchmark"| node_run
node_sweep_vision -->|"runs benchmark"| node_run
node_sweep_classical -.->|"uses utilities"| node_sweep_common

click node_entry "https://github.com/jsenk347/ai-bench/blob/main/main.py"
click node_cli_inputs "https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/cli/input_paths.py"
click node_cli_render "https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/cli/render.py"
click node_request "https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/pipeline/requests.py"
click node_registry "https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/pipeline/registry.py"
click node_detection "https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/pipeline/detection.py"
click node_loaders "https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/pipeline/loaders.py"
click node_run "https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/pipeline/run.py"
click node_protocols "https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/pipeline/protocols.py"
click node_explainers "https://github.com/jsenk347/ai-bench/tree/main/xai_pipeline/explanation_generators"
click node_explanation_objects "https://github.com/jsenk347/ai-bench/tree/main/xai_pipeline/explanation_objects"
click node_consistency "https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/metrics/consistency.py"
click node_fidelity "https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/metrics/fidelity_core.py"
click node_validity "https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/metrics/validity.py"
click node_preflight "https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/metrics/preflight.py"
click node_sampling "https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/metrics/sampling.py"
click node_report_schema "https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/report/schema.py"
click node_glossary "https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/report/glossary.py"
click node_sweep_common "https://github.com/jsenk347/ai-bench/blob/main/experiments/model_sweep/common.py"
click node_sweep_classical "https://github.com/jsenk347/ai-bench/blob/main/experiments/model_sweep/classical_sweep.py"
click node_sweep_nlp "https://github.com/jsenk347/ai-bench/blob/main/experiments/model_sweep/nlp_sweep.py"
click node_sweep_vision "https://github.com/jsenk347/ai-bench/blob/main/experiments/model_sweep/vision_sweep.py"
click node_sweep_genllm "https://github.com/jsenk347/ai-bench/blob/main/experiments/model_sweep/genllm_sweep.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_cli_inputs,node_cli_render toneBlue
class node_request,node_registry,node_detection,node_loaders,node_run,node_protocols,node_dataset_source toneAmber
class node_explainers,node_explanation_objects,node_consistency,node_fidelity,node_validity,node_preflight,node_sampling toneMint
class node_report_schema,node_glossary toneRose
class node_sweep_common,node_sweep_classical,node_sweep_nlp,node_sweep_vision,node_sweep_genllm,node_user toneIndigo
```

## Components

### User interface

- [CLI entry](https://github.com/jsenk347/ai-bench/blob/main/main.py): `main.py`
- [Input selection](https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/cli/input_paths.py): `xai_pipeline/cli/input_paths.py`
- [Briefing and rendering](https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/cli/render.py): `xai_pipeline/cli/render.py`

### Benchmark orchestration

- [Run request](https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/pipeline/requests.py): `xai_pipeline/pipeline/requests.py`
- [Model registry](https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/pipeline/registry.py): `xai_pipeline/pipeline/registry.py`
- [Model detection](https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/pipeline/detection.py): `xai_pipeline/pipeline/detection.py`
- [Model and data loading](https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/pipeline/loaders.py): `xai_pipeline/pipeline/loaders.py`
- [Benchmark runner](https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/pipeline/run.py): `xai_pipeline/pipeline/run.py`
- [Group protocols](https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/pipeline/protocols.py): `xai_pipeline/pipeline/protocols.py`

### Explanation and evaluation

- [IG, SHAP, Ablation CAM](https://github.com/jsenk347/ai-bench/tree/main/xai_pipeline/explanation_generators): `xai_pipeline/explanation_generators`
- [Explanation objects](https://github.com/jsenk347/ai-bench/tree/main/xai_pipeline/explanation_objects): `xai_pipeline/explanation_objects`
- [Consistency metrics](https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/metrics/consistency.py): `xai_pipeline/metrics/consistency.py`
- [Fidelity masking](https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/metrics/fidelity_core.py): `xai_pipeline/metrics/fidelity_core.py`
- [Metric validity](https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/metrics/validity.py): `xai_pipeline/metrics/validity.py`
- [Dataset preflight](https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/metrics/preflight.py): `xai_pipeline/metrics/preflight.py`
- [Confidence sampling](https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/metrics/sampling.py): `xai_pipeline/metrics/sampling.py`

### Reports

- [Report schema](https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/report/schema.py): `xai_pipeline/report/schema.py`
- [Plain-language glossary](https://github.com/jsenk347/ai-bench/blob/main/xai_pipeline/report/glossary.py): `xai_pipeline/report/glossary.py`

### Research sweeps

- [Sweep utilities](https://github.com/jsenk347/ai-bench/blob/main/experiments/model_sweep/common.py): `experiments/model_sweep/common.py`
- [Classical sweep](https://github.com/jsenk347/ai-bench/blob/main/experiments/model_sweep/classical_sweep.py): `experiments/model_sweep/classical_sweep.py`
- [NLP sweeps](https://github.com/jsenk347/ai-bench/blob/main/experiments/model_sweep/nlp_sweep.py): `experiments/model_sweep/nlp_sweep.py`
- [Vision sweep](https://github.com/jsenk347/ai-bench/blob/main/experiments/model_sweep/vision_sweep.py): `experiments/model_sweep/vision_sweep.py`
- [Generative LLM sweep](https://github.com/jsenk347/ai-bench/blob/main/experiments/model_sweep/genllm_sweep.py): `experiments/model_sweep/genllm_sweep.py`

### Other components

- **Researcher**
- **JIRA dataset source**

## Connections

- Researcher → CLI entry: starts
- CLI entry → Input selection: collects input (evidence: `main.py`)
- CLI entry → Briefing and rendering: renders output (evidence: `main.py`)
- Input selection → Run request: builds request (evidence: `xai_pipeline/cli/input_paths.py`)
- Input selection → Model registry: resolves model (evidence: `xai_pipeline/cli/input_paths.py`)
- CLI entry → Benchmark runner: starts benchmark
- Benchmark runner → Run request: accepts request (evidence: `xai_pipeline/pipeline/run.py`)
- Benchmark runner → Model registry: resolves spec (evidence: `xai_pipeline/pipeline/run.py`)
- Benchmark runner → Model detection: detects group (evidence: `xai_pipeline/pipeline/run.py`)
- Benchmark runner → Model and data loading: loads subject (evidence: `xai_pipeline/pipeline/run.py`)
- Benchmark runner → Group protocols: dispatches protocol (evidence: `xai_pipeline/pipeline/run.py`)
- Group protocols → IG, SHAP, Ablation CAM: uses explainers (evidence: `xai_pipeline/pipeline/protocols.py`)
- Group protocols → Consistency metrics: computes consistency (evidence: `xai_pipeline/pipeline/protocols.py`)
- Group protocols → Fidelity masking: computes fidelity (evidence: `xai_pipeline/pipeline/protocols.py`)
- Group protocols → Metric validity: checks capability (evidence: `xai_pipeline/pipeline/protocols.py`)
- Group protocols → Dataset preflight: checks dataset (evidence: `xai_pipeline/pipeline/protocols.py`)
- Group protocols → Confidence sampling: samples instances
- IG, SHAP, Ablation CAM → Explanation objects: produces explanations (evidence: `xai_pipeline/explanation_generators/base.py`)
- IG, SHAP, Ablation CAM → Fidelity masking: uses masking (evidence: `xai_pipeline/explanation_generators/__init__.py`)
- IG, SHAP, Ablation CAM → Consistency metrics: uses consistency (evidence: `xai_pipeline/explanation_generators/__init__.py`)
- Benchmark runner → Report schema: returns report
- Briefing and rendering → Report schema: renders report (evidence: `xai_pipeline/cli/render.py`)
- Briefing and rendering → Plain-language glossary: explains scores (evidence: `xai_pipeline/cli/render.py`)
- Model and data loading → JIRA dataset source: downloads data (evidence: `xai_pipeline/pipeline/loaders.py`)
- NLP sweeps → Sweep utilities: uses utilities (evidence: `experiments/model_sweep/nlp_sweep.py`)
- Vision sweep → Sweep utilities: uses utilities (evidence: `experiments/model_sweep/vision_sweep.py`)
- Generative LLM sweep → Sweep utilities: uses utilities (evidence: `experiments/model_sweep/genllm_sweep.py`)
- Generative LLM sweep → Benchmark runner: runs benchmark (evidence: `experiments/model_sweep/genllm_sweep.py`)
- NLP sweeps → Benchmark runner: runs benchmark (evidence: `experiments/model_sweep/nlp_sweep.py`)
- Vision sweep → Benchmark runner: runs benchmark (evidence: `experiments/model_sweep/vision_sweep.py`)
- Classical sweep → Sweep utilities: uses utilities
