{"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/spectral-editing-of-activations-for-large","title":"Spectral Editing of Activations for Large Language Model Alignment","arxiv_id":"2405.09719","date":"2024-05-15","proceeding":null,"authors":["Yifu Qiu","Zheng Zhao","Yftah Ziser","Anna Korhonen","Edoardo M. Ponti","Shay B. Cohen"],"abstract":"Large language models (LLMs) often exhibit undesirable behaviours, such as generating untruthful or biased content. Editing their internal representations has been shown to be effective in mitigating such behaviours on top of the existing alignment methods. We propose a novel inference-time editing method, namely spectral editing of activations (SEA), to project the input representations into directions with maximal covariance with the positive demonstrations (e.g., truthful) while minimising covariance with the negative demonstrations (e.g., hallucinated). We also extend our method to non-linear editing using feature functions. We run extensive experiments on benchmarks concerning truthfulness and bias with six open-source LLMs of different sizes and model families. The results demonstrate the superiority of SEA in effectiveness, generalisation to similar tasks, as well as computation and data efficiency. We also show that SEA editing only has a limited negative impact on other model capabilities.","url_abs":"https://arxiv.org/abs/2405.09719v3","url_pdf":"https://arxiv.org/pdf/2405.09719v3.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":"spectral-editing-of-activations-for-large","repo_url":"https://github.com/yfqiu-nlp/sea-llm","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"large-language-model","task_name":"Large Language Model"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2405.09719","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2405.09719"}},"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/yfqiu-nlp/sea-llm","reach":null}],"summary":{"ran":3,"ran_honours":1,"ran_fixture":2,"unverified":1},"by_repo_kind":{"official":{"samples":7,"ran":6,"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":"8da14c2ed8b18b3e","entry":"AdapterLayer","repo":"yfqiu-nlp/sea-llm","repo_kind":"official","path":"src/decoding_algorithm/inference.py","file_url":"https://github.com/yfqiu-nlp/sea-llm/blob/HEAD/src/decoding_algorithm/inference.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8da14c2ed8b18b3e"}},{"code_sha256_prefix":"4a899bf9876b28be","entry":"LLamaQaStoppingCriteria","repo":"yfqiu-nlp/sea-llm","repo_kind":"official","path":"src/decoding_algorithm/inference.py","file_url":"https://github.com/yfqiu-nlp/sea-llm/blob/HEAD/src/decoding_algorithm/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":"4a899bf9876b28be"}},{"code_sha256_prefix":"a7ff01581b98b9d3","entry":"ev_id","repo":"yfqiu-nlp/sea-llm","repo_kind":"official","path":"sea-train.py","file_url":"https://github.com/yfqiu-nlp/sea-llm/blob/HEAD/sea-train.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a7ff01581b98b9d3"}},{"code_sha256_prefix":"8b3675363502e274","entry":"get_heuristic_info","repo":"yfqiu-nlp/sea-llm","repo_kind":"official","path":"sea-train.py","file_url":"https://github.com/yfqiu-nlp/sea-llm/blob/HEAD/sea-train.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8b3675363502e274"}},{"code_sha256_prefix":"e9bba4fd98cb4d74","entry":"model_with_adapter","repo":"yfqiu-nlp/sea-llm","repo_kind":"official","path":"src/decoding_algorithm/inference.py","file_url":"https://github.com/yfqiu-nlp/sea-llm/blob/HEAD/src/decoding_algorithm/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":"e9bba4fd98cb4d74"}},{"code_sha256_prefix":"e1a379ee36ea0f89","entry":"non_linear_feature_func","repo":"yfqiu-nlp/sea-llm","repo_kind":"official","path":"sea-train.py","file_url":"https://github.com/yfqiu-nlp/sea-llm/blob/HEAD/sea-train.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e1a379ee36ea0f89"}},{"code_sha256_prefix":"1a8fb28e1b16fdd7","entry":"Inference","repo":"yfqiu-nlp/sea-llm","repo_kind":"official","path":"src/decoding_algorithm/inference.py","file_url":"https://github.com/yfqiu-nlp/sea-llm/blob/HEAD/src/decoding_algorithm/inference.py","link_basis":"first_harvest_node","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":"1a8fb28e1b16fdd7"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}