{"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/interventional-and-counterfactual-inference","title":"Modeling Causal Mechanisms with Diffusion Models for Interventional and Counterfactual Queries","arxiv_id":"2302.00860","date":"2023-02-02","proceeding":null,"authors":["Patrick Chao","Patrick Blöbaum","Sapan Patel","Shiva Prasad Kasiviswanathan"],"abstract":"We consider the problem of answering observational, interventional, and counterfactual queries in a causally sufficient setting where only observational data and the causal graph are available. Utilizing the recent developments in diffusion models, we introduce diffusion-based causal models (DCM) to learn causal mechanisms, that generate unique latent encodings. These encodings enable us to directly sample under interventions and perform abduction for counterfactuals. Diffusion models are a natural fit here, since they can encode each node to a latent representation that acts as a proxy for exogenous noise. Our empirical evaluations demonstrate significant improvements over existing state-of-the-art methods for answering causal queries. Furthermore, we provide theoretical results that offer a methodology for analyzing counterfactual estimation in general encoder-decoder models, which could be useful in settings beyond our proposed approach.","url_abs":"https://arxiv.org/abs/2302.00860v3","url_pdf":"https://arxiv.org/pdf/2302.00860v3.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":"interventional-and-counterfactual-inference","repo_url":"https://github.com/patrickrchao/diffusionbasedcausalmodels","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"interventional-and-counterfactual-inference","repo_url":"https://github.com/tatsu432/BDCM","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"counterfactual-inference","task_name":"Counterfactual Inference"},{"task_slug":"decoder","task_name":"Decoder"},{"task_slug":null,"task_name":"counterfactual"}],"methods":[{"method_slug":"diffusion","method_name":"Diffusion"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2302.00860","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2302.00860"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+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/patrickrchao/diffusionbasedcausalmodels","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/tatsu432/BDCM","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_honours":1,"unverified":11},"by_repo_kind":{"official":{"samples":4,"ran":1,"repositories":1},"listed":{"samples":8,"ran":0,"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":0,"samples":[{"code_sha256_prefix":"ffedaa6f5d9645d7","entry":"get_train_data","repo":"patrickrchao/diffusionbasedcausalmodels","repo_kind":"official","path":"all_exp.py","file_url":"https://github.com/patrickrchao/diffusionbasedcausalmodels/blob/HEAD/all_exp.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ffedaa6f5d9645d7"}},{"code_sha256_prefix":"a63a5a850576074d","entry":"build_diffusion_schedule","repo":"tatsu432/BDCM","repo_kind":"listed","path":"src/bdcm/config.py","file_url":"https://github.com/tatsu432/BDCM/blob/HEAD/src/bdcm/config.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a63a5a850576074d"}},{"code_sha256_prefix":"f510fd2b496d5b89","entry":"compose_config","repo":"tatsu432/BDCM","repo_kind":"listed","path":"src/bdcm/hydra_config.py","file_url":"https://github.com/tatsu432/BDCM/blob/HEAD/src/bdcm/hydra_config.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f510fd2b496d5b89"}},{"code_sha256_prefix":"a013316d618bdcde","entry":"config_summary","repo":"tatsu432/BDCM","repo_kind":"listed","path":"src/bdcm/hydra_config.py","file_url":"https://github.com/tatsu432/BDCM/blob/HEAD/src/bdcm/hydra_config.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a013316d618bdcde"}},{"code_sha256_prefix":"9e4e0b99a3c337ca","entry":"convert_data_to_pandas","repo":"patrickrchao/diffusionbasedcausalmodels","repo_kind":"official","path":"all_exp.py","file_url":"https://github.com/patrickrchao/diffusionbasedcausalmodels/blob/HEAD/all_exp.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9e4e0b99a3c337ca"}},{"code_sha256_prefix":"66a5d053ccc3be6e","entry":"convert_numpy_to_torch","repo":"patrickrchao/diffusionbasedcausalmodels","repo_kind":"official","path":"model/diffusion.py","file_url":"https://github.com/patrickrchao/diffusionbasedcausalmodels/blob/HEAD/model/diffusion.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"66a5d053ccc3be6e"}},{"code_sha256_prefix":"f52e9c858becf668","entry":"create_input_1","repo":"tatsu432/BDCM","repo_kind":"listed","path":"src/bdcm/infrastructure/diffusion.py","file_url":"https://github.com/tatsu432/BDCM/blob/HEAD/src/bdcm/infrastructure/diffusion.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f52e9c858becf668"}},{"code_sha256_prefix":"e4882eb143ebe45c","entry":"experiment_config_from_omegaconf","repo":"tatsu432/BDCM","repo_kind":"listed","path":"src/bdcm/config.py","file_url":"https://github.com/tatsu432/BDCM/blob/HEAD/src/bdcm/config.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e4882eb143ebe45c"}},{"code_sha256_prefix":"44bde545b1a472e4","entry":"get_data_loader","repo":"patrickrchao/diffusionbasedcausalmodels","repo_kind":"official","path":"all_exp.py","file_url":"https://github.com/patrickrchao/diffusionbasedcausalmodels/blob/HEAD/all_exp.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"44bde545b1a472e4"}},{"code_sha256_prefix":"e1188dd6fec1ecd6","entry":"mmd","repo":"tatsu432/BDCM","repo_kind":"listed","path":"src/bdcm/infrastructure/mmd.py","file_url":"https://github.com/tatsu432/BDCM/blob/HEAD/src/bdcm/infrastructure/mmd.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e1188dd6fec1ecd6"}},{"code_sha256_prefix":"ce0be3a33a19fd30","entry":"normalize","repo":"tatsu432/BDCM","repo_kind":"listed","path":"src/bdcm/infrastructure/diffusion.py","file_url":"https://github.com/tatsu432/BDCM/blob/HEAD/src/bdcm/infrastructure/diffusion.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ce0be3a33a19fd30"}},{"code_sha256_prefix":"420cc879345f3b2e","entry":"save_array","repo":"tatsu432/BDCM","repo_kind":"listed","path":"src/bdcm/infrastructure/evaluation.py","file_url":"https://github.com/tatsu432/BDCM/blob/HEAD/src/bdcm/infrastructure/evaluation.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"420cc879345f3b2e"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}