{"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/lxmert-learning-cross-modality-encoder","title":"LXMERT: Learning Cross-Modality Encoder Representations from Transformers","arxiv_id":"1908.07490","date":"2019-08-20","proceeding":"IJCNLP 2019 11","authors":["Hao Tan","Mohit Bansal"],"abstract":"Vision-and-language reasoning requires an understanding of visual concepts, language semantics, and, most importantly, the alignment and relationships between these two modalities. We thus propose the LXMERT (Learning Cross-Modality Encoder Representations from Transformers) framework to learn these vision-and-language connections. In LXMERT, we build a large-scale Transformer model that consists of three encoders: an object relationship encoder, a language encoder, and a cross-modality encoder. Next, to endow our model with the capability of connecting vision and language semantics, we pre-train the model with large amounts of image-and-sentence pairs, via five diverse representative pre-training tasks: masked language modeling, masked object prediction (feature regression and label classification), cross-modality matching, and image question answering. These tasks help in learning both intra-modality and cross-modality relationships. After fine-tuning from our pre-trained parameters, our model achieves the state-of-the-art results on two visual question answering datasets (i.e., VQA and GQA). We also show the generalizability of our pre-trained cross-modality model by adapting it to a challenging visual-reasoning task, NLVR2, and improve the previous best result by 22% absolute (54% to 76%). Lastly, we demonstrate detailed ablation studies to prove that both our novel model components and pre-training strategies significantly contribute to our strong results; and also present several attention visualizations for the different encoders. Code and pre-trained models publicly available at: https://github.com/airsplay/lxmert","url_abs":"https://arxiv.org/abs/1908.07490v3","url_pdf":"https://arxiv.org/pdf/1908.07490v3.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":"lxmert-learning-cross-modality-encoder","repo_url":"https://github.com/airsplay/lxmert","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"lxmert-learning-cross-modality-encoder","repo_url":"https://github.com/chaitanyadwivedii/3D-Attention-is-All-You-Need","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"lxmert-learning-cross-modality-encoder","repo_url":"https://github.com/ghazaleh-mahmoodi/lxmert_compression","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"lxmert-learning-cross-modality-encoder","repo_url":"https://github.com/huggingface/transformers","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"lxmert-learning-cross-modality-encoder","repo_url":"https://github.com/itsShnik/adaptively-finetuning-transformers","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"lxmert-learning-cross-modality-encoder","repo_url":"https://github.com/social-ai-studio/matk","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"lxmert-learning-cross-modality-encoder","repo_url":"https://github.com/zhegan27/LXMERT-AdvTrain","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"lxmert-learning-cross-modality-encoder","repo_url":"https://github.com/zhegan27/VILLA","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"lxmert-learning-cross-modality-encoder","repo_url":"https://github.com/Mind23-2/MindCode-156","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":{"status":"ok"}}],"tasks":[{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"masked-language-modeling","task_name":"Masked Language Modeling"},{"task_slug":"question-answering","task_name":"Question Answering"},{"task_slug":"sentence","task_name":"Sentence"},{"task_slug":"visual-question-answering-1","task_name":"Visual Question Answering"},{"task_slug":"visual-question-answering","task_name":"Visual Question Answering (VQA)"},{"task_slug":"visual-reasoning","task_name":"Visual Reasoning"}],"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":"lxmert","method_name":"LXMERT"},{"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":"relu","method_name":"ReLU"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"transformer","method_name":"Transformer"}],"datasets_introduced":[],"methods_introduced":[{"slug":"lxmert","name":"LXMERT","full_name":"Learning Cross-Modality Encoder Representations from Transformers"}],"results":[{"leaderboard":"/sota/visual-question-answering-on-a-okvqa","task":"Visual Question Answering (VQA)","dataset":"A-OKVQA","model":"LXMERT","rank_in_archive_order":10,"of":15,"metrics":{"DA VQA Score":"25.9","MC Accuracy":"41.6"},"uses_additional_data":false},{"leaderboard":"/sota/visual-question-answering-on-gqa-test2019","task":"Visual Question Answering (VQA)","dataset":"GQA Test2019","model":"LXR955, Ensemble","rank_in_archive_order":15,"of":127,"metrics":{"Accuracy":"62.71","Binary":"79.79","Consistency":"93.1","Distribution":"6.42","Open":"47.64","Plausibility":"85.21","Validity":"96.36"},"uses_additional_data":false},{"leaderboard":"/sota/visual-question-answering-on-gqa-test2019","task":"Visual Question Answering (VQA)","dataset":"GQA Test2019","model":"LXR955, Single Model","rank_in_archive_order":36,"of":127,"metrics":{"Accuracy":"60.33","Binary":"77.16","Consistency":"89.59","Distribution":"5.69","Open":"45.47","Plausibility":"84.53","Validity":"96.35"},"uses_additional_data":false},{"leaderboard":"/sota/visual-question-answering-on-gqa-test-dev","task":"Visual Question Answering (VQA)","dataset":"GQA test-dev","model":"LXMERT (Pre-train + scratch)","rank_in_archive_order":7,"of":17,"metrics":{"Accuracy":"60.0"},"uses_additional_data":false},{"leaderboard":"/sota/visual-question-answering-on-gqa-test-std","task":"Visual Question Answering (VQA)","dataset":"GQA test-std","model":"LXMERT","rank_in_archive_order":4,"of":7,"metrics":{"Accuracy":"60.3"},"uses_additional_data":true},{"leaderboard":"/sota/visual-question-answering-on-vqa-v2-test-dev","task":"Visual Question Answering (VQA)","dataset":"VQA v2 test-dev","model":"LXMERT (Pre-train + scratch)","rank_in_archive_order":32,"of":56,"metrics":{"Accuracy":"69.9"},"uses_additional_data":false},{"leaderboard":"/sota/visual-question-answering-on-vqa-v2-test-std","task":"Visual Question Answering (VQA)","dataset":"VQA v2 test-std","model":"LXMERT","rank_in_archive_order":21,"of":38,"metrics":{"overall":"72.5"},"uses_additional_data":false},{"leaderboard":"/sota/visual-question-answering-on-vizwiz-2018-1","task":"Visual Question Answering (VQA)","dataset":"VizWiz 2018","model":"LXR955, No Ensemble","rank_in_archive_order":1,"of":10,"metrics":{"number":"24.76","other":"39.0","overall":"55.4","unanswerable":"82.26","yes/no":"74.0"},"uses_additional_data":false},{"leaderboard":"/sota/visual-reasoning-on-nlvr2-dev","task":"Visual Reasoning","dataset":"NLVR2 Dev","model":"LXMERT (Pre-train + scratch)","rank_in_archive_order":14,"of":15,"metrics":{"Accuracy":"74.9"},"uses_additional_data":false},{"leaderboard":"/sota/visual-reasoning-on-nlvr2-test","task":"Visual Reasoning","dataset":"NLVR2 Test","model":"LXMERT","rank_in_archive_order":13,"of":14,"metrics":{"Accuracy":"76.2"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=1908.07490","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"1908.07490"}},"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/huggingface/transformers","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/social-ai-studio/matk","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/airsplay/lxmert","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/ghazaleh-mahmoodi/lxmert_compression","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/chaitanyadwivedii/3D-Attention-is-All-You-Need","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/Mind23-2/MindCode-156","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/zhegan27/VILLA","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/itsShnik/adaptively-finetuning-transformers","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/zhegan27/LXMERT-AdvTrain","reach":null}],"summary":{"ran":4,"unverified":11},"by_repo_kind":{"listed":{"samples":15,"ran":4,"repositories":2}},"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":3,"samples":[{"code_sha256_prefix":"5324d31f8ea9ca59","entry":"BertConfig","repo":"ghazaleh-mahmoodi/lxmert_compression","repo_kind":"listed","path":"lxmert/src/lxrt/modeling.py","file_url":"https://github.com/ghazaleh-mahmoodi/lxmert_compression/blob/HEAD/lxmert/src/lxrt/modeling.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":"5324d31f8ea9ca59"}},{"code_sha256_prefix":"e988ae429f42601c","entry":"BertEmbeddings","repo":"ghazaleh-mahmoodi/lxmert_compression","repo_kind":"listed","path":"lxmert/src/lxrt/modeling.py","file_url":"https://github.com/ghazaleh-mahmoodi/lxmert_compression/blob/HEAD/lxmert/src/lxrt/modeling.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":"e988ae429f42601c"}},{"code_sha256_prefix":"3644fb46790a5387","entry":"VisualConfig","repo":"ghazaleh-mahmoodi/lxmert_compression","repo_kind":"listed","path":"lxmert/src/lxrt/modeling.py","file_url":"https://github.com/ghazaleh-mahmoodi/lxmert_compression/blob/HEAD/lxmert/src/lxrt/modeling.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":"3644fb46790a5387"}},{"code_sha256_prefix":"62eb6af27b771c4f","entry":"VisualFeatEncoder","repo":"ghazaleh-mahmoodi/lxmert_compression","repo_kind":"listed","path":"lxmert/src/lxrt/modeling.py","file_url":"https://github.com/ghazaleh-mahmoodi/lxmert_compression/blob/HEAD/lxmert/src/lxrt/modeling.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":"62eb6af27b771c4f"}},{"code_sha256_prefix":"041610d8fd391e5c","entry":"BertCrossattLayer","repo":"itsShnik/adaptively-finetuning-transformers","repo_kind":"listed","path":"lxmert/src/lxrt/modeling.py","file_url":"https://github.com/itsShnik/adaptively-finetuning-transformers/blob/HEAD/lxmert/src/lxrt/modeling.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":"041610d8fd391e5c"}},{"code_sha256_prefix":"2f7d2c26e185cb3f","entry":"BertLayer","repo":"ghazaleh-mahmoodi/lxmert_compression","repo_kind":"listed","path":"lxmert/src/lxrt/modeling.py","file_url":"https://github.com/ghazaleh-mahmoodi/lxmert_compression/blob/HEAD/lxmert/src/lxrt/modeling.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":"2f7d2c26e185cb3f"}},{"code_sha256_prefix":"805f9fc004ffa11b","entry":"BertPreTrainedModel","repo":"ghazaleh-mahmoodi/lxmert_compression","repo_kind":"listed","path":"lxmert/src/lxrt/modeling.py","file_url":"https://github.com/ghazaleh-mahmoodi/lxmert_compression/blob/HEAD/lxmert/src/lxrt/modeling.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":"805f9fc004ffa11b"}},{"code_sha256_prefix":"eec3a5ce59023166","entry":"LXRTEncoder","repo":"ghazaleh-mahmoodi/lxmert_compression","repo_kind":"listed","path":"lxmert/src/lxrt/modeling.py","file_url":"https://github.com/ghazaleh-mahmoodi/lxmert_compression/blob/HEAD/lxmert/src/lxrt/modeling.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":"eec3a5ce59023166"}},{"code_sha256_prefix":"b2d464cb37f35db7","entry":"LXRTEncoder","repo":"itsShnik/adaptively-finetuning-transformers","repo_kind":"listed","path":"lxmert/src/lxrt/modeling.py","file_url":"https://github.com/itsShnik/adaptively-finetuning-transformers/blob/HEAD/lxmert/src/lxrt/modeling.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":"b2d464cb37f35db7"}},{"code_sha256_prefix":"69076d81f02f197f","entry":"LXRTModel","repo":"ghazaleh-mahmoodi/lxmert_compression","repo_kind":"listed","path":"lxmert/src/lxrt/modeling.py","file_url":"https://github.com/ghazaleh-mahmoodi/lxmert_compression/blob/HEAD/lxmert/src/lxrt/modeling.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":"69076d81f02f197f"}},{"code_sha256_prefix":"0b1bea7c4d0afd60","entry":"LXRTXLayer","repo":"ghazaleh-mahmoodi/lxmert_compression","repo_kind":"listed","path":"lxmert/src/lxrt/modeling.py","file_url":"https://github.com/ghazaleh-mahmoodi/lxmert_compression/blob/HEAD/lxmert/src/lxrt/modeling.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":"0b1bea7c4d0afd60"}},{"code_sha256_prefix":"22162f5bca31d93a","entry":"LXRTXLayer","repo":"itsShnik/adaptively-finetuning-transformers","repo_kind":"listed","path":"lxmert/src/lxrt/modeling.py","file_url":"https://github.com/itsShnik/adaptively-finetuning-transformers/blob/HEAD/lxmert/src/lxrt/modeling.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":"22162f5bca31d93a"}},{"code_sha256_prefix":"a4e8483353cec520","entry":"cached_path","repo":"ghazaleh-mahmoodi/lxmert_compression","repo_kind":"listed","path":"lxmert/src/lxrt/modeling.py","file_url":"https://github.com/ghazaleh-mahmoodi/lxmert_compression/blob/HEAD/lxmert/src/lxrt/modeling.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":"a4e8483353cec520"}},{"code_sha256_prefix":"242c3c3d7e930e18","entry":"get_from_cache","repo":"ghazaleh-mahmoodi/lxmert_compression","repo_kind":"listed","path":"lxmert/src/lxrt/modeling.py","file_url":"https://github.com/ghazaleh-mahmoodi/lxmert_compression/blob/HEAD/lxmert/src/lxrt/modeling.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":"242c3c3d7e930e18"}},{"code_sha256_prefix":"7099305544368003","entry":"load_tf_weights_in_bert","repo":"ghazaleh-mahmoodi/lxmert_compression","repo_kind":"listed","path":"lxmert/src/lxrt/modeling.py","file_url":"https://github.com/ghazaleh-mahmoodi/lxmert_compression/blob/HEAD/lxmert/src/lxrt/modeling.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":"7099305544368003"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}