{"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/ctrla-adaptive-retrieval-augmented-generation","title":"CtrlA: Adaptive Retrieval-Augmented Generation via Inherent Control","arxiv_id":"2405.18727","date":"2024-05-29","proceeding":null,"authors":["Huanshuo Liu","Hao Zhang","Zhijiang Guo","Jing Wang","Kuicai Dong","Xiangyang Li","Yi Quan Lee","Cong Zhang","Yong liu"],"abstract":"Retrieval-augmented generation (RAG) has emerged as a promising solution for mitigating hallucinations of large language models (LLMs) with retrieved external knowledge. Adaptive RAG enhances this approach by enabling dynamic retrieval during generation, activating retrieval only when the query exceeds LLM's internal knowledge. Existing methods primarily focus on detecting LLM's confidence via statistical uncertainty. Instead, we present the first attempts to solve adaptive RAG from a representation perspective and develop an inherent control-based framework, termed \\name. Specifically, we extract the features that represent the honesty and confidence directions of LLM and adopt them to control LLM behavior and guide retrieval timing decisions. We also design a simple yet effective query formulation strategy to support adaptive retrieval. Experiments show that \\name is superior to existing adaptive RAG methods on a diverse set of tasks, the honesty steering can effectively make LLMs more honest and confidence monitoring is a promising indicator of retrieval trigger.Our code is available at \\url{https://github.com/HSLiu-Initial/CtrlA}.","url_abs":"https://arxiv.org/abs/2405.18727v2","url_pdf":"https://arxiv.org/pdf/2405.18727v2.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":"ctrla-adaptive-retrieval-augmented-generation","repo_url":"https://github.com/hsliu-initial/ctrla","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"rag","task_name":"RAG"},{"task_slug":"response-generation","task_name":"Response Generation"},{"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":"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":"focus","method_name":"Focus"},{"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":"set","method_name":"SET"},{"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":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2405.18727","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2405.18727"}},"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/hsliu-initial/ctrla","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran":5,"unverified":7},"by_repo_kind":{"official":{"samples":12,"ran":5,"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":"e3a2cc0ca1e808fd","entry":"compare_strings_except_punctuation","repo":"hsliu-initial/ctrla","repo_kind":"official","path":"code/model/utils.py","file_url":"https://github.com/hsliu-initial/ctrla/blob/HEAD/code/model/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e3a2cc0ca1e808fd"}},{"code_sha256_prefix":"7e5f3e4b66dea866","entry":"extract_query","repo":"hsliu-initial/ctrla","repo_kind":"official","path":"code/retrieval.py","file_url":"https://github.com/hsliu-initial/ctrla/blob/HEAD/code/retrieval.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7e5f3e4b66dea866"}},{"code_sha256_prefix":"e6db0e97e3f20326","entry":"format_list_as_numbered_string","repo":"hsliu-initial/ctrla","repo_kind":"official","path":"code/model/utils.py","file_url":"https://github.com/hsliu-initial/ctrla/blob/HEAD/code/model/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e6db0e97e3f20326"}},{"code_sha256_prefix":"6965bef00ccbd894","entry":"init_method","repo":"hsliu-initial/ctrla","repo_kind":"official","path":"code/utils.py","file_url":"https://github.com/hsliu-initial/ctrla/blob/HEAD/code/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"6965bef00ccbd894"}},{"code_sha256_prefix":"c29fc928dae85749","entry":"normalize_answer","repo":"hsliu-initial/ctrla","repo_kind":"official","path":"code/utils.py","file_url":"https://github.com/hsliu-initial/ctrla/blob/HEAD/code/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"c29fc928dae85749"}},{"code_sha256_prefix":"782d9e5aaab6dd69","entry":"RHM","repo":"hsliu-initial/ctrla","repo_kind":"official","path":"code/retrieval.py","file_url":"https://github.com/hsliu-initial/ctrla/blob/HEAD/code/retrieval.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"782d9e5aaab6dd69"}},{"code_sha256_prefix":"7272a14d4edc059a","entry":"confidence_function_dataset","repo":"hsliu-initial/ctrla","repo_kind":"official","path":"code/dataset/probe.py","file_url":"https://github.com/hsliu-initial/ctrla/blob/HEAD/code/dataset/probe.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7272a14d4edc059a"}},{"code_sha256_prefix":"82a5ced5dbda8b54","entry":"honesty_function_dataset","repo":"hsliu-initial/ctrla","repo_kind":"official","path":"code/dataset/probe.py","file_url":"https://github.com/hsliu-initial/ctrla/blob/HEAD/code/dataset/probe.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"82a5ced5dbda8b54"}},{"code_sha256_prefix":"8c6b734d5c949090","entry":"project_onto_direction","repo":"hsliu-initial/ctrla","repo_kind":"official","path":"code/repe/rep_readers.py","file_url":"https://github.com/hsliu-initial/ctrla/blob/HEAD/code/repe/rep_readers.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":true,"mcp_get_code":{"code_sha256":"8c6b734d5c949090"}},{"code_sha256_prefix":"1ceba3fc481567ab","entry":"recenter","repo":"hsliu-initial/ctrla","repo_kind":"official","path":"code/repe/rep_readers.py","file_url":"https://github.com/hsliu-initial/ctrla/blob/HEAD/code/repe/rep_readers.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":true,"mcp_get_code":{"code_sha256":"1ceba3fc481567ab"}},{"code_sha256_prefix":"17965da41b5a7cec","entry":"transform_data","repo":"hsliu-initial/ctrla","repo_kind":"official","path":"code/model/utils.py","file_url":"https://github.com/hsliu-initial/ctrla/blob/HEAD/code/model/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"17965da41b5a7cec"}},{"code_sha256_prefix":"f99d57607dabd59e","entry":"tvq","repo":"hsliu-initial/ctrla","repo_kind":"official","path":"code/retrieval.py","file_url":"https://github.com/hsliu-initial/ctrla/blob/HEAD/code/retrieval.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"f99d57607dabd59e"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}