{"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/classifier-free-diffusion-guidance","title":"Classifier-Free Diffusion Guidance","arxiv_id":"2207.12598","date":"2022-07-26","proceeding":null,"authors":["Jonathan Ho","Tim Salimans"],"abstract":"Classifier guidance is a recently introduced method to trade off mode coverage and sample fidelity in conditional diffusion models post training, in the same spirit as low temperature sampling or truncation in other types of generative models. Classifier guidance combines the score estimate of a diffusion model with the gradient of an image classifier and thereby requires training an image classifier separate from the diffusion model. It also raises the question of whether guidance can be performed without a classifier. We show that guidance can be indeed performed by a pure generative model without such a classifier: in what we call classifier-free guidance, we jointly train a conditional and an unconditional diffusion model, and we combine the resulting conditional and unconditional score estimates to attain a trade-off between sample quality and diversity similar to that obtained using classifier guidance.","url_abs":"https://arxiv.org/abs/2207.12598v1","url_pdf":"https://arxiv.org/pdf/2207.12598v1.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":"classifier-free-diffusion-guidance","repo_url":"https://github.com/DeepakSridhar/fgdm","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"NOASSERTION"}},{"paper_slug":"classifier-free-diffusion-guidance","repo_url":"https://github.com/alexmaols/elucd","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"classifier-free-diffusion-guidance","repo_url":"https://github.com/coderpiaobozhe/classifier-free-diffusion-guidance-Pytorch","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"classifier-free-diffusion-guidance","repo_url":"https://github.com/dewenzeng/clsp","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"classifier-free-diffusion-guidance","repo_url":"https://github.com/dzq84/MusicScore-script","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"classifier-free-diffusion-guidance","repo_url":"https://github.com/elodiegermani/style-transfer_diffusion","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"classifier-free-diffusion-guidance","repo_url":"https://github.com/g4vrel/DDPM","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"classifier-free-diffusion-guidance","repo_url":"https://github.com/kjsman/stable-diffusion-pytorch","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"classifier-free-diffusion-guidance","repo_url":"https://github.com/lucidrains/classifier-free-guidance-pytorch","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"classifier-free-diffusion-guidance","repo_url":"https://github.com/teapearce/conditional_diffusion_mnist","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"classifier-free-diffusion-guidance","repo_url":"https://github.com/Michedev/DDPM-Pytorch","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"diversity","task_name":"Diversity"}],"methods":[{"method_slug":"diffusion","method_name":"Diffusion"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2207.12598","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2207.12598"}},"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/dewenzeng/clsp","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/dzq84/MusicScore-script","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/alexmaols/elucd","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/g4vrel/DDPM","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/Michedev/DDPM-Pytorch","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/kjsman/stable-diffusion-pytorch","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/DeepakSridhar/fgdm","reach":{"status":"ok","spdx":"NOASSERTION"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/teapearce/conditional_diffusion_mnist","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/lucidrains/classifier-free-guidance-pytorch","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/coderpiaobozhe/classifier-free-diffusion-guidance-Pytorch","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/elodiegermani/style-transfer_diffusion","reach":null}],"summary":{"ran":14,"ran_draft_wrong":6,"ran_fixture":1,"unverified":9},"by_repo_kind":{"listed":{"samples":28,"ran":20,"repositories":4}},"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":4,"samples":[{"code_sha256_prefix":"fbf59f94fbb9dc9e","entry":"AttentionBlock","repo":"g4vrel/DDPM","repo_kind":"listed","path":"sample.py","file_url":"https://github.com/g4vrel/DDPM/blob/HEAD/sample.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"fbf59f94fbb9dc9e"}},{"code_sha256_prefix":"6a8336d50ac2b63a","entry":"ConditioningBlock","repo":"g4vrel/DDPM","repo_kind":"listed","path":"sample.py","file_url":"https://github.com/g4vrel/DDPM/blob/HEAD/sample.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6a8336d50ac2b63a"}},{"code_sha256_prefix":"f6bc6f9aea13d9b8","entry":"ContextUnet","repo":"elodiegermani/style-transfer_diffusion","repo_kind":"listed","path":"diffusion/c_ddpm.py","file_url":"https://github.com/elodiegermani/style-transfer_diffusion/blob/HEAD/diffusion/c_ddpm.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f6bc6f9aea13d9b8"}},{"code_sha256_prefix":"2cdc7e0af049b4ea","entry":"Downsample","repo":"g4vrel/DDPM","repo_kind":"listed","path":"sample.py","file_url":"https://github.com/g4vrel/DDPM/blob/HEAD/sample.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"2cdc7e0af049b4ea"}},{"code_sha256_prefix":"db6eecd6a0d6e2ab","entry":"EmbedFC","repo":"elodiegermani/style-transfer_diffusion","repo_kind":"listed","path":"diffusion/c_ddpm.py","file_url":"https://github.com/elodiegermani/style-transfer_diffusion/blob/HEAD/diffusion/c_ddpm.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"db6eecd6a0d6e2ab"}},{"code_sha256_prefix":"20e8dff4c32fb858","entry":"GaussianDiffusion","repo":"g4vrel/DDPM","repo_kind":"listed","path":"sample.py","file_url":"https://github.com/g4vrel/DDPM/blob/HEAD/sample.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"20e8dff4c32fb858"}},{"code_sha256_prefix":"105db34d26e2d338","entry":"GaussianDiffusionSampler","repo":"dewenzeng/clsp","repo_kind":"listed","path":"ddpm.py","file_url":"https://github.com/dewenzeng/clsp/blob/HEAD/ddpm.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":"105db34d26e2d338"}},{"code_sha256_prefix":"3845f2deb4ec0887","entry":"GuidedUnet","repo":"g4vrel/DDPM","repo_kind":"listed","path":"sample.py","file_url":"https://github.com/g4vrel/DDPM/blob/HEAD/sample.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3845f2deb4ec0887"}},{"code_sha256_prefix":"d46574b8bb2019c3","entry":"ResBlock","repo":"g4vrel/DDPM","repo_kind":"listed","path":"sample.py","file_url":"https://github.com/g4vrel/DDPM/blob/HEAD/sample.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d46574b8bb2019c3"}},{"code_sha256_prefix":"f78260a23a053cb4","entry":"ResidualConvBlock","repo":"elodiegermani/style-transfer_diffusion","repo_kind":"listed","path":"diffusion/c_ddpm.py","file_url":"https://github.com/elodiegermani/style-transfer_diffusion/blob/HEAD/diffusion/c_ddpm.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f78260a23a053cb4"}},{"code_sha256_prefix":"111b04642f50bdd2","entry":"UnetDown","repo":"elodiegermani/style-transfer_diffusion","repo_kind":"listed","path":"diffusion/c_ddpm.py","file_url":"https://github.com/elodiegermani/style-transfer_diffusion/blob/HEAD/diffusion/c_ddpm.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"111b04642f50bdd2"}},{"code_sha256_prefix":"a7308172779a61da","entry":"UnetUp","repo":"elodiegermani/style-transfer_diffusion","repo_kind":"listed","path":"diffusion/c_ddpm.py","file_url":"https://github.com/elodiegermani/style-transfer_diffusion/blob/HEAD/diffusion/c_ddpm.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a7308172779a61da"}},{"code_sha256_prefix":"24cbc2ae131f9498","entry":"Upsample","repo":"g4vrel/DDPM","repo_kind":"listed","path":"sample.py","file_url":"https://github.com/g4vrel/DDPM/blob/HEAD/sample.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"24cbc2ae131f9498"}},{"code_sha256_prefix":"982a69b452b3abeb","entry":"create_bytes_table","repo":"kjsman/stable-diffusion-pytorch","repo_kind":"listed","path":"stable_diffusion_pytorch/pipeline.py","file_url":"https://github.com/kjsman/stable-diffusion-pytorch/blob/HEAD/stable_diffusion_pytorch/pipeline.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"982a69b452b3abeb"}},{"code_sha256_prefix":"1c539f5aa6ca79d2","entry":"ddpm_schedules","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"1c539f5aa6ca79d2"}},{"code_sha256_prefix":"411e30457e916104","entry":"extract","repo":"dewenzeng/clsp","repo_kind":"listed","path":"ddpm.py","file_url":"https://github.com/dewenzeng/clsp/blob/HEAD/ddpm.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"411e30457e916104"}},{"code_sha256_prefix":"f9a074c3439ca741","entry":"get_timestep_embedding","repo":"g4vrel/DDPM","repo_kind":"listed","path":"sample.py","file_url":"https://github.com/g4vrel/DDPM/blob/HEAD/sample.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f9a074c3439ca741"}},{"code_sha256_prefix":"fc896cf6190912f4","entry":"make_attn","repo":"g4vrel/DDPM","repo_kind":"listed","path":"sample.py","file_url":"https://github.com/g4vrel/DDPM/blob/HEAD/sample.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"fc896cf6190912f4"}},{"code_sha256_prefix":"df8230699cd28a82","entry":"make_block","repo":"g4vrel/DDPM","repo_kind":"listed","path":"sample.py","file_url":"https://github.com/g4vrel/DDPM/blob/HEAD/sample.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"df8230699cd28a82"}},{"code_sha256_prefix":"883c1ab882e33f3b","entry":"make_skip_connection","repo":"g4vrel/DDPM","repo_kind":"listed","path":"sample.py","file_url":"https://github.com/g4vrel/DDPM/blob/HEAD/sample.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"883c1ab882e33f3b"}},{"code_sha256_prefix":"df31b88dfd9608ff","entry":"pairwise","repo":"kjsman/stable-diffusion-pytorch","repo_kind":"listed","path":"stable_diffusion_pytorch/pipeline.py","file_url":"https://github.com/kjsman/stable-diffusion-pytorch/blob/HEAD/stable_diffusion_pytorch/pipeline.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"df31b88dfd9608ff"}},{"code_sha256_prefix":"0da20a659b48b38f","entry":"DDPM","repo":"elodiegermani/style-transfer_diffusion","repo_kind":"listed","path":"diffusion/c_ddpm.py","file_url":"https://github.com/elodiegermani/style-transfer_diffusion/blob/HEAD/diffusion/c_ddpm.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":"0da20a659b48b38f"}},{"code_sha256_prefix":"2334501499153205","entry":"KEulerAncestralSampler","repo":"kjsman/stable-diffusion-pytorch","repo_kind":"listed","path":"stable_diffusion_pytorch/pipeline.py","file_url":"https://github.com/kjsman/stable-diffusion-pytorch/blob/HEAD/stable_diffusion_pytorch/pipeline.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":"2334501499153205"}},{"code_sha256_prefix":"7be7f5500c629aa9","entry":"KEulerSampler","repo":"kjsman/stable-diffusion-pytorch","repo_kind":"listed","path":"stable_diffusion_pytorch/pipeline.py","file_url":"https://github.com/kjsman/stable-diffusion-pytorch/blob/HEAD/stable_diffusion_pytorch/pipeline.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":"7be7f5500c629aa9"}},{"code_sha256_prefix":"670bc184479669c7","entry":"KLMSSampler","repo":"kjsman/stable-diffusion-pytorch","repo_kind":"listed","path":"stable_diffusion_pytorch/pipeline.py","file_url":"https://github.com/kjsman/stable-diffusion-pytorch/blob/HEAD/stable_diffusion_pytorch/pipeline.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":"670bc184479669c7"}},{"code_sha256_prefix":"05ee784f97ca2b95","entry":"Tokenizer","repo":"kjsman/stable-diffusion-pytorch","repo_kind":"listed","path":"stable_diffusion_pytorch/pipeline.py","file_url":"https://github.com/kjsman/stable-diffusion-pytorch/blob/HEAD/stable_diffusion_pytorch/pipeline.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":"05ee784f97ca2b95"}},{"code_sha256_prefix":"9fbf646e18eed1db","entry":"ablation_sampler","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"9fbf646e18eed1db"}},{"code_sha256_prefix":"f3f744a1397430c9","entry":"generate","repo":"kjsman/stable-diffusion-pytorch","repo_kind":"listed","path":"stable_diffusion_pytorch/pipeline.py","file_url":"https://github.com/kjsman/stable-diffusion-pytorch/blob/HEAD/stable_diffusion_pytorch/pipeline.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":"f3f744a1397430c9"}},{"code_sha256_prefix":"519cace55bd6c411","entry":"make_mask","repo":"g4vrel/DDPM","repo_kind":"listed","path":"sample.py","file_url":"https://github.com/g4vrel/DDPM/blob/HEAD/sample.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":"519cace55bd6c411"}},{"code_sha256_prefix":"967f89e7cb02bdf9","entry":"sample_guidance","repo":"g4vrel/DDPM","repo_kind":"listed","path":"sample.py","file_url":"https://github.com/g4vrel/DDPM/blob/HEAD/sample.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":"967f89e7cb02bdf9"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}