{"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/dwell-in-the-beginning-how-language-models","title":"Dwell in the Beginning: How Language Models Embed Long Documents for Dense Retrieval","arxiv_id":"2404.04163","date":"2024-04-05","proceeding":null,"authors":["João Coelho","Bruno Martins","João Magalhães","Jamie Callan","Chenyan Xiong"],"abstract":"This study investigates the existence of positional biases in Transformer-based models for text representation learning, particularly in the context of web document retrieval. We build on previous research that demonstrated loss of information in the middle of input sequences for causal language models, extending it to the domain of representation learning. We examine positional biases at various stages of training for an encoder-decoder model, including language model pre-training, contrastive pre-training, and contrastive fine-tuning. Experiments with the MS-MARCO document collection reveal that after contrastive pre-training the model already generates embeddings that better capture early contents of the input, with fine-tuning further aggravating this effect.","url_abs":"https://arxiv.org/abs/2404.04163v2","url_pdf":"https://arxiv.org/pdf/2404.04163v2.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":"dwell-in-the-beginning-how-language-models","repo_url":"https://github.com/cxcscmu/longembeddinganalysis","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"decoder","task_name":"Decoder"},{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"representation-learning","task_name":"Representation Learning"},{"task_slug":"retrieval","task_name":"Retrieval"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2404.04163","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2404.04163"}},"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/cxcscmu/longembeddinganalysis","reach":{"status":"ok"}}],"summary":{"ran":7,"ran_violates":1,"unverified":2},"by_repo_kind":{"official":{"samples":10,"ran":8,"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":10,"samples":[{"code_sha256_prefix":"7f1946b9c385a5cf","entry":"cached","repo":"cxcscmu/longembeddinganalysis","repo_kind":"official","path":"GradCache/src/grad_cache/functional.py","file_url":"https://github.com/cxcscmu/longembeddinganalysis/blob/HEAD/GradCache/src/grad_cache/functional.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7f1946b9c385a5cf"}},{"code_sha256_prefix":"79176433334d19b4","entry":"dev","repo":"cxcscmu/longembeddinganalysis","repo_kind":"official","path":"OpenMatch/v1/gen_feature.py","file_url":"https://github.com/cxcscmu/longembeddinganalysis/blob/HEAD/OpenMatch/v1/gen_feature.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"79176433334d19b4"}},{"code_sha256_prefix":"b46a95cff9bf41b5","entry":"has_answers","repo":"cxcscmu/longembeddinganalysis","repo_kind":"official","path":"OpenMatch/src/openmatch/qa_utils.py","file_url":"https://github.com/cxcscmu/longembeddinganalysis/blob/HEAD/OpenMatch/src/openmatch/qa_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b46a95cff9bf41b5"}},{"code_sha256_prefix":"222c1daa5a08da51","entry":"load_beir_positives","repo":"cxcscmu/longembeddinganalysis","repo_kind":"official","path":"OpenMatch/src/openmatch/utils.py","file_url":"https://github.com/cxcscmu/longembeddinganalysis/blob/HEAD/OpenMatch/src/openmatch/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"222c1daa5a08da51"}},{"code_sha256_prefix":"8d2e5d58238cd53f","entry":"load_from_trec","repo":"cxcscmu/longembeddinganalysis","repo_kind":"official","path":"OpenMatch/src/openmatch/utils.py","file_url":"https://github.com/cxcscmu/longembeddinganalysis/blob/HEAD/OpenMatch/src/openmatch/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"8d2e5d58238cd53f"}},{"code_sha256_prefix":"9e4c17e0bdb9dcd5","entry":"load_positives","repo":"cxcscmu/longembeddinganalysis","repo_kind":"official","path":"OpenMatch/src/openmatch/utils.py","file_url":"https://github.com/cxcscmu/longembeddinganalysis/blob/HEAD/OpenMatch/src/openmatch/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9e4c17e0bdb9dcd5"}},{"code_sha256_prefix":"93b0eef32604c3f7","entry":"regex_match","repo":"cxcscmu/longembeddinganalysis","repo_kind":"official","path":"OpenMatch/src/openmatch/qa_utils.py","file_url":"https://github.com/cxcscmu/longembeddinganalysis/blob/HEAD/OpenMatch/src/openmatch/qa_utils.py","link_basis":"plan_row","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"93b0eef32604c3f7"}},{"code_sha256_prefix":"aaf2a2b86f345be4","entry":"test","repo":"cxcscmu/longembeddinganalysis","repo_kind":"official","path":"OpenMatch/v1/inference.py","file_url":"https://github.com/cxcscmu/longembeddinganalysis/blob/HEAD/OpenMatch/v1/inference.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"aaf2a2b86f345be4"}},{"code_sha256_prefix":"fab5db4632e2fa87","entry":"cat_input_tensor","repo":"cxcscmu/longembeddinganalysis","repo_kind":"official","path":"GradCache/src/grad_cache/functional.py","file_url":"https://github.com/cxcscmu/longembeddinganalysis/blob/HEAD/GradCache/src/grad_cache/functional.py","link_basis":"harvester_set","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":"fab5db4632e2fa87"}},{"code_sha256_prefix":"7917a2079ec6b095","entry":"gather_input_tensor","repo":"cxcscmu/longembeddinganalysis","repo_kind":"official","path":"GradCache/src/grad_cache/functional.py","file_url":"https://github.com/cxcscmu/longembeddinganalysis/blob/HEAD/GradCache/src/grad_cache/functional.py","link_basis":"harvester_set","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":"7917a2079ec6b095"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}