Giter VIP home page Giter VIP logo

wilke's Introduction

Wise-layer Knowledge Editor (WilKE)

This is the relevant code for the paper WilKE: Wise-Layer Knowledge Editor for Lifelong Knowledge Editing.

Requirements

conda create -n wilke python=3.10
pip install -r requirements.txt

To achieve the baseline (KE & MEND), download the necessary open source model (Please refer to ROME).

  • Download related KE (for GPT2-XL):
wget https://rome.baulab.info/data/weights/efk-1tok-gpt2-xl.pt -P baselines/efk/weights
  • Download related MEND (for GPT2-XL & GPT-J):
wget https://rome.baulab.info/data/weights/mend-10tok-gpt2-xl.pt -P baselines/mend/weights
wget https://rome.baulab.info/data/weights/mend-10tok-gpt-j-6b.pt -P baselines/mend/weights

To achieve the baseline (ROME&MEMIT), download the necessary open source data (Please refer to ROME).

wget -r -np -nH --cut-dirs=2 https://rome.baulab.info/data/stats -P data
wget -r -np -nH --cut-dirs=2 -A "*" https://rome.baulab.info/data/dsets/ -P data

Filtered data

Based on the CounterFact dataset, we filter the data that would cause toxicity flash when editing GPT2-XL and GPT-J, respectively. For details, see data/.

Quick Start

You can use WilKE to perform 1024 steps of continuous knowledge editing on GPT2-XL with the following command, and you can modify --alg_name and --model_name to use other knowledge editing methods and language models.

python3 -m experiments.evaluate --alg_name=WilKE --model_name=gpt2-xl --hparams_fname=gpt2-xl.json --ds_name=counterfact --dataset_size_limit=2048 --edit_times=1024 --skip_generation_tests

You can then use the experiments/summarize* jupyter notebook files to summarize the results of your runs.

Acknowledgements

Our code is built based on ROME and MEMIT, so we would like to thank the original authors.

How to Cite

@article{hu2024wilke,
  title={WilKE: Wise-Layer Knowledge Editor for Lifelong Knowledge Editing},
  author={Hu, Chenhui and Cao, Pengfei and Chen, Yubo and Liu, Kang and Zhao, Jun},
  journal={arXiv preprint arXiv:2402.10987},
  year={2024}
}

wilke's People

Contributors

chenhuihu avatar tututututututuutututu avatar

Stargazers

 avatar Xiaojie Gu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.