{"id":28676503,"url":"https://github.com/zjunlp/steer-target-atoms","last_synced_at":"2025-06-13T23:04:52.757Z","repository":{"id":297192834,"uuid":"988954469","full_name":"zjunlp/steer-target-atoms","owner":"zjunlp","description":"[ACL 2025] Beyond Prompt Engineering: Robust Behavior Control in LLMs via Steering Target Atoms","archived":false,"fork":false,"pushed_at":"2025-06-04T14:10:21.000Z","size":420,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-04T15:52:03.365Z","etag":null,"topics":["acl2025","artificial-intelligence","controlled-generation","easyedit2","knowledge-editing","large-language-models","model-editing","natural-language-processing","safety","sta","steering-behaviors"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zjunlp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-23T10:29:01.000Z","updated_at":"2025-06-04T14:10:23.000Z","dependencies_parsed_at":"2025-06-04T15:52:17.688Z","dependency_job_id":"6f5407d3-43ae-4331-8ed5-2ea070cc9f8e","html_url":"https://github.com/zjunlp/steer-target-atoms","commit_stats":null,"previous_names":["zjunlp/steer-target-atoms"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zjunlp/steer-target-atoms","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zjunlp%2Fsteer-target-atoms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zjunlp%2Fsteer-target-atoms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zjunlp%2Fsteer-target-atoms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zjunlp%2Fsteer-target-atoms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zjunlp","download_url":"https://codeload.github.com/zjunlp/steer-target-atoms/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zjunlp%2Fsteer-target-atoms/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259732772,"owners_count":22903087,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acl2025","artificial-intelligence","controlled-generation","easyedit2","knowledge-editing","large-language-models","model-editing","natural-language-processing","safety","sta","steering-behaviors"],"created_at":"2025-06-13T23:04:52.191Z","updated_at":"2025-06-13T23:04:52.745Z","avatar_url":"https://github.com/zjunlp.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cdiv align=\"center\"\u003e\n    \n# **Beyond Prompt Engineering: Robust Behavior Control in LLMs via Steering Target Atoms**\n    \n\u003c/div\u003e\n\n\n\n## 🔧 Pip Installation\n\nTo get started, simply install conda:\n\n```shell\nconda create -n sta python=3.11 -y\npip install -r requirements.txt\ncd ./TransformerLens\npip install -e . # 2.4.0\ncd ../trl\npip install -e . # for sft dpo training\n```\n\n\n## 📂 Data Preparation\n\n**Dataset and Steering Vector**\n\nThe data for STA can be downloaded [here](https://huggingface.co/datasets/mengru/data_for_STA).\n\n\n**Directory Structure**\n\n```\nsteer-target-atoms\n└── data\n    ├── mmlu\n    └── safety\n```\n\n## 💻 Run\n\n### Steering vector\n\n#### directly download\n\nIf you download data from [here](https://huggingface.co/datasets/mengru/data_for_STA), then you can get the steering vectors used in this paper:\n\n- steering vecotr for Gemma-2-9b-it (./data/safety/toxic_DINM_it/sae_caa_vector_it/gemma-2-9b-it_safety/act_and_fre_trim/steering_vector)\n\n- steering vecotr for Gemma-2-9b-pt (./data/safety/toxic_DINM_pt/sae_caa_vector_pt/gemma-2-9b_safety/act_and_fre_trim/steering_vector)\n\n  Then, you can directly go to the [Steering the behaviors of LLMs](#steering-the-behaviors-of-llms) section.\n\n#### Generate the steering vector by yourself\n\nYou can also generate these steering vectors using the following steps by yourself:\n\n1. Download the sae\n\n- Download sea for Gemma-2-9b-it from [here](https://huggingface.co/google/gemma-scope-9b-it-res/tree/main/layer_20/width_16k/average_l0_91), then replace the value of sae_paths (in ./scripts/generate_vector/gemma/sta/run_selection_safe_gemma_it_DINM.sh) with your own path.\n\n- Download sea for Gemma-2-9b-pt from [here](https://huggingface.co/google/gemma-scope-9b-pt-res/tree/main/layer_24/width_16k/average_l0_114), then replace the value of sae_paths (in ./scripts/generate_vector/gemma/sta/run_selection_safe_gemma_pt_DINM.sh) with your own path.\n\n\n\n2. Genetate steering vector\n\n```shell\nbash run_generate_vector.sh\n```\n\n### Steering the behaviors of LLMs \n\nYou can steering the behaviors of LLMs by **steering vector**\n\n```shell\nbash run_main_table.sh\n```\n\u003e ❗️ You should replace the value of model_name_or_path in the corresponding xx.sh file with your own model path.\n\n### Evaluation\n\n```shell\nbash run_eval.sh\n```\n\n## 🌟 Some Important Information\n\nThis repository is developed for our STA paper. We also release [EasyEdit2](https://github.com/zjunlp/EasyEdit/blob/main/README_2.md), a unified framework for controllable editing without retraining. It integrates multiple steering methods to facilitate usage and evaluation.\nUnlike this repository, which depends on TransformerLens, EasyEdit2 is independent of it.\n\nWe recommend using [EasyEdit2](https://github.com/zjunlp/EasyEdit/blob/main/README_2.md) for future research and applications.\n\n# 📖 Citation\n\nPlease cite our paper if you use **STA** in your work.\n\n```bibtex\n@misc{wang2025STA,\n      title={Beyond Prompt Engineering: Robust Behavior Control in LLMs via Steering Target Atoms}, \n      author={Mengru Wang, Ziwen Xu, Shengyu Mao, Shumin Deng, Zhaopeng Tu, Huajun Chen, Ningyu Zhang},\n      year={2025},\n      eprint={2505.20322},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzjunlp%2Fsteer-target-atoms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzjunlp%2Fsteer-target-atoms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzjunlp%2Fsteer-target-atoms/lists"}