EasyEdit  by zjunlp

Framework for LLM knowledge editing (ACL 2024 paper)

created 2 years ago
2,483 stars

Top 19.2% on sourcepulse

GitHubView on GitHub
Project Summary

EasyEdit is a comprehensive Python framework designed for efficiently editing knowledge within Large Language Models (LLMs). It targets researchers and practitioners in NLP who need to correct factual inaccuracies, update outdated information, or remove sensitive data from LLMs without extensive retraining. The framework offers a unified interface to various knowledge editing techniques, simplifying their implementation and evaluation.

How It Works

EasyEdit provides a modular architecture with distinct components for Editor, Method, and Evaluate. Users select an LLM, choose a knowledge editing technique (e.g., ROME, MEND, GRACE), and define the edit descriptors (prompts and target outputs). The framework then applies the chosen method to modify the model's parameters, aiming to alter specific behaviors while preserving general performance. It supports both single and continuous knowledge editing scenarios.

Quick Start & Requirements

  • Installation: pip install -r requirements.txt after cloning the repository. Requires Python 3.9+.
  • Prerequisites: PyTorch, Transformers library (version 4.34.0+ recommended for Mistral). GPU with sufficient memory (e.g., 23GB for GRACE on GPT-J, 40GB+ for Llama-2-7B).
  • Setup: Clone repository, create conda environment, install requirements.
  • Docs: README, Tutorial Notebooks

Highlighted Details

  • Supports a wide range of LLMs (T5, GPT series, Llama, Mistral, etc.) and editing methods (over 20 listed).
  • Includes extensive benchmarks and datasets (KnowEdit, CKnowEdit, SafeEdit) for evaluating editing performance across metrics like Reliability, Generalization, Locality, and Portability.
  • Offers support for multimodal LLM editing and personality editing.
  • Version 2.0 introduces real-time steering of LLMs during inference without retraining.

Maintenance & Community

The project is actively maintained with frequent updates and contributions. It has a strong academic backing, with papers accepted at major conferences like ACL, EMNLP, and NeurIPS. Community engagement is encouraged via GitHub Issues and PRs.

Licensing & Compatibility

  • License: MIT License.
  • Compatibility: Permissive license allows for commercial use and integration with closed-source projects.

Limitations & Caveats

The maximum input length for edits is 512 tokens, exceeding which can cause CUDA errors. Some methods (e.g., MALMEN) have partial support. Rollback functionality is currently limited to the GRACE method.

Health Check
Last commit

5 days ago

Responsiveness

1 day

Pull Requests (30d)
10
Issues (30d)
10
Star History
233 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.