{"data":{"slug":"zichuan-liu-ib4llms","name":"IB4LLMs","tagline":"[NeurIPS'24] Protecting Your LLMs with Information Bottleneck","github_url":"https://github.com/zichuan-liu/IB4LLMs","owner":"zichuan-liu","repo":"IB4LLMs","owner_avatar_url":"https://avatars.githubusercontent.com/u/46738976?v=4","primary_language":"Python","stars":25,"forks":2,"topics":[],"archived":false,"github_pushed_at":"2024-11-07T07:25:58+00:00","maintenance_label":"Dormant","url":"https://www.graphcanon.com/tools/zichuan-liu-ib4llms","markdown_url":"https://www.graphcanon.com/tools/zichuan-liu-ib4llms.md","api_url":"https://www.graphcanon.com/api/graphcanon/tools/zichuan-liu-ib4llms","graph_url":"https://www.graphcanon.com/api/graphcanon/graph?tool=zichuan-liu-ib4llms","description":"[NeurIPS'24] Protecting Your LLMs with Information Bottleneck","homepage_url":"https://zichuan-liu.github.io/projects/IBProtector/index.html","license":null,"open_issues":4,"watchers":1,"ai_summary":null,"readme_excerpt":"# <p align=center> :fire: `Protecting Your LLMs with Information Bottleneck`</p>\n\n\n[[Arxiv Paper](https://arxiv.org/abs/2404.13968)] [[Slides](https://zichuan-liu.github.io/talk/ib_slides.pdf)] [[中文版](https://zhuanlan.zhihu.com/p/694129510)] [[Website Page](https://zichuan-liu.github.io/projects/IBProtector/index.html)] \n\n**TL;DR**: We propose IBProtector, the first LLM jailbreak defending method based on the Information Bottleneck principle. Our protector efficiently defends against adversarial prompts without losing key information.\n\n\n\n> 🌟 If you want to read the main code of IBProtector, check out the class **VIBLLM** in the file `./lib/defenses.py`.\n\n## Dependent version\n\n```bash\npip install -U datasets==2.14.5 torch==2.1.1 torchmetrics==1.2.0 bitsandbytes==0.43.0 openai==0.28.0 fschat==0.2.20\npip install -U transformers==4.40.1\n```\n``please don't change the order, otherwise it will have comfict sicne this fschat verson is too old``\n\n## Getting Started\n\n### model configuration\nFirst set up the path and parameters of your LLMs configuration in the file `lib/model_configs.py`\n\n\n### data preparing\nDatasets acquisition instuction in the file `./data/README.md`, overall, you should get your jailbreaking data by `GCG` or `PAIR` in advance. \n\n### how to tune models\n\nTo finetune the IBProtector of Vicuna-13b, you can execute the following command\n```bash\npython test_finetuning.py\n```\n\nTo finetune the IBProtector of Llama2-7b, you can execute the following command\n```bash\npython test_finetuning_llama.py\n```\n\nThe baselines `sft` and `unlearning` are set in files `test_sft.py` and `test_unlearning.py`, respectively.\n\n### how to inference\n\nYou can execute the following command\n```bash\npython main.py  --results_dir ./our_results  --target_model vicuna  --attack TriviaQA --method vib --cuda 0\n```\nThe denfense **method** can be chosen: `none`, `smooth`, `selfdefense`, `sft`, `unlearning`, `ra`, `semantic`, and `vib`, Note that the `vib`, `sft`, and `unlearning` need to fine-tune the LLMs in advance, via the corresponding commands. \n\nThe **attack** method can be chosen: `GCG` and `PAIR` for the main experiment, `EasyJailbreak` for the transferability,  and `TriviaQA` for testing benign answering rates.\n\n\nYou can also run the main results through the script:\n\n```bash\nbash script.sh\n```\n\n## Evaluating the results\n\nPlease find the examples in `./eval/eval_asr.py`,  `./eval/eval_harm.py`, `./eval/eval_gpt.py`, `./eval/eval_friedman.py`, and `./eval/eval_time.py` to evaluate the results. The main you need is to change your result path by modifying `file_path`\n\n\nFor instance, the evaluating command is:\n```bash\ncd eval/\npython eval_asr.py  --file_path `YOUR_RESULTS_PATH`\n```\n\n\n\n## Further Reading\nFor more information about theories and limitations of existing perturbation methods, please see [THIS SLIDE](https://zichuan-liu.github.io/talk/ib_slides.pdf).\n\nThe following are related works:\n\n1, [**Explaining Time Series via Contrastive and Locally Sparse Perturbations**](https://openreview.net/pdf?id=qDdSRaOiyb), in ICLR 2024.\n[\\[GitHub Repo\\]](https://github.com/zichuan-liu/ContraLSP)\n\n\n2, [**TimeX++: Learning Time-Series Explanations with Information Bottleneck**](https://arxiv.org/abs/2405.09308), in ICML 2024.\n[\\[GitHub Repo\\]](https://github.com/zichuan-liu/TimeXplusplus)\n\n\n## Citing IBProtector\n🌟 If you find this resource helpful, please consider starting this repository and cite our research:\n```tex\n@inproceedings{liu2024protecting,\n      title={Protecting Your LLMs with Information Bottleneck}, \n      author={Zichuan Liu and Zefan Wang and Linjie Xu and Jinyu Wang and Lei Song and Tianchun Wang and Chunlin Chen and Wei Cheng and Jiang Bian},\n      year={2024},\n      booktitle={Neural Information Processing Systems}\n}\n```\nIn case of any questions, bugs, suggestions, or improvements, please feel free to drop me at _zichuanliu@smail.nju.edu.cn_ or open an issue.","github_created_at":"2024-04-17T08:21:38+00:00","created_at":"2026-07-11T23:41:48.084476+00:00","updated_at":"2026-07-11T23:41:53.362723+00:00","categories":[{"slug":"llm-frameworks","name":"LLM Frameworks","url":"https://www.graphcanon.com/categories/llm-frameworks","markdown_url":"https://www.graphcanon.com/categories/llm-frameworks.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/llm-frameworks"},{"slug":"model-training","name":"Model Training","url":"https://www.graphcanon.com/categories/model-training","markdown_url":"https://www.graphcanon.com/categories/model-training.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/model-training"},{"slug":"inference-serving","name":"Inference & Serving","url":"https://www.graphcanon.com/categories/inference-serving","markdown_url":"https://www.graphcanon.com/categories/inference-serving.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/inference-serving"}],"tags":[{"slug":"python","name":"python"}],"trust":{"provenance":{"is_fork":false,"github_id":787810972,"owner_type":"User","methodology":"github_public_v1","parent_repo":null,"near_duplicate_slugs":[]},"computed_at":"2026-07-11T23:41:49.667Z","maintenance":{"label":"Dormant","score":18,"methodology":"github_public_v1","releases_90d":0,"days_since_push":611,"last_release_at":null},"security_summary":{"status":"findings","scanner":"osv@v1","low_count":77,"high_count":0,"last_scan_at":"2026-07-11T23:41:50.176Z","medium_count":0,"scan_profile":"deps","critical_count":0}},"capability_facts":{"scan":{"source":"repo_scan","observed_at":"2026-07-11T23:41:49.381Z"},"languages":{"value":["python"],"source":"github.language","observed_at":"2026-07-11T23:41:49.381Z"}}}}