Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.1%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

Basic Info
  • Host: GitHub
  • Owner: anshitag
  • License: mit
  • Language: Python
  • Default Branch: clean-code
  • Size: 2.62 MB
Statistics
  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created almost 3 years ago · Last pushed over 2 years ago
Metadata Files
Readme License Citation

README.md

Editing Common Sense in Transformers

EMNLP 2023 Paper: Editing Common Sense in Transformers

We find that commonsense judgments by GPT-2 are associated with localized parameters in early MLP layers of the models by conducting causal mediation analyses. We propose to correct commonsense judgments in transformer models by $MEMIT_{CSK}$, an adaptation of Mass-Editing Memory in a Transformer that can edit subject, verb, or object token positions and features a robust editing layer selection strategy.

Table of Contents

Installation

Similar to MEMIT installation instructions. We recommend conda for managing Python, CUDA, and PyTorch; pip is for everything else. To get started, simply install conda and run: bash CONDA_HOME=$CONDA_HOME ./scripts/setup_conda.sh

$CONDA_HOME should be the path to your conda installation, e.g., ~/miniconda3.

Datasets

The 20 Question and PEP 3K datasets are under the data folder. Each dataset consists of Train, Edit Validation, Edit, and Probe Sets. - Training Set and Edit Validation Set: Formed by randomly dividing the validation set from Porada et al. (2021) into an 80%-20% split. - Edit Set: The test set from Porada et al. (2021). - Probe Set: For the subset of Edit Set that was incorrectly predicted by both GPT-2 Large and XL Base Model, we augment each instance with semantically related instances generated by GPT-3 text-davinci-003. The types of relations we consider include unaffected neighborhood, affected neighborhood, affected paraphrase, and affected reasoning, which are detailed in Sec. 4.2.1 of our paper.

Evaluation Metrics

We report three metrics on the Edit Validation Set and Edit Set: - F1 Score (↑), a measure of overall performance - Efficacy (↑), the percentage of previously incorrect predictions that are corrected by an update method - Relapse (↓), the percentage of instances that were previously predicted correctly but are now predicted incorrectly

We report accuracy on different types of augmented instances in the Probe Set.

The metrics are at eval_utils_csk.py.

Base Finetuning

script_base_finetuning.sh can be used for running base finetuning on the GPT2-XL model for the 20q dataset. Similar command can be used for running experiments for GPT2-Large model and PEP 3K dataset.

Causal Tracing

script_causal_trace_zero_shot.sh can be used for performing causal tracing experiment for zero shot model.

script_causal_trace.sh can be used for performing causal tracing experiment for base finetuned model, by passing its checkpoint location as a parameter and output inference file.

script_causal_trace_severed.sh can be used for performing severed causal tracing experiment for base finetuned model, by passing it's checkpoint location as a parameter and output inference file.

Repair Finetuning

script_repair_finetuning.sh can be used for running repair finetuning on the base finetuned GPT2-XL model for the 20q dataset. Similar command can be used for running experiments for GPT2-Large model and PEP 3K dataset.

It includes commands to evaluate the affected and unaffected metrics for the repair finetuned model.

MEMIT_CSK Experiment

script_memit_csk.sh can be used for running $MEMIT_{CSK}$ on the base finetuned GPT2-XL model for the 20q dataset. Similar commands can be used for running experiments for GPT2-Large model and PEP 3K dataset.

It includes commands to (1) find best hyperparamters for the Edit Validation Set and perform configuration generalization evaluation on the Edit Set, and (2) run semantic generalization evaluation on the Probe Set. Please refer to Section 3.3-3.4 in our paper for descriptions of the two types of generalization.

How to Cite

bibtex @article{gupta2023editing, title={Editing Common Sense in Transformers}, author={Gupta, Anshita and Mondal, Debanjan and Sheshadri, Akshay Krishna and Zhao, Wenlong and Li, Xiang Lorraine and Wiegreffe, Sarah and Tandon, Niket}, journal={arXiv preprint arXiv:2305.14956}, year={2023} }

Owner

  • Name: Anshita Gupta
  • Login: anshitag
  • Kind: user

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
preferred-citation:
  type: article
  authors:
  - family-names: "Gupta"
    given-names: "Anshita"
  - family-names: "Mondal"
    given-names: "Debanjan"
  - family-names: "Sheshadri"
    given-names: "Akshay Krishna"
  - family-names: "Zhao"
    given-names: "Wenlong"
  - family-names: "Li"
    given-names: "Xiang Lorraine"
  - family-names: "Wiegreffe"
    given-names: "Sarah"
  - family-names: "Tandon"
    given-names: "Niket"
  journal: "arXiv preprint arXiv:2305.14956"
  title: "Editing Commonsense Knowledge in GPT"
  year: 2023

GitHub Events

Total
Last Year