Dynamic Retriever for In-Context Knowledge Editing via Policy Optimization

Mahmud Wasif Nafee, Maiqi Jiang, Haipeng Chen, Yanfu Zhang
10/24/2025
cs.CL

Official code: mwnafee/DR-IKE (0 stars, MIT, last commit 2025-10-27).

Abstract

Large language models (LLMs) excel at factual recall yet still propagate stale or incorrect knowledge. In-context knowledge editing offers a gradient-free remedy suitable for black-box APIs, but current editors rely on static demonstration sets chosen by surface-level similarity, leading to two persistent obstacles: (i) a quantity-quality trade-off, and (ii) lack of adaptivity to task difficulty. We address these issues by dynamically selecting supporting demonstrations according to their utility for the edit. We propose Dynamic Retriever for In-Context Knowledge Editing (DR-IKE), a lightweight framework that (1) trains a BERT retriever with REINFORCE to rank demonstrations by editing reward, and (2) employs a learnable threshold to prune low-value examples, shortening the prompt when the edit is easy and expanding it when the task is hard. DR-IKE performs editing without modifying model weights, relying solely on forward passes for compatibility with black-box LLMs. On the COUNTERFACT benchmark, it improves edit success by up to 17.1%, reduces latency by 41.6%, and preserves accuracy on unrelated queries, demonstrating scalable and adaptive knowledge editing. The code is available at https://github.com/mwnafee/DR-IKE .

View on arXivView PDF

Code Implementations(1)

mwnafee/DR-IKEOfficial100%
MIT

Code and Resources for Dynamic Retriever For In Context Knowledge Editing Via Policy Optimization

00PythonOct 8, 202512 months agoMIT

Similar Papers

Cite this paper

@article{nafee2025dynamic,
  title  = {Dynamic Retriever for In-Context Knowledge Editing via Policy Optimization},
  author = {Mahmud Wasif Nafee and Maiqi Jiang and Haipeng Chen and Yanfu Zhang},
  year   = {2025},
  eprint = {2510.21059},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2510.21059v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2510.21059.svg)](https://codeofpaper.com/paper/2510.21059)

Discussion