{"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/enhancing-retrieval-and-managing-retrieval-a","title":"Enhancing Retrieval and Managing Retrieval: A Four-Module Synergy for Improved Quality and Efficiency in RAG Systems","arxiv_id":"2407.10670","date":"2024-07-15","proceeding":null,"authors":["Yunxiao Shi","Xing Zi","Zijing Shi","Haimin Zhang","Qiang Wu","Min Xu"],"abstract":"Retrieval-augmented generation (RAG) techniques leverage the in-context learning capabilities of large language models (LLMs) to produce more accurate and relevant responses. Originating from the simple 'retrieve-then-read' approach, the RAG framework has evolved into a highly flexible and modular paradigm. A critical component, the Query Rewriter module, enhances knowledge retrieval by generating a search-friendly query. This method aligns input questions more closely with the knowledge base. Our research identifies opportunities to enhance the Query Rewriter module to Query Rewriter+ by generating multiple queries to overcome the Information Plateaus associated with a single query and by rewriting questions to eliminate Ambiguity, thereby clarifying the underlying intent. We also find that current RAG systems exhibit issues with Irrelevant Knowledge; to overcome this, we propose the Knowledge Filter. These two modules are both based on the instruction-tuned Gemma-2B model, which together enhance response quality. The final identified issue is Redundant Retrieval; we introduce the Memory Knowledge Reservoir and the Retriever Trigger to solve this. The former supports the dynamic expansion of the RAG system's knowledge base in a parameter-free manner, while the latter optimizes the cost for accessing external knowledge, thereby improving resource utilization and response efficiency. These four RAG modules synergistically improve the response quality and efficiency of the RAG system. The effectiveness of these modules has been validated through experiments and ablation studies across six common QA datasets. The source code can be accessed at https://github.com/Ancientshi/ERM4.","url_abs":"https://arxiv.org/abs/2407.10670v1","url_pdf":"https://arxiv.org/pdf/2407.10670v1.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":"enhancing-retrieval-and-managing-retrieval-a","repo_url":"https://github.com/ancientshi/erm4","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"NOASSERTION"}}],"tasks":[{"task_slug":"in-context-learning","task_name":"In-Context Learning"},{"task_slug":"rag","task_name":"RAG"},{"task_slug":"retrieval","task_name":"Retrieval"},{"task_slug":"retrieval-augmented-generation","task_name":"Retrieval-augmented Generation"}],"methods":[{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"attention-dropout","method_name":"Attention Dropout"},{"method_slug":"bart","method_name":"BART"},{"method_slug":"base","method_name":"BASE"},{"method_slug":"bert","method_name":"BERT"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"linear-warmup-with-linear-decay","method_name":"Linear Warmup With Linear Decay"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"rag","method_name":"RAG"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"weight-decay","method_name":"Weight Decay"},{"method_slug":"wordpiece","method_name":"WordPiece"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2407.10670","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2407.10670"}},"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/ancientshi/erm4","reach":{"status":"ok","spdx":"NOASSERTION"}}],"summary":{"ran":8,"ran_violates":1,"unverified":2},"by_repo_kind":{"official":{"samples":11,"ran":9,"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":11,"samples":[{"code_sha256_prefix":"780d3d881bff9426","entry":"async_GPT_QA","repo":"ancientshi/erm4","repo_kind":"official","path":"utils.py","file_url":"https://github.com/ancientshi/erm4/blob/HEAD/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"780d3d881bff9426"}},{"code_sha256_prefix":"c97060e48c93da97","entry":"check_answer","repo":"ancientshi/erm4","repo_kind":"official","path":"evaluation.py","file_url":"https://github.com/ancientshi/erm4/blob/HEAD/evaluation.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"c97060e48c93da97"}},{"code_sha256_prefix":"51f4c1ae26ea0c4c","entry":"generate_prompt","repo":"ancientshi/erm4","repo_kind":"official","path":"finetune_gemma_rewriter.py","file_url":"https://github.com/ancientshi/erm4/blob/HEAD/finetune_gemma_rewriter.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"51f4c1ae26ea0c4c"}},{"code_sha256_prefix":"4de4c9707060d248","entry":"generate_prompt","repo":"ancientshi/erm4","repo_kind":"official","path":"infer_gemma_rewriter.py","file_url":"https://github.com/ancientshi/erm4/blob/HEAD/infer_gemma_rewriter.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"4de4c9707060d248"}},{"code_sha256_prefix":"2075373a61e75fd7","entry":"has_answer","repo":"ancientshi/erm4","repo_kind":"official","path":"evaluation.py","file_url":"https://github.com/ancientshi/erm4/blob/HEAD/evaluation.py","link_basis":"harvester_set","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":"2075373a61e75fd7"}},{"code_sha256_prefix":"9cf71ec356b0a40d","entry":"hits","repo":"ancientshi/erm4","repo_kind":"official","path":"evaluation.py","file_url":"https://github.com/ancientshi/erm4/blob/HEAD/evaluation.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"9cf71ec356b0a40d"}},{"code_sha256_prefix":"a79494451ce95c27","entry":"query_rewriter_plus","repo":"ancientshi/erm4","repo_kind":"official","path":"utils.py","file_url":"https://github.com/ancientshi/erm4/blob/HEAD/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"a79494451ce95c27"}},{"code_sha256_prefix":"7231faa0f2fefc46","entry":"searchbing","repo":"ancientshi/erm4","repo_kind":"official","path":"bing.py","file_url":"https://github.com/ancientshi/erm4/blob/HEAD/bing.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"7231faa0f2fefc46"}},{"code_sha256_prefix":"a957019ca36a6747","entry":"str2bool","repo":"ancientshi/erm4","repo_kind":"official","path":"config.py","file_url":"https://github.com/ancientshi/erm4/blob/HEAD/config.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a957019ca36a6747"}},{"code_sha256_prefix":"cdb5dce21340def0","entry":"GPT_QA","repo":"ancientshi/erm4","repo_kind":"official","path":"utils.py","file_url":"https://github.com/ancientshi/erm4/blob/HEAD/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"cdb5dce21340def0"}},{"code_sha256_prefix":"7268f2124fba73a9","entry":"train","repo":"ancientshi/erm4","repo_kind":"official","path":"finetune_gemma_rewriter.py","file_url":"https://github.com/ancientshi/erm4/blob/HEAD/finetune_gemma_rewriter.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"7268f2124fba73a9"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}