{"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/monoformer-one-transformer-for-both-diffusion","title":"MonoFormer: One Transformer for Both Diffusion and Autoregression","arxiv_id":"2409.16280","date":"2024-09-24","proceeding":null,"authors":["Chuyang Zhao","Yuxing Song","Wenhao Wang","Haocheng Feng","Errui Ding","Yifan Sun","Xinyan Xiao","Jingdong Wang"],"abstract":"Most existing multimodality methods use separate backbones for autoregression-based discrete text generation and diffusion-based continuous visual generation, or the same backbone by discretizing the visual data to use autoregression for both text and visual generation. In this paper, we propose to study a simple idea: share one transformer for both autoregression and diffusion. The feasibility comes from two main aspects: (i) Transformer is successfully applied to diffusion for visual generation, and (ii) transformer training for autoregression and diffusion is very similar, and the difference merely lies in that diffusion uses bidirectional attention mask and autoregression uses causal attention mask. Experimental results show that our approach achieves comparable image generation performance to current state-of-the-art methods as well as maintains the text generation capability. The project is publicly available at https://monoformer.github.io/.","url_abs":"https://arxiv.org/abs/2409.16280v1","url_pdf":"https://arxiv.org/pdf/2409.16280v1.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":"monoformer-one-transformer-for-both-diffusion","repo_url":"https://github.com/MonoFormer/MonoFormer","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"image-generation","task_name":"Image Generation"},{"task_slug":"text-generation","task_name":"Text Generation"}],"methods":[{"method_slug":"absolute-position-encodings","method_name":"Absolute Position Encodings"},{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"diffusion","method_name":"Diffusion"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"label-smoothing","method_name":"Label Smoothing"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"position-wise-feed-forward-layer","method_name":"Position-Wise Feed-Forward Layer"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"transformer","method_name":"Transformer"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2409.16280","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2409.16280"}},"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/MonoFormer/MonoFormer","reach":{"status":"ok"}}],"summary":{"ran":3,"ran_draft_wrong":1,"ran_fixture":1,"unverified":3},"by_repo_kind":{"official":{"samples":8,"ran":5,"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":8,"samples":[{"code_sha256_prefix":"27c5a16fa884fb87","entry":"center_crop_arr","repo":"MonoFormer/MonoFormer","repo_kind":"official","path":"imgproc.py","file_url":"https://github.com/MonoFormer/MonoFormer/blob/HEAD/imgproc.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":"27c5a16fa884fb87"}},{"code_sha256_prefix":"7b21a01ae77703a3","entry":"create_npz_from_sample_folder","repo":"MonoFormer/MonoFormer","repo_kind":"official","path":"sample_ddp.py","file_url":"https://github.com/MonoFormer/MonoFormer/blob/HEAD/sample_ddp.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7b21a01ae77703a3"}},{"code_sha256_prefix":"e5947aba1d10885f","entry":"get_1d_sincos_pos_embed_from_grid","repo":"MonoFormer/MonoFormer","repo_kind":"official","path":"models/modeling.py","file_url":"https://github.com/MonoFormer/MonoFormer/blob/HEAD/models/modeling.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"e5947aba1d10885f"}},{"code_sha256_prefix":"5094d51ab076d069","entry":"preprocess_inputs","repo":"MonoFormer/MonoFormer","repo_kind":"official","path":"infer_llm.py","file_url":"https://github.com/MonoFormer/MonoFormer/blob/HEAD/infer_llm.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":"5094d51ab076d069"}},{"code_sha256_prefix":"9387a346aade06b9","entry":"resize_and_pad_image","repo":"MonoFormer/MonoFormer","repo_kind":"official","path":"imgproc.py","file_url":"https://github.com/MonoFormer/MonoFormer/blob/HEAD/imgproc.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":"9387a346aade06b9"}},{"code_sha256_prefix":"665d8a4e8f673a4c","entry":"get_2d_sincos_pos_embed_from_grid","repo":"MonoFormer/MonoFormer","repo_kind":"official","path":"models/modeling.py","file_url":"https://github.com/MonoFormer/MonoFormer/blob/HEAD/models/modeling.py","link_basis":"harvester_set","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":"665d8a4e8f673a4c"}},{"code_sha256_prefix":"427cd0bde9819614","entry":"modulate","repo":"MonoFormer/MonoFormer","repo_kind":"official","path":"models/monoformer.py","file_url":"https://github.com/MonoFormer/MonoFormer/blob/HEAD/models/monoformer.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":"427cd0bde9819614"}},{"code_sha256_prefix":"c6b51673a14dc067","entry":"read_config_from_file","repo":"MonoFormer/MonoFormer","repo_kind":"official","path":"config.py","file_url":"https://github.com/MonoFormer/MonoFormer/blob/HEAD/config.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":"c6b51673a14dc067"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}