{"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/replug-retrieval-augmented-black-box-language","title":"REPLUG: Retrieval-Augmented Black-Box Language Models","arxiv_id":"2301.12652","date":"2023-01-30","proceeding":null,"authors":["Weijia Shi","Sewon Min","Michihiro Yasunaga","Minjoon Seo","Rich James","Mike Lewis","Luke Zettlemoyer","Wen-tau Yih"],"abstract":"We introduce REPLUG, a retrieval-augmented language modeling framework that treats the language model (LM) as a black box and augments it with a tuneable retrieval model. Unlike prior retrieval-augmented LMs that train language models with special cross attention mechanisms to encode the retrieved text, REPLUG simply prepends retrieved documents to the input for the frozen black-box LM. This simple design can be easily applied to any existing retrieval and language models. Furthermore, we show that the LM can be used to supervise the retrieval model, which can then find documents that help the LM make better predictions. Our experiments demonstrate that REPLUG with the tuned retriever significantly improves the performance of GPT-3 (175B) on language modeling by 6.3%, as well as the performance of Codex on five-shot MMLU by 5.1%.","url_abs":"https://arxiv.org/abs/2301.12652v4","url_pdf":"https://arxiv.org/pdf/2301.12652v4.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":"replug-retrieval-augmented-black-box-language","repo_url":"https://github.com/intellabs/fastrag","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"replug-retrieval-augmented-black-box-language","repo_url":"https://github.com/liano3/RAG-fairness","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"replug-retrieval-augmented-black-box-language","repo_url":"https://github.com/ruc-nlpir/flashrag","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"mmlu","task_name":"MMLU"},{"task_slug":"multi-task-language-understanding","task_name":"Multi-task Language Understanding"},{"task_slug":"question-answering","task_name":"Question Answering"},{"task_slug":"retrieval","task_name":"Retrieval"}],"methods":[{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"attention-dropout","method_name":"Attention Dropout"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"cosine-annealing","method_name":"Cosine Annealing"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"gpt-3","method_name":"GPT-3"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"linear-warmup-with-cosine-annealing","method_name":"Linear Warmup With Cosine Annealing"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"weight-decay","method_name":"Weight Decay"}],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/question-answering-on-natural-questions","task":"Question Answering","dataset":"Natural Questions","model":"code-davinci-002 175B + REPLUG LSR (few-shot)","rank_in_archive_order":16,"of":47,"metrics":{"EM":"45.5"},"uses_additional_data":false},{"leaderboard":"/sota/question-answering-on-natural-questions","task":"Question Answering","dataset":"Natural Questions","model":"code-davinci-002 175B + REPLUG (few-shot)","rank_in_archive_order":18,"of":47,"metrics":{"EM":"44.7"},"uses_additional_data":false},{"leaderboard":"/sota/question-answering-on-triviaqa","task":"Question Answering","dataset":"TriviaQA","model":"code-davinci-002 175B + REPLUG LSR (Few-Shot)","rank_in_archive_order":16,"of":56,"metrics":{"EM":"77.3"},"uses_additional_data":false},{"leaderboard":"/sota/question-answering-on-triviaqa","task":"Question Answering","dataset":"TriviaQA","model":"code-davinci-002 175B + REPLUG (Few-Shot)","rank_in_archive_order":18,"of":56,"metrics":{"EM":"76.8"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2301.12652","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2301.12652"}},"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/intellabs/fastrag","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/liano3/RAG-fairness","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/ruc-nlpir/flashrag","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"unverified":13},"by_repo_kind":{"listed":{"samples":13,"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":13,"samples":[{"code_sha256_prefix":"f3305aacfc98aaff","entry":"add_timing_to_pipeline","repo":"intellabs/fastrag","repo_kind":"listed","path":"fastrag/utils.py","file_url":"https://github.com/intellabs/fastrag/blob/HEAD/fastrag/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"f3305aacfc98aaff"}},{"code_sha256_prefix":"22702323a133d7aa","entry":"adjust_batch","repo":"intellabs/fastrag","repo_kind":"listed","path":"fastrag/generators/gaudi_utils.py","file_url":"https://github.com/intellabs/fastrag/blob/HEAD/fastrag/generators/gaudi_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"22702323a133d7aa"}},{"code_sha256_prefix":"a063dd45ba80cda9","entry":"clean_for_prompt","repo":"intellabs/fastrag","repo_kind":"listed","path":"fastrag/agents/utils.py","file_url":"https://github.com/intellabs/fastrag/blob/HEAD/fastrag/agents/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"a063dd45ba80cda9"}},{"code_sha256_prefix":"3bd441205b45bf06","entry":"fastrag_timing","repo":"intellabs/fastrag","repo_kind":"listed","path":"fastrag/utils.py","file_url":"https://github.com/intellabs/fastrag/blob/HEAD/fastrag/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"3bd441205b45bf06"}},{"code_sha256_prefix":"392eb8978ee423ad","entry":"get_padded_tensor","repo":"intellabs/fastrag","repo_kind":"listed","path":"fastrag/generators/fid_utils.py","file_url":"https://github.com/intellabs/fastrag/blob/HEAD/fastrag/generators/fid_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"392eb8978ee423ad"}},{"code_sha256_prefix":"629184378b16dad0","entry":"get_timing_from_pipeline","repo":"intellabs/fastrag","repo_kind":"listed","path":"fastrag/utils.py","file_url":"https://github.com/intellabs/fastrag/blob/HEAD/fastrag/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"629184378b16dad0"}},{"code_sha256_prefix":"9a8ef57d5aeeee0d","entry":"get_torch_compiled_model","repo":"intellabs/fastrag","repo_kind":"listed","path":"fastrag/generators/gaudi_utils.py","file_url":"https://github.com/intellabs/fastrag/blob/HEAD/fastrag/generators/gaudi_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"9a8ef57d5aeeee0d"}},{"code_sha256_prefix":"e7bb63793c50dd54","entry":"load_text","repo":"intellabs/fastrag","repo_kind":"listed","path":"fastrag/agents/utils.py","file_url":"https://github.com/intellabs/fastrag/blob/HEAD/fastrag/agents/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"e7bb63793c50dd54"}},{"code_sha256_prefix":"b7cb9a8067883d41","entry":"passages_to_tensors","repo":"intellabs/fastrag","repo_kind":"listed","path":"fastrag/generators/fid_utils.py","file_url":"https://github.com/intellabs/fastrag/blob/HEAD/fastrag/generators/fid_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"b7cb9a8067883d41"}},{"code_sha256_prefix":"3c215e4cbc96b8b6","entry":"setup_device","repo":"intellabs/fastrag","repo_kind":"listed","path":"fastrag/generators/gaudi_utils.py","file_url":"https://github.com/intellabs/fastrag/blob/HEAD/fastrag/generators/gaudi_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"3c215e4cbc96b8b6"}},{"code_sha256_prefix":"3a98b7557c38ef50","entry":"setup_parser","repo":"intellabs/fastrag","repo_kind":"listed","path":"fastrag/generators/gaudi.py","file_url":"https://github.com/intellabs/fastrag/blob/HEAD/fastrag/generators/gaudi.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"3a98b7557c38ef50"}},{"code_sha256_prefix":"24505d354160b0da","entry":"tokenization_result_to_tensor","repo":"intellabs/fastrag","repo_kind":"listed","path":"fastrag/generators/fid_utils.py","file_url":"https://github.com/intellabs/fastrag/blob/HEAD/fastrag/generators/fid_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"24505d354160b0da"}},{"code_sha256_prefix":"71454965f4141e50","entry":"wiki_odqa_tasks_encoder","repo":"intellabs/fastrag","repo_kind":"listed","path":"fastrag/data_loaders.py","file_url":"https://github.com/intellabs/fastrag/blob/HEAD/fastrag/data_loaders.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"71454965f4141e50"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}