Skip to content

NUSTM/ChainEdit

Repository files navigation

ChainEdit

Introduction

This repository contains the implementation of the paper ChainEdit: Propagating Ripple Effects in LLM Knowledge Editing through Logical Rule-Guided Chains.

Abstract

Current knowledge editing methods for large language models (LLMs) struggle to maintain logical consistency when propagating ripple effects to associated facts. We propose ChainEdit, a framework that synergizes knowledge graph-derived logical rules with LLM logical reasoning capabilities to enable systematic chain updates. By automatically extracting logical patterns from structured knowledge bases and aligning them with LLMs' internal logics, ChainEdit dynamically generates and edits logically connected knowledge clusters. Experiments demonstrate an improvement of more than 30% in logical generalization over baselines while preserving editing reliability and specificity. We further address evaluation biases in existing benchmarks through knowledge-aware protocols that disentangle external dependencies. This work establishes new state-of-the-art performance on ripple effect while ensuring internal logical consistency after knowledge editing.

Code Structure

The core components are organized into the following modules:

  • rule_mining_neo4j/: Mines logical rules from knowledge graphs using Neo4j as storage. Requires importing Wikidata into Neo4j. Contains pre-mined rules in TSV format.

  • rule_process_apply/: Processes mined rules and applies them to datasets. customized_edit_rules.tsv contains processed rules. LRA_data_generate.py applies rules to datasets, generating logically generalized data like rule_process_apply/data/qwen2.5-1.5B-Instruct/augmented_edit_data.tsv.

  • RippleEdits/: Data and code from RippleEdits. build_benchmark_by*.py scripts implement the three variant dataset construction methods described in our paper.

  • easyeditor/ and hparams/: Code and parameter settings from EasyEdit.

  • edit_with_custom_eval.py: Performs knowledge editing with logical rules (ChainEdit).

  • edit_with_eval.py: Performs knowledge editing without logical rules (baseline).

  • data_analyse.py: Analyzes and statistics evaluation results.

Acknowledgments

This code is based on the EasyEdit framework. The dataset comes from RippleEdits, with data format referencing KnowEdit.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages