{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/climbing-the-ladder-of-interpretability-with","title":"Counterfactual Concept Bottleneck Models","arxiv_id":"2402.01408","date":"2024-02-02","proceeding":null,"authors":["Gabriele Dominici","Pietro Barbiero","Francesco Giannini","Martin Gjoreski","Giuseppe Marra","Marc Langheinrich"],"abstract":"Current deep learning models are not designed to simultaneously address three fundamental questions: predict class labels to solve a given classification task (the \"What?\"), simulate changes in the situation to evaluate how this impacts class predictions (the \"How?\"), and imagine how the scenario should change to result in different class predictions (the \"Why not?\"). The inability to answer these questions represents a crucial gap in deploying reliable AI agents, calibrating human trust, and improving human-machine interaction. To bridge this gap, we introduce CounterFactual Concept Bottleneck Models (CF-CBMs), a class of models designed to efficiently address the above queries all at once without the need to run post-hoc searches. Our experimental results demonstrate that CF-CBMs: achieve classification accuracy comparable to black-box models and existing CBMs (\"What?\"), rely on fewer important concepts leading to simpler explanations (\"How?\"), and produce interpretable, concept-based counterfactuals (\"Why not?\"). Additionally, we show that training the counterfactual generator jointly with the CBM leads to two key improvements: (i) it alters the model's decision-making process, making the model rely on fewer important concepts (leading to simpler explanations), and (ii) it significantly increases the causal effect of concept interventions on class predictions, making the model more responsive to these changes.","url_abs":"https://arxiv.org/abs/2402.01408v2","url_pdf":"https://arxiv.org/pdf/2402.01408v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"climbing-the-ladder-of-interpretability-with","repo_url":"https://github.com/gabriele-dominici/counterfactual-cbm","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"decision-making","task_name":"Decision Making"},{"task_slug":null,"task_name":"counterfactual"}],"methods":[{"method_slug":"counterfactuals","method_name":"Counterfactuals"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2402.01408","atlas_url":"https://app.syntology.ai/?focus=2402.01408","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2402.01408"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/gabriele-dominici/counterfactual-cbm","reach":{"status":"ok"}}],"summary":{"ran":12,"unverified":4},"by_repo_kind":{"official":{"samples":16,"ran":12,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":16,"samples":[{"code_sha256_prefix":"b6a6628cdfc08742","entry":"EI","repo":"gabriele-dominici/counterfactual-cbm","repo_kind":"official","path":"baycon/baycon/acquisition_functions.py","file_url":"https://github.com/gabriele-dominici/counterfactual-cbm/blob/HEAD/baycon/baycon/acquisition_functions.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b6a6628cdfc08742"}},{"code_sha256_prefix":"c0dd3d59e18c2e97","entry":"PI","repo":"gabriele-dominici/counterfactual-cbm","repo_kind":"official","path":"baycon/baycon/acquisition_functions.py","file_url":"https://github.com/gabriele-dominici/counterfactual-cbm/blob/HEAD/baycon/baycon/acquisition_functions.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c0dd3d59e18c2e97"}},{"code_sha256_prefix":"12aa7a459caa41dc","entry":"UCB","repo":"gabriele-dominici/counterfactual-cbm","repo_kind":"official","path":"baycon/baycon/acquisition_functions.py","file_url":"https://github.com/gabriele-dominici/counterfactual-cbm/blob/HEAD/baycon/baycon/acquisition_functions.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"12aa7a459caa41dc"}},{"code_sha256_prefix":"e5a8875083f3d66c","entry":"extract_concepts","repo":"gabriele-dominici/counterfactual-cbm","repo_kind":"official","path":"ccbm/utils.py","file_url":"https://github.com/gabriele-dominici/counterfactual-cbm/blob/HEAD/ccbm/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"e5a8875083f3d66c"}},{"code_sha256_prefix":"e21532e86b163c25","entry":"filter_outliers","repo":"gabriele-dominici/counterfactual-cbm","repo_kind":"official","path":"baycon/baycon/bayesian_generator.py","file_url":"https://github.com/gabriele-dominici/counterfactual-cbm/blob/HEAD/baycon/baycon/bayesian_generator.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"e21532e86b163c25"}},{"code_sha256_prefix":"5ca94368a93ee4e7","entry":"hinge_loss","repo":"gabriele-dominici/counterfactual-cbm","repo_kind":"official","path":"ccbm/models.py","file_url":"https://github.com/gabriele-dominici/counterfactual-cbm/blob/HEAD/ccbm/models.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"5ca94368a93ee4e7"}},{"code_sha256_prefix":"b7d0860747dbad15","entry":"intersection_over_union","repo":"gabriele-dominici/counterfactual-cbm","repo_kind":"official","path":"ccbm/metrics.py","file_url":"https://github.com/gabriele-dominici/counterfactual-cbm/blob/HEAD/ccbm/metrics.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b7d0860747dbad15"}},{"code_sha256_prefix":"c0863e960752f7f5","entry":"randomize_class","repo":"gabriele-dominici/counterfactual-cbm","repo_kind":"official","path":"ccbm/utils.py","file_url":"https://github.com/gabriele-dominici/counterfactual-cbm/blob/HEAD/ccbm/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c0863e960752f7f5"}},{"code_sha256_prefix":"2b68d4e9b71800ad","entry":"scale","repo":"gabriele-dominici/counterfactual-cbm","repo_kind":"official","path":"baycon/common/DataAnalyzer.py","file_url":"https://github.com/gabriele-dominici/counterfactual-cbm/blob/HEAD/baycon/common/DataAnalyzer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"2b68d4e9b71800ad"}},{"code_sha256_prefix":"6d9ff45b5f74b1d7","entry":"score_y_away_from_target","repo":"gabriele-dominici/counterfactual-cbm","repo_kind":"official","path":"baycon/common/ScoreCalculator.py","file_url":"https://github.com/gabriele-dominici/counterfactual-cbm/blob/HEAD/baycon/common/ScoreCalculator.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6d9ff45b5f74b1d7"}},{"code_sha256_prefix":"12a80c0bb92deeca","entry":"score_y_reaching_target","repo":"gabriele-dominici/counterfactual-cbm","repo_kind":"official","path":"baycon/common/ScoreCalculator.py","file_url":"https://github.com/gabriele-dominici/counterfactual-cbm/blob/HEAD/baycon/common/ScoreCalculator.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"12a80c0bb92deeca"}},{"code_sha256_prefix":"db27655f907743ca","entry":"variability","repo":"gabriele-dominici/counterfactual-cbm","repo_kind":"official","path":"ccbm/metrics.py","file_url":"https://github.com/gabriele-dominici/counterfactual-cbm/blob/HEAD/ccbm/metrics.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"db27655f907743ca"}},{"code_sha256_prefix":"a1c54e25ee630b04","entry":"cf_in_distribution","repo":"gabriele-dominici/counterfactual-cbm","repo_kind":"official","path":"ccbm/metrics.py","file_url":"https://github.com/gabriele-dominici/counterfactual-cbm/blob/HEAD/ccbm/metrics.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a1c54e25ee630b04"}},{"code_sha256_prefix":"3c06307d039c83ce","entry":"encode","repo":"gabriele-dominici/counterfactual-cbm","repo_kind":"official","path":"baycon/common/DataAnalyzer.py","file_url":"https://github.com/gabriele-dominici/counterfactual-cbm/blob/HEAD/baycon/common/DataAnalyzer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3c06307d039c83ce"}},{"code_sha256_prefix":"5a99191dfe200ab1","entry":"load_data","repo":"gabriele-dominici/counterfactual-cbm","repo_kind":"official","path":"ccbm/utils.py","file_url":"https://github.com/gabriele-dominici/counterfactual-cbm/blob/HEAD/ccbm/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"5a99191dfe200ab1"}},{"code_sha256_prefix":"b5cb8a79e23ce469","entry":"sample_different_label","repo":"gabriele-dominici/counterfactual-cbm","repo_kind":"official","path":"ccbm/baycon.py","file_url":"https://github.com/gabriele-dominici/counterfactual-cbm/blob/HEAD/ccbm/baycon.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b5cb8a79e23ce469"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}