Skip to content

About

Code Repository for the paper "Learning Through Explanations: Cooperative Dialogue Between Models"

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Learning Through Explanations: Cooperative Dialogue Between Models

Official implementation of the experiments presented in “Learning Through Explanations: Cooperative Dialogue Between Models.”

This repository contains the complete collection of notebooks used to train and evaluate heterogeneous neural models that exchange explanations during cooperative learning.

Overview

Most explainable artificial intelligence methods produce explanations for human inspection after a model has been trained. This work investigates a different setting: explanations are used directly as training signals exchanged between models.

The proposed framework combines:

  • heterogeneous neural models with different inductive biases;
  • differentiable Grad-CAM explanations;
  • directional model-to-model explanation alignment;
  • independent, exchange-only and moderated training regimes;
  • a frozen external reference model acting as a devil's advocate;
  • dense, fixed-subset and cyclic interaction topologies.

The experiments evaluate predictive performance, explanation faithfulness, stability and inter-model agreement across multiple ensemble sizes and strong–weak model configurations.

Repository organization

The experimental pipeline is distributed across a numbered sequence of Jupyter notebooks placed in the root of the repository. Numerical prefixes define the intended execution order, while the suffix b identifies an evaluation or completion step associated with the preceding notebook.

The collection covers: The notebooks are organized as follows:

  1. 00_setup_and_dataset_check.ipynb: project setup, dataset configuration and data-loading checks;
  2. 01_models_and_smoke_test.ipynb: model definitions and architecture smoke tests;
  3. 02_train_single_model_baseline.ipynb: training and evaluation of a single independent baseline;
  4. 03_train_all_single_baselines.ipynb: training and aggregation of all independent baseline models;
  5. 04_gradcam_baseline_check.ipynb: qualitative Grad-CAM validation for the baseline models;
  6. 05_xai_metrics_baseline.ipynb: computation of baseline explanation metrics;
  7. 06_train_two_model_cooperative.ipynb: initial two-model cooperative explanation-exchange experiment;
  8. 07_train_two_model_matched_baseline_vs_cooperative.ipynb: matched comparison between independent and cooperative two-model training;
  9. 08_evaluate_matched_pair_xai.ipynb: predictive and explanation-based evaluation of the matched pair;
  10. 09_repeat_matched_two_model_pairs.ipynb: repetition of the matched experiment for the remaining model pairs;
  11. 10_train_multimodel_scaling_fully_connected.ipynb: fully connected multi-model scaling experiments;
  12. 11_moderated_two_model_pairs.ipynb: two-model experiments with the frozen devil’s-advocate reference model;
  13. 12_multimodel_scaling_moderated_N3_N5_N10.ipynb: comparison of independent, exchange-only and moderated ensembles for N = 3, N = 5 and N = 10;
  14. 13_xai_scaling_N3_N5_N10.ipynb: explanation-based evaluation of the ensemble-scaling experiments;
  15. 13b_sanity_scaling_completion.ipynb: completion of the sanity-check metrics associated with Notebook 13;
  16. 14_topology_ablation_N10.ipynb: comparison of fully connected, fixed-subset and cyclic interaction topologies at N = 10;
  17. 14b_topology_ablation_N10_XAI.ipynb: explanation-based evaluation of the topology ablation;
  18. 15_asymmetry_studies_N5.ipynb: strong–weak asymmetry experiments with one strong and four weak models, and four strong and one weak model;
  19. 15b_asymmetry_studies_N5_XAI.ipynb: explanation-based evaluation of the strong–weak asymmetry experiments;
  20. 16_qualitative_figures.ipynb: generation of qualitative Grad-CAM comparisons;

Some later notebooks reuse checkpoints and metrics produced by earlier ones. For a complete reproduction, run the notebooks in numerical order and do not rename the generated experiment directories.

Experimental setting

Datasets

The study uses five medical image-classification datasets:

  • Derma;
  • Blood Cell;
  • Chest X-Ray;
  • Breast Ultrasound;
  • Abdominal CT.

Dataset loading and preprocessing are handled by the notebooks through the shared project utilities.

Model families

The heterogeneous ensembles use combinations of the following architectures:

  • Small CNN;
  • Plain CNN;
  • VGG-Small;
  • Inception-Small;
  • ResNet-18;
  • EfficientNet-B0.

Training regimes

The main conditions are:

  • Independent: models are trained without explanation exchange;
  • Exchange-only: models exchange differentiable explanations during training;
  • Moderated: explanation exchange is anchored by a frozen external reference model.

The experiments also consider ensemble sizes (N\in{3,5,10}), sparse interaction topologies and asymmetric ensembles containing different proportions of strong and weak models.

Evaluation metrics

The notebooks compute and export, where applicable:

  • test accuracy;
  • balanced accuracy;
  • insertion and deletion AUC;
  • explanation stability;
  • pairwise explanation agreement;
  • top-(k) Jaccard overlap;
  • per-model and soft-voting ensemble performance.

Generated files

During execution, the notebooks create the following directory structure:

Self_XAI_Ens/
├── data/
├── runs/
├── results/
│   ├── raw/
│   ├── aggregated/
│   ├── figures/
│   └── tables/
└── paper_export/
    ├── figures/
    └── tables/

Training checkpoints and intermediate metrics are stored under runs/. Aggregated CSV files, plots and LaTeX-ready outputs are stored under results/ and paper_export/.

Reproducibility notes

  • The experiments reported in the manuscript use a random seed, change this for multiple runs.
  • Later notebooks may require checkpoints generated by the baseline and scaling notebooks.
  • Interrupted training conditions can be resumed from the most recent checkpoint where supported.
  • Fully reproducing all experiments requires substantially more computation than running a single dataset and configuration.
  • Exact numerical results may depend on the GPU, CUDA, PyTorch and cuDNN versions used by the environment.

Citation

If you use this code, please cite the corresponding paper:

@article{metta2026learning,
  title   = {Learning Through Explanations: Cooperative Dialogue Between Models},
  author  = {Metta, Carlo},
  year    = {2026},
  note    = {Manuscript under review}
}

The final journal, volume, pages and DOI will be added after publication.

Code availability

The repository contains the notebooks used to implement the proposed framework, run the experiments and generate the reported results.

Contact

For questions about the code or experiments, contact:

Carlo Metta
ISTI-CNR / NEST, IIT
carlo.metta@isti.cnr.it

License

License information will be added before the public release of the repository.

About

Code Repository for the paper "Learning Through Explanations: Cooperative Dialogue Between Models"

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages