LoKI: Low-damage Knowledge Implanting of Large Language Models

Runyu Wang, Peng Ping, Zhengyu Guo, Xiaoye Zhang, Quan Shi, Liting Zhou, Tianbo Ji

TL;DR

Fine-tuning Large Language Models (LLMs) for specific tasks often overwrites their core pretrained knowledge—a phenomenon known as catastrophic forgetting. LoKI (Low-damage Knowledge Implanting) solves this by identifying low-contribution weights within the model's Feed-Forward Networks (FFNs) and safely repurposing them for new tasks. This approach achieves state-of-the-art task adaptation while keeping the model's foundational capabilities almost entirely intact.

What Problem Does This Paper Address?

When you fine-tune a pretrained LLM on a downstream task (like function-calling or specialized retrieval), the optimization process indiscriminately updates weights across the entire architecture. Unfortunately, this often disrupts the delicate internal "memory traces" the model acquired during pretraining. The model gains a new skill but loses its general-purpose reasoning, world knowledge, or instruction-following capabilities.

While parameter-efficient fine-tuning (PEFT) methods like LoRA or DoRA reduce the number of trainable parameters, they still update weights blindly without considering where or how knowledge is structurally organized inside the transformer. The authors of LoKI bridge this gap by leveraging insights from mechanistic interpretability to fine-tune models with surgical precision.

Methods

LoKI introduces a staged fine-tuning framework that treats Feed-Forward Networks (FFNs) as key-value memories, focusing specifically on the down-projection matrices ($W_{down}$) where conceptual "values" reside.

Figure 1: Schematic illustration of the staged fine-tuning process in LoKI.

The framework operates in three distinct phases:

  1. Analysing (Knowledge Vector Attribution - KVA): The authors develop KVA, a gradient-based attribution technique rooted in Integrated Gradients. By running the model through a diverse dataset, KVA quantifies exactly how much each individual neuron (knowledge vector) contributes to general-purpose capabilities.
  2. Selecting (Layer-Balanced Strategy): Instead of simply picking the lowest-contributing neurons globally, LoKI enforces a strict, equal quota of trainable parameters across every single layer. This ensures that the hierarchical structure of the transformer isn't warped or overridden during training.
  3. Implanting: The down-projection matrix is split into active and frozen subsets based on the selection. Only the low-contribution, active weights are updated during fine-tuning. Crucially, this method can also be combined with LoRA (termed LoKI*) to compress the parameter footprint even further.

Datasets

  • General Knowledge Evaluation (KVA Phase): The MMLU (Massive Multitask Language Understanding) benchmark, spanning 57 subjects, was used to score the general-purpose importance of knowledge vectors.
  • Downstream Fine-Tuning Tasks:
  • ToolACE Function-Calling Dataset: 26,507 distinct APIs used to train Llama3.1-8B-Instruct.
  • LB Reranker Dataset: 2.28 million multilingual query-text pairs used to train Qwen2.5-0.5B-Instruct.
  • Catastrophic Forgetting Benchmarks: Models were evaluated across six foundational benchmarks: TriviaQA (world knowledge), GSM8K (math), HellaSwag and WinoGrande (commonsense), HumanEval (coding), and IFEval (instruction following).

Key Insights and Ideas

  • The Co-location Phenomenon: Using KVA, the authors discovered a striking structural bias: neurons with globally high contributions and those with globally low contributions tend to cluster densely within the exact same layers. Knowledge distribution inside LLMs is highly concentrated, not randomly scattered.
  • Layer Balance is Non-Negotiable: Naive selection strategies that only update a few specific layers heavily degrade performance. Because transformer layers progressively refine knowledge from surface-level patterns to deep semantics, modifying weights in an unbalanced way can completely block or "override" downstream information flow.

Key Results

LoKI achieves an unprecedented balance between learning new tasks and remembering old ones.

  • Mitigating Forgetting: On the ToolACE dataset, standard LoRA fine-tuning caused an average performance degradation of 16.11% across the six general benchmarks. DoRA dropped by 4.92%. LoKI (at $q=10$), by contrast, limited general capability degradation to a mere 0.34%.
  • Task Performance: On the Berkeley Function Calling Leaderboard (BFCL) V3, LoKI ($q=30$) achieved the highest overall accuracy (58.93%), outperforming both standard LoRA and DoRA.
Table 1: Performance comparison on the Berkeley Function Calling Leaderboard V3. ToolACE refers to the official model trained using LoRA. r denotes the rank. Models marked with † indicate that the corresponding performance metrics are sourced directly from the official BFCL documentation. An asterisk (*) denotes models where LoRA was applied during training. Bold represents the top performance score in each column; underline represents the runner-up.
  • LoRA Synergy: When combining LoRA with LoKI (LoKI), the number of trainable parameters plummeted by 97.16% compared to standard LoKI, yet it still fiercely resisted catastrophic forgetting (only 1.26%* degradation).

Limitations and Future Work

Despite its strong performance, LoKI relies on a hyperparameter $q$ to determine the percentage of trainable nodes to select. The authors note that the optimal value for $q$ varies depending on the model and task, indicating a need for a more robust, adaptive quota allocation mechanism. Additionally, while the KVA analysis is a one-time cost per model, optimizing its computational overhead and exploring how LoKI interacts with different LoRA rank settings remain open avenues for future research.

Summary updated

Abstract

Fine-tuning adapts pretrained models for specific tasks but poses the risk of catastrophic forgetting (CF), where critical knowledge from pretraining is overwritten. To address the issue of CF in a general-purpose framework, we propose Low-damage Knowledge Implanting (LoKI), a parameter-efficient fine-tuning (PEFT) technique that utilizes recent mechanistic understanding of how knowledge is stored in transformer architectures. We compare LoKI against state-of-the-art PEFT methods in two real-world fine-tuning scenarios. The results show that LoKI demonstrates significantly better preservation of general capabilities. At the same time, its task-specific performance is comparable to or even surpasses that of full parameter fine-tuning and these PEFT methods across various model architectures. Our work bridges the mechanistic insights of LLMs' knowledge storage with practical fine-tuning objectives, enabling an effective balance between task-specific adaptation and the retention of general-purpose capabilities.
BibTeX
@inproceedings{wang2026loki,
  author = {Runyu Wang and Peng Ping and Zhengyu Guo and Xiaoye Zhang and Quan Shi and Liting Zhou and Tianbo Ji},
  title = {{LoKI: Low-damage Knowledge Implanting of Large Language Models}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2026},
  doi = {10.1609/aaai.v40i39.40651},
}
Figure