{"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/reinforcement-learning-as-one-big-sequence","title":"Offline Reinforcement Learning as One Big Sequence Modeling Problem","arxiv_id":"2106.02039","date":"2021-06-03","proceeding":"NeurIPS 2021 12","authors":["Michael Janner","Qiyang Li","Sergey Levine"],"abstract":"Reinforcement learning (RL) is typically concerned with estimating stationary policies or single-step models, leveraging the Markov property to factorize problems in time. However, we can also view RL as a generic sequence modeling problem, with the goal being to produce a sequence of actions that leads to a sequence of high rewards. Viewed in this way, it is tempting to consider whether high-capacity sequence prediction models that work well in other domains, such as natural-language processing, can also provide effective solutions to the RL problem. To this end, we explore how RL can be tackled with the tools of sequence modeling, using a Transformer architecture to model distributions over trajectories and repurposing beam search as a planning algorithm. Framing RL as sequence modeling problem simplifies a range of design decisions, allowing us to dispense with many of the components common in offline RL algorithms. We demonstrate the flexibility of this approach across long-horizon dynamics prediction, imitation learning, goal-conditioned RL, and offline RL. Further, we show that this approach can be combined with existing model-free algorithms to yield a state-of-the-art planner in sparse-reward, long-horizon tasks.","url_abs":"https://arxiv.org/abs/2106.02039v4","url_pdf":"https://arxiv.org/pdf/2106.02039v4.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":"reinforcement-learning-as-one-big-sequence","repo_url":"https://github.com/JannerM/trajectory-transformer","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"reinforcement-learning-as-one-big-sequence","repo_url":"https://github.com/howuhh/faster-trajectory-transformer","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"imitation-learning","task_name":"Imitation Learning"},{"task_slug":"offline-rl","task_name":"Offline RL"},{"task_slug":"reinforcement-learning","task_name":"Reinforcement Learning"},{"task_slug":"reinforcement-learning-1","task_name":"Reinforcement Learning (RL)"},{"task_slug":"reinforcement-learning-2","task_name":"reinforcement-learning"}],"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=2106.02039","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2106.02039"}},"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/howuhh/faster-trajectory-transformer","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/JannerM/trajectory-transformer","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":1,"ran_honours":1,"ran_draft_wrong":1,"unverified":25},"by_repo_kind":{"official":{"samples":21,"ran":3,"repositories":1},"listed":{"samples":7,"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":"308e4d2dcc2d67f2","entry":"get_activation","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/models/mlp.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/models/mlp.py","link_basis":"plan_row","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":"308e4d2dcc2d67f2"}},{"code_sha256_prefix":"0e8d8251e66ab160","entry":"to_np","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/utils/arrays.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/utils/arrays.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0e8d8251e66ab160"}},{"code_sha256_prefix":"0f0021cdea13e4da","entry":"top_k_logits","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/search/sampling.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/search/sampling.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0f0021cdea13e4da"}},{"code_sha256_prefix":"f0bbd8cb02e1d63f","entry":"add_stop_token","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/models/embeddings.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/models/embeddings.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":"f0bbd8cb02e1d63f"}},{"code_sha256_prefix":"0164e9415395d715","entry":"ant_preprocess_fn","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/datasets/preprocessing.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/datasets/preprocessing.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":"0164e9415395d715"}},{"code_sha256_prefix":"f3d303190e64c4e4","entry":"beam_plan","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/search/core.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/search/core.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":"f3d303190e64c4e4"}},{"code_sha256_prefix":"c6b3fddb40879156","entry":"beam_search","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/search/core.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/search/core.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":"c6b3fddb40879156"}},{"code_sha256_prefix":"36bb7ea2ef4a54a3","entry":"create_env","repo":"howuhh/faster-trajectory-transformer","repo_kind":"listed","path":"trajectory/utils/env.py","file_url":"https://github.com/howuhh/faster-trajectory-transformer/blob/HEAD/trajectory/utils/env.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":"36bb7ea2ef4a54a3"}},{"code_sha256_prefix":"730393eba4e1cb7a","entry":"d4rl_dataset","repo":"howuhh/faster-trajectory-transformer","repo_kind":"listed","path":"trajectory/datasets/get_d4rl.py","file_url":"https://github.com/howuhh/faster-trajectory-transformer/blob/HEAD/trajectory/datasets/get_d4rl.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":"730393eba4e1cb7a"}},{"code_sha256_prefix":"9c84ff02a4f59c05","entry":"extract_actions","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/search/utils.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/search/utils.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":"9c84ff02a4f59c05"}},{"code_sha256_prefix":"c2129c72e2f07f7f","entry":"filter_cdf","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/search/sampling.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/search/sampling.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":"c2129c72e2f07f7f"}},{"code_sha256_prefix":"12754b16911ecee4","entry":"flatten","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/models/mlp.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/models/mlp.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":"12754b16911ecee4"}},{"code_sha256_prefix":"8fe2aea76aedd71b","entry":"join_trajectory","repo":"howuhh/faster-trajectory-transformer","repo_kind":"listed","path":"trajectory/datasets/d4rl_dataset.py","file_url":"https://github.com/howuhh/faster-trajectory-transformer/blob/HEAD/trajectory/datasets/d4rl_dataset.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":"8fe2aea76aedd71b"}},{"code_sha256_prefix":"d3a9e7f0b010aa47","entry":"kitchen_preprocess_fn","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/datasets/preprocessing.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/datasets/preprocessing.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":"d3a9e7f0b010aa47"}},{"code_sha256_prefix":"8368faab224d9322","entry":"load_environment","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/datasets/d4rl.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/datasets/d4rl.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":"8368faab224d9322"}},{"code_sha256_prefix":"6dafa63552e84e1c","entry":"make_prefix","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/search/utils.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/search/utils.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":"6dafa63552e84e1c"}},{"code_sha256_prefix":"73db3cbbc056327e","entry":"make_weights","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/models/embeddings.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/models/embeddings.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":"73db3cbbc056327e"}},{"code_sha256_prefix":"e256f0dfb18dd284","entry":"normalize","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/utils/arrays.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/utils/arrays.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":"e256f0dfb18dd284"}},{"code_sha256_prefix":"47b8a48fc0f2ac80","entry":"qlearning_dataset_with_timeouts","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/datasets/d4rl.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/datasets/d4rl.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":"47b8a48fc0f2ac80"}},{"code_sha256_prefix":"35aa466eb16f5e15","entry":"round_to_multiple","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/search/sampling.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/search/sampling.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":"35aa466eb16f5e15"}},{"code_sha256_prefix":"e58135c9c7b6ed0e","entry":"round_to_multiple","repo":"howuhh/faster-trajectory-transformer","repo_kind":"listed","path":"trajectory/utils/common.py","file_url":"https://github.com/howuhh/faster-trajectory-transformer/blob/HEAD/trajectory/utils/common.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":"e58135c9c7b6ed0e"}},{"code_sha256_prefix":"48bd963796baa6f4","entry":"segment","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/datasets/sequence.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/datasets/sequence.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":"48bd963796baa6f4"}},{"code_sha256_prefix":"53c137a7abd88735","entry":"segment","repo":"howuhh/faster-trajectory-transformer","repo_kind":"listed","path":"trajectory/datasets/d4rl_dataset.py","file_url":"https://github.com/howuhh/faster-trajectory-transformer/blob/HEAD/trajectory/datasets/d4rl_dataset.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":"53c137a7abd88735"}},{"code_sha256_prefix":"429e141abcf66681","entry":"to_torch","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/utils/arrays.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/utils/arrays.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":"429e141abcf66681"}},{"code_sha256_prefix":"c7cbcd467cc49a53","entry":"top_k_logits","repo":"howuhh/faster-trajectory-transformer","repo_kind":"listed","path":"trajectory/utils/common.py","file_url":"https://github.com/howuhh/faster-trajectory-transformer/blob/HEAD/trajectory/utils/common.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":"c7cbcd467cc49a53"}},{"code_sha256_prefix":"6ba529c9388c1d12","entry":"update_context","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/search/utils.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/search/utils.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":"6ba529c9388c1d12"}},{"code_sha256_prefix":"3e098abac7794b97","entry":"vmap","repo":"JannerM/trajectory-transformer","repo_kind":"official","path":"trajectory/datasets/preprocessing.py","file_url":"https://github.com/JannerM/trajectory-transformer/blob/HEAD/trajectory/datasets/preprocessing.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":"3e098abac7794b97"}},{"code_sha256_prefix":"ae1cccd21623b2cc","entry":"weight_decay_groups","repo":"howuhh/faster-trajectory-transformer","repo_kind":"listed","path":"trajectory/utils/common.py","file_url":"https://github.com/howuhh/faster-trajectory-transformer/blob/HEAD/trajectory/utils/common.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":"ae1cccd21623b2cc"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}