{"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/the-neural-data-router-adaptive-control-flow","title":"The Neural Data Router: Adaptive Control Flow in Transformers Improves Systematic Generalization","arxiv_id":"2110.07732","date":"2021-10-14","proceeding":null,"authors":["Róbert Csordás","Kazuki Irie","Jürgen Schmidhuber"],"abstract":"Despite progress across a broad range of applications, Transformers have limited success in systematic generalization. The situation is especially frustrating in the case of algorithmic tasks, where they often fail to find intuitive solutions that route relevant information to the right node/operation at the right time in the grid represented by Transformer columns. To facilitate the learning of useful control flow, we propose two modifications to the Transformer architecture, copy gate and geometric attention. Our novel Neural Data Router (NDR) achieves 100% length generalization accuracy on the classic compositional table lookup task, as well as near-perfect accuracy on the simple arithmetic task and a new variant of ListOps testing for generalization across computational depths. NDR's attention and gating patterns tend to be interpretable as an intuitive form of neural routing. Our code is public.","url_abs":"https://arxiv.org/abs/2110.07732v4","url_pdf":"https://arxiv.org/pdf/2110.07732v4.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":"the-neural-data-router-adaptive-control-flow","repo_url":"https://github.com/robertcsordas/ndr","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"listops","task_name":"ListOps"},{"task_slug":"systematic-generalization","task_name":"Systematic Generalization"}],"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":"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":{"syntology_url":"https://syntology.ai/paper/2110.07732","atlas_url":"https://app.syntology.ai/?focus=2110.07732","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2110.07732"}},"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":"deterministic:regex_extraction","url":"https://github.com/robertcsordas/ndr","reach":null}],"summary":{"ran":5,"ran_draft_wrong":1,"ran_violates":1,"unverified":4},"by_repo_kind":{"official":{"samples":11,"ran":7,"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":"28c21d66cc3361af","entry":"AttentionMask","repo":"robertcsordas/ndr","repo_kind":"official","path":"layers/transformer/ndr.py","file_url":"https://github.com/robertcsordas/ndr/blob/HEAD/layers/transformer/ndr.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"28c21d66cc3361af"}},{"code_sha256_prefix":"e0c7a1fa7f8f1165","entry":"LayerWithVisualization","repo":"robertcsordas/ndr","repo_kind":"official","path":"layers/transformer/ndr.py","file_url":"https://github.com/robertcsordas/ndr/blob/HEAD/layers/transformer/ndr.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e0c7a1fa7f8f1165"}},{"code_sha256_prefix":"51c7e36152503851","entry":"MultiHeadAttentionBase","repo":"robertcsordas/ndr","repo_kind":"official","path":"layers/transformer/ndr.py","file_url":"https://github.com/robertcsordas/ndr/blob/HEAD/layers/transformer/ndr.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"51c7e36152503851"}},{"code_sha256_prefix":"c9270f7c12e670a5","entry":"RegularizedLayer","repo":"robertcsordas/ndr","repo_kind":"official","path":"layers/transformer/ndr.py","file_url":"https://github.com/robertcsordas/ndr/blob/HEAD/layers/transformer/ndr.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":"c9270f7c12e670a5"}},{"code_sha256_prefix":"5cc9456646f6915c","entry":"RelativeAttentionBase","repo":"robertcsordas/ndr","repo_kind":"official","path":"layers/transformer/ndr.py","file_url":"https://github.com/robertcsordas/ndr/blob/HEAD/layers/transformer/ndr.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5cc9456646f6915c"}},{"code_sha256_prefix":"06cf617792cacde6","entry":"UniversalTransformerRandomLayerEncoderWithLayer","repo":"RobertCsordas/ndr","repo_kind":"official","path":"layers/transformer/ndr.py","file_url":"https://github.com/RobertCsordas/ndr/blob/HEAD/layers/transformer/ndr.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":"06cf617792cacde6"}},{"code_sha256_prefix":"fd07c4fcaa87fe04","entry":"shift","repo":"robertcsordas/ndr","repo_kind":"official","path":"layers/transformer/ndr.py","file_url":"https://github.com/robertcsordas/ndr/blob/HEAD/layers/transformer/ndr.py","link_basis":"first_harvest_node","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"fd07c4fcaa87fe04"}},{"code_sha256_prefix":"df234de93fadef4e","entry":"AttentionMergeMixin","repo":"robertcsordas/ndr","repo_kind":"official","path":"layers/transformer/ndr.py","file_url":"https://github.com/robertcsordas/ndr/blob/HEAD/layers/transformer/ndr.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":"df234de93fadef4e"}},{"code_sha256_prefix":"fc0009775b8227c6","entry":"FixedRelativeMultiheadAttention","repo":"robertcsordas/ndr","repo_kind":"official","path":"layers/transformer/ndr.py","file_url":"https://github.com/robertcsordas/ndr/blob/HEAD/layers/transformer/ndr.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":"fc0009775b8227c6"}},{"code_sha256_prefix":"1a1e99543d24b2e2","entry":"FixedRelativeMultiheadAttentionBase","repo":"robertcsordas/ndr","repo_kind":"official","path":"layers/transformer/ndr.py","file_url":"https://github.com/robertcsordas/ndr/blob/HEAD/layers/transformer/ndr.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":"1a1e99543d24b2e2"}},{"code_sha256_prefix":"ac16130612e4864a","entry":"NDRResidual","repo":"robertcsordas/ndr","repo_kind":"official","path":"layers/transformer/ndr.py","file_url":"https://github.com/robertcsordas/ndr/blob/HEAD/layers/transformer/ndr.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":"ac16130612e4864a"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}