{"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/beyond-a-better-planning-with-transformers","title":"Beyond A*: Better Planning with Transformers via Search Dynamics Bootstrapping","arxiv_id":"2402.14083","date":"2024-02-21","proceeding":null,"authors":["Lucas Lehnert","Sainbayar Sukhbaatar","DiJia Su","Qinqing Zheng","Paul McVay","Michael Rabbat","Yuandong Tian"],"abstract":"While Transformers have enabled tremendous progress in various application settings, such architectures still trail behind traditional symbolic planners for solving complex decision making tasks. In this work, we demonstrate how to train Transformers to solve complex planning tasks. This is accomplished by training an encoder-decoder Transformer model to predict the search dynamics of the $A^*$ search algorithm. We fine tune this model to obtain a Searchformer, a Transformer model that optimally solves previously unseen Sokoban puzzles 93.7% of the time, while using up to 26.8% fewer search steps than the $A^*$ implementation that was used for training initially. In our training method, $A^*$'s search dynamics are expressed as a token sequence outlining when task states are added and removed into the search tree during symbolic planning. Searchformer significantly outperforms baselines that predict the optimal plan directly with a 5-10$\\times$ smaller model size and a 10$\\times$ smaller training dataset. Lastly, we demonstrate how Searchformer scales to larger and more complex decision making tasks with improved percentage of solved tasks and shortened search dynamics.","url_abs":"https://arxiv.org/abs/2402.14083v2","url_pdf":"https://arxiv.org/pdf/2402.14083v2.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":"beyond-a-better-planning-with-transformers","repo_url":"https://github.com/facebookresearch/searchformer","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"NOASSERTION"}}],"tasks":[{"task_slug":"decision-making","task_name":"Decision Making"},{"task_slug":"decoder","task_name":"Decoder"},{"task_slug":"sokoban","task_name":"Sokoban"}],"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":{"atlas_url":"https://app.syntology.ai/?focus=2402.14083","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2402.14083"}},"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/facebookresearch/searchformer","reach":{"status":"ok","spdx":"NOASSERTION"}}],"summary":{"ran":13,"unverified":1},"by_repo_kind":{"official":{"samples":14,"ran":13,"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":14,"samples":[{"code_sha256_prefix":"5d068b31b9254b5a","entry":"astar","repo":"facebookresearch/searchformer","repo_kind":"official","path":"searchformer/astar.py","file_url":"https://github.com/facebookresearch/searchformer/blob/HEAD/searchformer/astar.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"5d068b31b9254b5a"}},{"code_sha256_prefix":"e7297099a6671090","entry":"build_optimizer","repo":"facebookresearch/searchformer","repo_kind":"official","path":"searchformer/transformer/optim.py","file_url":"https://github.com/facebookresearch/searchformer/blob/HEAD/searchformer/transformer/optim.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"e7297099a6671090"}},{"code_sha256_prefix":"3a942bcaa7ded890","entry":"fixed_size_maze_dataset_name","repo":"facebookresearch/searchformer","repo_kind":"official","path":"searchformer/maze.py","file_url":"https://github.com/facebookresearch/searchformer/blob/HEAD/searchformer/maze.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"3a942bcaa7ded890"}},{"code_sha256_prefix":"2de53a847ce3ebdb","entry":"lr_constant","repo":"facebookresearch/searchformer","repo_kind":"official","path":"searchformer/transformer/optim.py","file_url":"https://github.com/facebookresearch/searchformer/blob/HEAD/searchformer/transformer/optim.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"2de53a847ce3ebdb"}},{"code_sha256_prefix":"b5030440560f7a3c","entry":"lr_cosine","repo":"facebookresearch/searchformer","repo_kind":"official","path":"searchformer/transformer/optim.py","file_url":"https://github.com/facebookresearch/searchformer/blob/HEAD/searchformer/transformer/optim.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"b5030440560f7a3c"}},{"code_sha256_prefix":"e6efc6bfc4f2862d","entry":"manhattan_distance","repo":"facebookresearch/searchformer","repo_kind":"official","path":"searchformer/sokoban.py","file_url":"https://github.com/facebookresearch/searchformer/blob/HEAD/searchformer/sokoban.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"e6efc6bfc4f2862d"}},{"code_sha256_prefix":"21203a2dc99cc011","entry":"num_model_parameters","repo":"facebookresearch/searchformer","repo_kind":"official","path":"searchformer/transformer/utils.py","file_url":"https://github.com/facebookresearch/searchformer/blob/HEAD/searchformer/transformer/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"21203a2dc99cc011"}},{"code_sha256_prefix":"f12b7a7b213cf517","entry":"repeat_kv","repo":"facebookresearch/searchformer","repo_kind":"official","path":"searchformer/transformer/model.py","file_url":"https://github.com/facebookresearch/searchformer/blob/HEAD/searchformer/transformer/model.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"f12b7a7b213cf517"}},{"code_sha256_prefix":"099db59e5044649b","entry":"sample_greedy","repo":"facebookresearch/searchformer","repo_kind":"official","path":"searchformer/transformer/utils.py","file_url":"https://github.com/facebookresearch/searchformer/blob/HEAD/searchformer/transformer/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"099db59e5044649b"}},{"code_sha256_prefix":"90652748c49c021a","entry":"sample_probability","repo":"facebookresearch/searchformer","repo_kind":"official","path":"searchformer/transformer/utils.py","file_url":"https://github.com/facebookresearch/searchformer/blob/HEAD/searchformer/transformer/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"90652748c49c021a"}},{"code_sha256_prefix":"22d075deea2c904a","entry":"sokoban_state_to_pretty_string","repo":"facebookresearch/searchformer","repo_kind":"official","path":"searchformer/sokoban.py","file_url":"https://github.com/facebookresearch/searchformer/blob/HEAD/searchformer/sokoban.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"22d075deea2c904a"}},{"code_sha256_prefix":"c30029071ba9902f","entry":"sokoban_state_to_string","repo":"facebookresearch/searchformer","repo_kind":"official","path":"searchformer/sokoban.py","file_url":"https://github.com/facebookresearch/searchformer/blob/HEAD/searchformer/sokoban.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"c30029071ba9902f"}},{"code_sha256_prefix":"3b7d3d5ef085446a","entry":"split_df_columns_to_value","repo":"facebookresearch/searchformer","repo_kind":"official","path":"searchformer/utils.py","file_url":"https://github.com/facebookresearch/searchformer/blob/HEAD/searchformer/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"3b7d3d5ef085446a"}},{"code_sha256_prefix":"31adf392ad5e3e28","entry":"sequence_mask_to_attention_mask","repo":"facebookresearch/searchformer","repo_kind":"official","path":"searchformer/transformer/model.py","file_url":"https://github.com/facebookresearch/searchformer/blob/HEAD/searchformer/transformer/model.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"31adf392ad5e3e28"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}