{"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/agentformer-agent-aware-transformers-for","title":"AgentFormer: Agent-Aware Transformers for Socio-Temporal Multi-Agent Forecasting","arxiv_id":"2103.14023","date":"2021-03-25","proceeding":"ICCV 2021 10","authors":["Ye Yuan","Xinshuo Weng","Yanglan Ou","Kris Kitani"],"abstract":"Predicting accurate future trajectories of multiple agents is essential for autonomous systems, but is challenging due to the complex agent interaction and the uncertainty in each agent's future behavior. Forecasting multi-agent trajectories requires modeling two key dimensions: (1) time dimension, where we model the influence of past agent states over future states; (2) social dimension, where we model how the state of each agent affects others. Most prior methods model these two dimensions separately, e.g., first using a temporal model to summarize features over time for each agent independently and then modeling the interaction of the summarized features with a social model. This approach is suboptimal since independent feature encoding over either the time or social dimension can result in a loss of information. Instead, we would prefer a method that allows an agent's state at one time to directly affect another agent's state at a future time. To this end, we propose a new Transformer, AgentFormer, that jointly models the time and social dimensions. The model leverages a sequence representation of multi-agent trajectories by flattening trajectory features across time and agents. Since standard attention operations disregard the agent identity of each element in the sequence, AgentFormer uses a novel agent-aware attention mechanism that preserves agent identities by attending to elements of the same agent differently than elements of other agents. Based on AgentFormer, we propose a stochastic multi-agent trajectory prediction model that can attend to features of any agent at any previous timestep when inferring an agent's future position. The latent intent of all agents is also jointly modeled, allowing the stochasticity in one agent's behavior to affect other agents. Our method substantially improves the state of the art on well-established pedestrian and autonomous driving datasets.","url_abs":"https://arxiv.org/abs/2103.14023v3","url_pdf":"https://arxiv.org/pdf/2103.14023v3.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":"agentformer-agent-aware-transformers-for","repo_url":"https://github.com/Khrylx/AgentFormer","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"agentformer-agent-aware-transformers-for","repo_url":"https://github.com/zhanwei-z/g2ltraj","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"autonomous-driving","task_name":"Autonomous Driving"},{"task_slug":"pedestrian-trajectory-prediction","task_name":"Pedestrian Trajectory Prediction"},{"task_slug":"trajectory-forecasting","task_name":"Trajectory Forecasting"},{"task_slug":"trajectory-prediction","task_name":"Trajectory Prediction"}],"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":[{"leaderboard":"/sota/trajectory-prediction-on-ethucy","task":"Trajectory Prediction","dataset":"ETH/UCY","model":"AgentFomer","rank_in_archive_order":10,"of":20,"metrics":{"ADE-8/12":"0.23","FDE-8/12":"0.39"},"uses_additional_data":false},{"leaderboard":"/sota/trajectory-prediction-on-nuscenes","task":"Trajectory Prediction","dataset":"nuScenes","model":"AgentFormer","rank_in_archive_order":21,"of":34,"metrics":{"MinADE_10":"1.45","MinADE_5":"1.86"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2103.14023","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2103.14023"}},"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/Khrylx/AgentFormer","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/zhanwei-z/g2ltraj","reach":null}],"summary":{"ran_draft_wrong":2,"ran":2,"unverified":13},"by_repo_kind":{"official":{"samples":17,"ran":4,"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":"d9def42110729a85","entry":"conv1x1","repo":"Khrylx/AgentFormer","repo_kind":"official","path":"model/common/resnet.py","file_url":"https://github.com/Khrylx/AgentFormer/blob/HEAD/model/common/resnet.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":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d9def42110729a85"}},{"code_sha256_prefix":"160bb14bd76201b4","entry":"conv3x3","repo":"Khrylx/AgentFormer","repo_kind":"official","path":"model/common/resnet.py","file_url":"https://github.com/Khrylx/AgentFormer/blob/HEAD/model/common/resnet.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":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"160bb14bd76201b4"}},{"code_sha256_prefix":"1b373d997a81df48","entry":"generate_ar_mask","repo":"Khrylx/AgentFormer","repo_kind":"official","path":"model/agentformer.py","file_url":"https://github.com/Khrylx/AgentFormer/blob/HEAD/model/agentformer.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":"1b373d997a81df48"}},{"code_sha256_prefix":"66d9c97d20cb3bfd","entry":"generate_mask","repo":"Khrylx/AgentFormer","repo_kind":"official","path":"model/agentformer.py","file_url":"https://github.com/Khrylx/AgentFormer/blob/HEAD/model/agentformer.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":"66d9c97d20cb3bfd"}},{"code_sha256_prefix":"f6e42d1a52522ffb","entry":"batch_to","repo":"Khrylx/AgentFormer","repo_kind":"official","path":"utils/torch.py","file_url":"https://github.com/Khrylx/AgentFormer/blob/HEAD/utils/torch.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":"f6e42d1a52522ffb"}},{"code_sha256_prefix":"d328d7d027ef837d","entry":"compute_motion_mse","repo":"Khrylx/AgentFormer","repo_kind":"official","path":"model/agentformer_loss.py","file_url":"https://github.com/Khrylx/AgentFormer/blob/HEAD/model/agentformer_loss.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":"d328d7d027ef837d"}},{"code_sha256_prefix":"27e6bed86bfe75d0","entry":"compute_sample_loss","repo":"Khrylx/AgentFormer","repo_kind":"official","path":"model/agentformer_loss.py","file_url":"https://github.com/Khrylx/AgentFormer/blob/HEAD/model/agentformer_loss.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":"27e6bed86bfe75d0"}},{"code_sha256_prefix":"f19fb436bd1c1362","entry":"compute_z_kld","repo":"Khrylx/AgentFormer","repo_kind":"official","path":"model/agentformer_loss.py","file_url":"https://github.com/Khrylx/AgentFormer/blob/HEAD/model/agentformer_loss.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":"f19fb436bd1c1362"}},{"code_sha256_prefix":"7dd2a5c1f5974656","entry":"compute_z_kld","repo":"Khrylx/AgentFormer","repo_kind":"official","path":"model/dlow.py","file_url":"https://github.com/Khrylx/AgentFormer/blob/HEAD/model/dlow.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":"7dd2a5c1f5974656"}},{"code_sha256_prefix":"82eee2c876ef54f2","entry":"diversity_loss","repo":"Khrylx/AgentFormer","repo_kind":"official","path":"model/dlow.py","file_url":"https://github.com/Khrylx/AgentFormer/blob/HEAD/model/dlow.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":"82eee2c876ef54f2"}},{"code_sha256_prefix":"748ebf6d58779d56","entry":"get_flat_params_from","repo":"Khrylx/AgentFormer","repo_kind":"official","path":"utils/torch.py","file_url":"https://github.com/Khrylx/AgentFormer/blob/HEAD/utils/torch.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":"748ebf6d58779d56"}},{"code_sha256_prefix":"664e282ebf0d3ef6","entry":"isfloat","repo":"Khrylx/AgentFormer","repo_kind":"official","path":"utils/utils.py","file_url":"https://github.com/Khrylx/AgentFormer/blob/HEAD/utils/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":"664e282ebf0d3ef6"}},{"code_sha256_prefix":"7795043c27738a7a","entry":"isinteger","repo":"Khrylx/AgentFormer","repo_kind":"official","path":"utils/utils.py","file_url":"https://github.com/Khrylx/AgentFormer/blob/HEAD/utils/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":"7795043c27738a7a"}},{"code_sha256_prefix":"e58bf86f2419f13f","entry":"isnparray","repo":"Khrylx/AgentFormer","repo_kind":"official","path":"utils/utils.py","file_url":"https://github.com/Khrylx/AgentFormer/blob/HEAD/utils/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":"e58bf86f2419f13f"}},{"code_sha256_prefix":"7a165e35db87d53d","entry":"recon_loss","repo":"Khrylx/AgentFormer","repo_kind":"official","path":"model/dlow.py","file_url":"https://github.com/Khrylx/AgentFormer/blob/HEAD/model/dlow.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":"7a165e35db87d53d"}},{"code_sha256_prefix":"17abbd201c85e08b","entry":"resnet18","repo":"Khrylx/AgentFormer","repo_kind":"official","path":"model/common/resnet.py","file_url":"https://github.com/Khrylx/AgentFormer/blob/HEAD/model/common/resnet.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":"17abbd201c85e08b"}},{"code_sha256_prefix":"bf9596e8a6a6b696","entry":"rotation_2d_torch","repo":"Khrylx/AgentFormer","repo_kind":"official","path":"utils/torch.py","file_url":"https://github.com/Khrylx/AgentFormer/blob/HEAD/utils/torch.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":"bf9596e8a6a6b696"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}