{"name":"EasyEdit: An Easy-to-Use Knowledge Editing Framework for LLMs","description":"EasyEdit is an open-source framework designed for efficient knowledge editing in Large Language Models (LLMs). It provides a unified, easy-to-use platform to modify, insert, or erase specific knowledge within LLMs without negatively impacting overall performance. This tool is crucial for aligning LLMs with evolving user needs and correcting factual inaccuracies.","github":"https://github.com/zjunlp/EasyEdit","url":"https://osrepos.com/repo/zjunlp-easyedit","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/zjunlp-easyedit","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/zjunlp-easyedit.md","json":"https://osrepos.com/repo/zjunlp-easyedit.json","topics":["artificial-intelligence","knowledge-editing","large-language-models","natural-language-processing","easyedit","jupyter-notebook","machine-learning","nlp"],"keywords":["artificial-intelligence","knowledge-editing","large-language-models","natural-language-processing","easyedit","jupyter-notebook","machine-learning","nlp"],"stars":null,"summary":"EasyEdit is an open-source framework designed for efficient knowledge editing in Large Language Models (LLMs). It provides a unified, easy-to-use platform to modify, insert, or erase specific knowledge within LLMs without negatively impacting overall performance. This tool is crucial for aligning LLMs with evolving user needs and correcting factual inaccuracies.","content":"## Introduction\nEasyEdit is a powerful and user-friendly open-source framework developed by zjunlp, designed for knowledge editing in Large Language Models (LLMs). Presented at ACL 2024, EasyEdit addresses the critical need to efficiently update, insert, or erase specific knowledge within pre-trained LLMs. This is essential for correcting factual errors, mitigating biases, and adapting models to new information without undergoing extensive retraining. The framework offers a unified approach to various editing scenarios, methods, and evaluation metrics, making it a comprehensive solution for researchers and developers working with LLMs.\n\n## Installation\nTo get started with EasyEdit, ensure you have Python 3.9 or higher installed. Follow these steps for a quick setup:\n\nbash\ngit clone https://github.com/zjunlp/EasyEdit.git\nconda create -n EasyEdit python=3.10\nconda activate EasyEdit\npip install -r requirements.txt\n\n\n## Examples\nEasyEdit is designed for modularity and flexibility, allowing users to easily integrate and apply editing methods. Here's a simplified example demonstrating how to use `BaseEditor` for factual knowledge editing:\n\n### Step 1: Define the PLM (Pre-trained Language Model) to be edited.\nEasyEdit supports models like T5, GPT-J, GPT-NEO, and Llama, retrievable from HuggingFace. You configure the model in a YAML file (e.g., `hparams/MEND/gpt2-xl.yaml`).\n\nyaml\nmodel_name: gpt2-xl\nmodel_class: GPT2LMHeadModel\ntokenizer_class: GPT2Tokenizer\ntokenizer_name: gpt2-xl\nmodel_parallel: false # true for multi-GPU editing\n\n\n### Step 2: Choose the appropriate Knowledge Editing Method.\nFor instance, using the MEND method:\n\npython\n## In this case, we use MEND method, so you should import `MENDHyperParams`\nfrom easyeditor import MENDHyperParams\n## Loading config from hparams/MEMIT/gpt2-xl.yaml\nhparams = MENDHyperParams.from_hparams('./hparams/MEND/gpt2-xl')\n\n\n### Step 3: Provide the edit descriptor and target.\nDefine the prompts you want to edit and their desired new outputs.\n\npython\n## edit descriptor: prompt that you want to edit\nprompts = [\n    'What university did Watts Humphrey attend?',\n    'Which family does Ramalinaceae belong to',\n    'What role does Denny Herzig play in football?'\n]\n## You can set `ground_truth` to None !!!(or set to original output)\nground_truth = ['Illinois Institute of Technology', 'Lecanorales', 'defender']\n## edit target: expected output\ntarget_new = ['University of Michigan', 'Lamiinae', 'winger']\n\n\n### Step 4: Initialize the `BaseEditor`.\n`EasyEdit` provides a simple and unified way to init `Editor`, like huggingface: **from_hparams**.\n\npython\n## Construct Language Model Editor\nfrom easyeditor import BaseEditor\neditor = BaseEditor.from_hparams(hparams)\n\n\n### Step 5: (Optional) Provide data for evaluation.\nYou can include `locality_inputs` and `portability_inputs` to assess the broader impact of the edit.\n\npython\nlocality_inputs = {\n    'neighborhood':{\n        'prompt': ['Joseph Fischhof, the', 'Larry Bird is a professional', 'In Forssa, they understand'],\n        'ground_truth': ['piano', 'basketball', 'Finnish']\n    }\n}\n\n\n### Step 6: Perform the Edit and Evaluation.\nThe `edit` function will return metrics and the modified model.\n\npython\nmetrics, edited_model, _ = editor.edit(\n    prompts=prompts,\n    ground_truth=ground_truth,\n    target_new=target_new,\n    locality_inputs=locality_inputs,\n    sequential_edit=False # Set to True for continuous editing\n)\n\n\nFor more hands-on experience, EasyEdit provides a handy [Jupyter Notebook tutorial](https://github.com/zjunlp/EasyEdit/blob/main/tutorial-notebooks/EasyEdit_Example_US_President.ipynb){:target=\"_blank\"} that demonstrates editing an LLM's knowledge about the US president.\n\n## Why Use EasyEdit\nEasyEdit stands out as a comprehensive and efficient solution for knowledge editing in LLMs due to several key advantages:\n\n*   **Unified Framework**: It integrates various editing scenarios (factual, multimodal, safety, personality) and techniques (e.g., ROME, MEMIT, SERAC, MEND) into a single, consistent interface.\n*   **Extensive Model Support**: The framework supports a wide range of LLMs, from GPT series to Llama, Baichuan, ChatGLM, and more, including Large Multimodal Models (LMMs).\n*   **Robust Evaluation**: EasyEdit provides a detailed evaluation suite with metrics like Reliability, Generalization, Locality, and Portability, ensuring thorough assessment of editing success and side effects.\n*   **Continuous Editing**: It supports sequential editing, allowing for multiple knowledge updates while maintaining consistency.\n*   **Active Development & Community**: The project is actively maintained, with frequent updates, new methods, and datasets being integrated, fostering a vibrant community.\n*   **Detailed Documentation & Tutorials**: With comprehensive READMEs, beginner's guides, and Jupyter Notebook tutorials, getting started and exploring advanced features is straightforward.\n\n## Links\n*   **GitHub Repository**: [https://github.com/zjunlp/EasyEdit](https://github.com/zjunlp/EasyEdit){:target=\"_blank\"}\n*   **Paper (ACL 2024)**: [https://arxiv.org/abs/2401.01286](https://arxiv.org/abs/2401.01286){:target=\"_blank\"}\n*   **HuggingFace Demo**: [https://huggingface.co/spaces/zjunlp/EasyEdit](https://huggingface.co/spaces/zjunlp/EasyEdit){:target=\"_blank\"}\n*   **KnowEdit Benchmark**: [https://huggingface.co/datasets/zjunlp/KnowEdit](https://huggingface.co/datasets/zjunlp/KnowEdit){:target=\"_blank\"}","metrics":{"detailViews":8,"githubClicks":4},"dates":{"published":null,"modified":"2026-01-26T16:01:16.000Z"}}