GithubHelp home page GithubHelp logo

ivan-yinty / pmet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xpq-tech/pmet

0.0 0.0 0.0 550 KB

This is a repository for "PMET: Precise Model Editing in a Transformer"

Python 88.40% Jupyter Notebook 11.50% Shell 0.10%

pmet's Introduction

PMET

Requirements

  • At least one A100/A800 80G GPU and another GPU with no less than 24G memory.
  • Environment
    conda create -n pmet python=3.10
    pip install -r requirements.txt

Quick Start

An example for editing GPT-J (6B) on counterfact dataset using PMET

1. Edit GPT-J model

python evaluate.py --model_path [your model path] --model_name EleutherAI/gpt-j-6B --alg_name PMET --hparams_fname EleutherAI_gpt-j-6B.json --ds_name mcf --num_edits [num]

Computing $C_0$ and $v^m_i$ for 10K edits will take about a day. But the $C_0$ and $v^m_i$ for the 10K edits will be stored after computing, they will be directly used without recomputing in the next run for the 10K edits. It will then take about 1 hour to complete the model editing. After model editing, it will take a dozen hours to complete the evaluation. Using '--skip_generation_tests' will significantly speed up evaluation.

2. Summarize the results

python summarize.py --dir_name=PMET --runs=run_<run1>,run_<run2>

Another example for editing GPT-J (6B) on zsRE dataset using PMET

python evaluate.py --model_path [your model path] --model_name EleutherAI/gpt-j-6B --hparams_fname EleutherAI_gpt-j-6B-zsre.json --ds_name zsre --num_edits [num]

Then just summarize the results

Acknowledgment

Our code is based on MEMIT.

Citation

Xiaopeng Li, Shasha Li, Shezheng Song, Jing Yang, Jun Ma, Jie Yu. PMET: Precise Model Editing in a Transformer. arXiv preprint arXiv:2308.08742 (2023).

@article{li2023pmet,
  title={PMET: Precise Model Editing in a Transformer},
  author={Li, Xiaopeng and Li, Shasha and Song, Shezheng and Yang, Jing and Ma, Jun and Yu, Jie},
  journal={arXiv preprint arXiv:2308.08742},
  year={2023}
}

pmet's People

Contributors

xpq-tech avatar ivan-yinty 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.