{"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/aligning-large-language-models-with-2","title":"Aligning Large Language Models with Representation Editing: A Control Perspective","arxiv_id":"2406.05954","date":"2024-06-10","proceeding":null,"authors":["Lingkai Kong","Haorui Wang","Wenhao Mu","Yuanqi Du","Yuchen Zhuang","Yifei Zhou","Yue Song","Rongzhi Zhang","Kai Wang","Chao Zhang"],"abstract":"Aligning large language models (LLMs) with human objectives is crucial for real-world applications. However, fine-tuning LLMs for alignment often suffers from unstable training and requires substantial computing resources. Test-time alignment techniques, such as prompting and guided decoding, do not modify the underlying model, and their performance remains dependent on the original model's capabilities. To address these challenges, we propose aligning LLMs through representation editing. The core of our method is to view a pre-trained autoregressive LLM as a discrete-time stochastic dynamical system. To achieve alignment for specific objectives, we introduce external control signals into the state space of this language dynamical system. We train a value function directly on the hidden states according to the Bellman equation, enabling gradient-based optimization to obtain the optimal control signals at test time. Our experiments demonstrate that our method outperforms existing test-time alignment techniques while requiring significantly fewer resources compared to fine-tuning methods. Our code is available at https://github.com/Lingkai-Kong/RE-Control.","url_abs":"https://arxiv.org/abs/2406.05954v3","url_pdf":"https://arxiv.org/pdf/2406.05954v3.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":"aligning-large-language-models-with-2","repo_url":"https://github.com/lingkai-kong/re-control","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2406.05954","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2406.05954"}},"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":"deterministic:regex_extraction","url":"https://github.com/Lingkai-Kong/RE-Control","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/lingkai-kong/re-control","reach":{"status":"ok"}}],"summary":{"ran":5,"ran_draft_wrong":1,"ran_honours":2,"unverified":7},"by_repo_kind":{"official":{"samples":15,"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":15,"samples":[{"code_sha256_prefix":"9d741ca160b48466","entry":"clean","repo":"Lingkai-Kong/RE-Control","repo_kind":"official","path":"gpt4_eval.py","file_url":"https://github.com/Lingkai-Kong/RE-Control/blob/HEAD/gpt4_eval.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9d741ca160b48466"}},{"code_sha256_prefix":"3cf2a6616e939e43","entry":"clean","repo":"Lingkai-Kong/RE-Control","repo_kind":"official","path":"metrics.py","file_url":"https://github.com/Lingkai-Kong/RE-Control/blob/HEAD/metrics.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3cf2a6616e939e43"}},{"code_sha256_prefix":"caf88b9c8ecf956d","entry":"data_collactor","repo":"Lingkai-Kong/RE-Control","repo_kind":"official","path":"reward_label.py","file_url":"https://github.com/Lingkai-Kong/RE-Control/blob/HEAD/reward_label.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":"caf88b9c8ecf956d"}},{"code_sha256_prefix":"b2e30556f9379844","entry":"data_process","repo":"lingkai-kong/re-control","repo_kind":"official","path":"measure_reward.py","file_url":"https://github.com/lingkai-kong/re-control/blob/HEAD/measure_reward.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b2e30556f9379844"}},{"code_sha256_prefix":"eff184cc56e8bb4d","entry":"get_rm","repo":"Lingkai-Kong/RE-Control","repo_kind":"official","path":"reward_label.py","file_url":"https://github.com/Lingkai-Kong/RE-Control/blob/HEAD/reward_label.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":"eff184cc56e8bb4d"}},{"code_sha256_prefix":"e891a84231ca8dd6","entry":"gpt4_eval","repo":"Lingkai-Kong/RE-Control","repo_kind":"official","path":"gpt4_eval.py","file_url":"https://github.com/Lingkai-Kong/RE-Control/blob/HEAD/gpt4_eval.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"e891a84231ca8dd6"}},{"code_sha256_prefix":"9e69e7d1e58dec6b","entry":"test_epoch","repo":"lingkai-kong/re-control","repo_kind":"official","path":"train_value_model.py","file_url":"https://github.com/lingkai-kong/re-control/blob/HEAD/train_value_model.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9e69e7d1e58dec6b"}},{"code_sha256_prefix":"1b355772493f759c","entry":"train_epoch","repo":"lingkai-kong/re-control","repo_kind":"official","path":"train_value_model.py","file_url":"https://github.com/lingkai-kong/re-control/blob/HEAD/train_value_model.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1b355772493f759c"}},{"code_sha256_prefix":"c19b40e338f183c3","entry":"Intervented_LlamaForCausalLM","repo":"lingkai-kong/re-control","repo_kind":"official","path":"intervented_model/llama.py","file_url":"https://github.com/lingkai-kong/re-control/blob/HEAD/intervented_model/llama.py","link_basis":"first_harvest_node","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":"c19b40e338f183c3"}},{"code_sha256_prefix":"e5833ed42b181705","entry":"Intervented_LlamaModel","repo":"lingkai-kong/re-control","repo_kind":"official","path":"intervented_model/llama.py","file_url":"https://github.com/lingkai-kong/re-control/blob/HEAD/intervented_model/llama.py","link_basis":"first_harvest_node","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":"e5833ed42b181705"}},{"code_sha256_prefix":"93c198d58d919707","entry":"compute_diversity","repo":"Lingkai-Kong/RE-Control","repo_kind":"official","path":"metrics.py","file_url":"https://github.com/Lingkai-Kong/RE-Control/blob/HEAD/metrics.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":"93c198d58d919707"}},{"code_sha256_prefix":"6c1c5b07ef997d49","entry":"compute_rep_n","repo":"Lingkai-Kong/RE-Control","repo_kind":"official","path":"metrics.py","file_url":"https://github.com/Lingkai-Kong/RE-Control/blob/HEAD/metrics.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":"6c1c5b07ef997d49"}},{"code_sha256_prefix":"66a8dc7918ff99ab","entry":"extract_out","repo":"lingkai-kong/re-control","repo_kind":"official","path":"measure_reward.py","file_url":"https://github.com/lingkai-kong/re-control/blob/HEAD/measure_reward.py","link_basis":"first_harvest_node","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":"66a8dc7918ff99ab"}},{"code_sha256_prefix":"71124f71d7503e4d","entry":"get_llm_activations","repo":"Lingkai-Kong/RE-Control","repo_kind":"official","path":"get_activations_only.py","file_url":"https://github.com/Lingkai-Kong/RE-Control/blob/HEAD/get_activations_only.py","link_basis":"first_harvest_node","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":"71124f71d7503e4d"}},{"code_sha256_prefix":"27de88ce6534463a","entry":"process_hidden_states","repo":"Lingkai-Kong/RE-Control","repo_kind":"official","path":"get_activations_only.py","file_url":"https://github.com/Lingkai-Kong/RE-Control/blob/HEAD/get_activations_only.py","link_basis":"first_harvest_node","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":"27de88ce6534463a"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}