Amin Parchami-Araghi · Sukrut Rao · Jonas Fischer · Bernt Schiele
[Update] We have now added a minimal and standalone implementation of our concept-consistency metric (C2-Score), which you can easily port to your own codebase.
git clone https://github.com/m-parchami/FaCT.git
conda create --name fact python=3.10
conda activate fact
cd FaCT; pip install -r requirements.txtYou can then either activate run conda activate fact before every script, or replace the CONDA variable in the script and point it towards the installed binary.
The training implementation is provided under fact.training. You can use train.sh for sample training scripts for different layers and architectures. The script has the commands for both local runs, as well as slurm jobs.
bash train.shFor every new layer or architecture that you visit, you would need to run the train script once to generate the features, and then afterwards run again, but with the --precomputed-feats pointing to the path of the feature tensor. Currently the code is configured to keep the size of the stored dataset to be 170GB (it adjusts itself based on number of dimensions). If 170 GB is too much for your setup, simply reduce number of feature samples per image here or specify a low --num_batches when collecting training features. I would recommend reducing the number of samples per image, so that the whole dataset is covered. I will soon add a less memory-intensive implementation of features, where it is stored in smaller tensor chunks that can be loaded independently.
We have released our FaCT models on Github. These are per-model and per-layer SAE checkpoints (Bias-free TopK-SAE) that would need to be plugged in to their corresponding B-cos-v2 checkpoints. All of our evaluation scripts take care of this. The correct B-cos-v2 checkpoint is downloaded based on the --arch argument that you pass.
All of the sample commands for this section (i.e model performance evaluation, concept consistency evaluation, and visualizations) are provided under analysis.sh. For all the evaluation scripts, if you mention --download v0.1 it would use our provided checkpoints, and if not, it would assume that you have trained your own and try to load it locally.
The fact.analysis.analysis evaluates the model accuracy and also collects activation and contribution statistics of concepts (over the test set). The statistics are required for the other evaluations below.
[Update] We have now added a minimal and standalone implementation of our concept-consistency metric (C2-Score), which you can easily port to your own codebase.
Using fact.analysis.dino_consistency you can measure how consistent the top-X % activations of the concepts are. Our metric uses DINOv2 features and upsamples them with LoftUP. You can either install LoftUP as a package, or have a clone of their repo in the root directory. You can also use any other upsampler, e.g. AnyUP. In principle, you can replace both the foundation model and up-sampler with other alternatives if you wish, as long as they perform well on semantic correpondence tasks.
The implementation of C2-Score is quite simple. We first need the foundation model with an upsampler (as done here). For a particular concept, we consider the top activating images, compute the DINO features (as done here), and finally compute the per-image feature vector with this function. Note that we use an attribution to take a weighted average of the features (to put emphasis on where the concept is looking). If you don't have any spatial attribution or activation map for your method, you can take a uniform weighting.
Once you have a set of dino features computed for the top-activating images of your concept, we measure the pairwise cosine similarity of the feature vectors (as done here). As discussed in the paper, it is important to consider a random baseline (a concept with random attribution and activaton on every image), to measure the inherent similarity of the probe dataset. For example, if you are evaluating your concept consistency on images of a single class, this will naturally increase the random baseline.
You can use fact.plotting.plot_inference to either visualize concepts or visualize the decision making, by measuring concept contributions. There are examples for both provided in the main function of fact.plotting.plot_inference. This code also relies on the statistics from the above, to know which images activate the concepts highest.
I'd more than happy to help you with any questions you have regarding the implementation or the paper :) Simply create an issue here or write me an email.
If you use our models, metric, or implementation, kindly cite us under following:
@inproceedings{
parchami2025fact,
title={Fa{CT}: Faithful Concept Traces for Explaining Neural Network Decisions},
author={Amin Parchami-Araghi and Sukrut Rao and Jonas Fischer and Bernt Schiele},
booktitle={The Thirty-ninth Annual Conference on Neural Information Processing Systems},
year={2025},
}