{"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/rag-ddr-optimizing-retrieval-augmented","title":"RAG-DDR: Optimizing Retrieval-Augmented Generation Using Differentiable Data Rewards","arxiv_id":"2410.13509","date":"2024-10-17","proceeding":null,"authors":["Xinze Li","Sen Mei","Zhenghao Liu","Yukun Yan","Shuo Wang","Shi Yu","Zheni Zeng","Hao Chen","Ge Yu","Zhiyuan Liu","Maosong Sun","Chenyan Xiong"],"abstract":"Retrieval-Augmented Generation (RAG) has proven its effectiveness in mitigating hallucinations in Large Language Models (LLMs) by retrieving knowledge from external resources. To adapt LLMs for RAG pipelines, current approaches use instruction tuning to optimize LLMs, improving their ability to utilize retrieved knowledge. This supervised fine-tuning (SFT) approach focuses on equipping LLMs to handle diverse RAG tasks using different instructions. However, it trains RAG modules to overfit training signals and overlooks the varying data preferences among agents within the RAG system. In this paper, we propose a Differentiable Data Rewards (DDR) method, which end-to-end trains RAG systems by aligning data preferences between different RAG modules. DDR works by collecting the rewards to optimize each agent with a rollout method. This method prompts agents to sample some potential responses as perturbations, evaluates the impact of these perturbations on the whole RAG system, and subsequently optimizes the agent to produce outputs that improve the performance of the RAG system. Our experiments on various knowledge-intensive tasks demonstrate that DDR significantly outperforms the SFT method, particularly for LLMs with smaller-scale parameters that depend more on the retrieved knowledge. Additionally, DDR exhibits a stronger capability to align the data preference between RAG modules. The DDR method makes generation module more effective in extracting key information from documents and mitigating conflicts between parametric memory and external knowledge. All codes are available at https://github.com/OpenMatch/RAG-DDR.","url_abs":"https://arxiv.org/abs/2410.13509v1","url_pdf":"https://arxiv.org/pdf/2410.13509v1.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":"rag-ddr-optimizing-retrieval-augmented","repo_url":"https://github.com/openmatch/rag-ddr","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"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":"align","method_name":"ALIGN"},{"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":"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":"sft","method_name":"SFT"},{"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=2410.13509","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2410.13509"}},"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/openmatch/rag-ddr","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":9,"unverified":1},"by_repo_kind":{"official":{"samples":10,"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":0,"samples":[{"code_sha256_prefix":"7420700db4ee8bac","entry":"extract_last_number","repo":"openmatch/rag-ddr","repo_kind":"official","path":"src/generator/merge_response_file.py","file_url":"https://github.com/openmatch/rag-ddr/blob/HEAD/src/generator/merge_response_file.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"7420700db4ee8bac"}},{"code_sha256_prefix":"f8cc01a165315942","entry":"find_max_element_by_key","repo":"openmatch/rag-ddr","repo_kind":"official","path":"src/generator/gen_dpo_data.py","file_url":"https://github.com/openmatch/rag-ddr/blob/HEAD/src/generator/gen_dpo_data.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":"f8cc01a165315942"}},{"code_sha256_prefix":"335904cc644a3184","entry":"find_min_element_by_key","repo":"openmatch/rag-ddr","repo_kind":"official","path":"src/generator/gen_dpo_data.py","file_url":"https://github.com/openmatch/rag-ddr/blob/HEAD/src/generator/gen_dpo_data.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":"335904cc644a3184"}},{"code_sha256_prefix":"915871573635cb08","entry":"get_batch_input","repo":"openmatch/rag-ddr","repo_kind":"official","path":"src/knowledgeRefinement/kr_inference.py","file_url":"https://github.com/openmatch/rag-ddr/blob/HEAD/src/knowledgeRefinement/kr_inference.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"915871573635cb08"}},{"code_sha256_prefix":"5e773ff3bfc49ef8","entry":"process_input_data","repo":"openmatch/rag-ddr","repo_kind":"official","path":"src/evaluate/eval_utils.py","file_url":"https://github.com/openmatch/rag-ddr/blob/HEAD/src/evaluate/eval_utils.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":"5e773ff3bfc49ef8"}},{"code_sha256_prefix":"a22422413f1c610b","entry":"read_jsonl","repo":"openmatch/rag-ddr","repo_kind":"official","path":"src/generator/gen_dpo_data.py","file_url":"https://github.com/openmatch/rag-ddr/blob/HEAD/src/generator/gen_dpo_data.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":"a22422413f1c610b"}},{"code_sha256_prefix":"fdd1249aa05ba5f3","entry":"read_jsonl","repo":"openmatch/rag-ddr","repo_kind":"official","path":"src/generator/gen_llm_response.py","file_url":"https://github.com/openmatch/rag-ddr/blob/HEAD/src/generator/gen_llm_response.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":"fdd1249aa05ba5f3"}},{"code_sha256_prefix":"e2f5857da2c35d73","entry":"split_list","repo":"openmatch/rag-ddr","repo_kind":"official","path":"src/knowledgeRefinement/kr_inference.py","file_url":"https://github.com/openmatch/rag-ddr/blob/HEAD/src/knowledgeRefinement/kr_inference.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":"e2f5857da2c35d73"}},{"code_sha256_prefix":"9c01dde082cc357b","entry":"split_list_evenly","repo":"openmatch/rag-ddr","repo_kind":"official","path":"src/generator/gen_llm_response.py","file_url":"https://github.com/openmatch/rag-ddr/blob/HEAD/src/generator/gen_llm_response.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9c01dde082cc357b"}},{"code_sha256_prefix":"90a22cdf7d22703b","entry":"read_jsonl","repo":"openmatch/rag-ddr","repo_kind":"official","path":"src/knowledgeRefinement/kr_inference.py","file_url":"https://github.com/openmatch/rag-ddr/blob/HEAD/src/knowledgeRefinement/kr_inference.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":"90a22cdf7d22703b"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}