arXiv:2610.19970cs.SEOct 2026

Manuscript Offprint

arXiv:2610.19970

Temporal Adaptive Fine-Tuning for Code Comprehension

Alex Wolf, Pooja Rani, Harald C. Gall

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

1st1^{st} Alex Wolf ∗^{*} 2nd2^{nd} Pooja Rani ∗^{*} †^{\dagger} 3rd3^{rd} Harald C. Gall ∗^{*}

*Dept. of Informatics, University of Zurich, Switzerland

†Software Engineering Group, University of Mannheim, Germany

ORCID: 0000-0002-0964-2224, 0000-0001-5127-4042, 0000-0002-3874-5628

Abstract—Repository-level code comprehension question-answer (QA) supports developer reasoning over functionality, or usage distributed across a codebase. However, repository-specialized LLMs can become misaligned with the repository as code evolves. We study this challenge as temporal repository adaptation: maintaining code comprehension QA alignment as the repository evolves by acquiring new knowledge, suppressing obsolete, retaining still-valid, and preserving semantically neighboring knowledge. Existing retrieval, fine-tuning, and model-editing approaches address only parts of this temporal repository adaptation problem. We propose TAFT, a novel adaptation approach that treats repository transitions as supervision. TAFT derives temporally grounded code comprehension QA data from repository transitions, pairs newly valid with obsolete knowledge through preference optimization, and replays transition-conditioned retention examples to preserve still-valid knowledge. We evaluate TAFT on an augmented temporal SWE-bench dataset comprising 255,295 QA entries across ten temporal slices, comparing deferred (Baseline), per-slice retrained (Baseline-Batched), and variants with knowledge anchors along four dimensions: updated knowledge, obsolete-answer suppression, retention, and neighbor stability. TAFT consistently outperforms both the deferred and batched baselines, improving updated/suppressed knowledge accuracy on average by a relative increase of 18% and doubling retention accuracy over the baselines. Furthermore, TAFT improves neighbor accuracy to roughly 1.5 times that of the baselines. Under directly supplied knowledge anchors, TAFT-KANT further improves mean updated/suppressed, retention, and neighbor accuracy over TAFT, corresponding to relative improvements of 3.55%, 8.35%, and 13.00%, respectively. Overall, TAFT demonstrates its effectiveness across all evaluated areas, effectively enabling code comprehension QA alignment with repository evolution. Future work can extend TAFT beyond QA to other change-sensitive SE tasks such as migration, testing, debugging, and code review where models must satisfy various dimensions of temporal adaptation.

Index Terms—large language models, temporal adaptation, continuous fine-tuning, deep learning, repository-level, code comprehension, information-seeking

I. INTRODUCTION

Code comprehension underpins many software engineering (SE) activities, e.g., bug fixing, feature development, and maintenance [1], [2]. To comprehend code and change it, developers often form a working mental model of the code [3], [4], which requires answering various kinds of questions about its behavior, rationale, and usage [1], [2]. However, answering such questions requires knowledge scattered across repository artifacts (e.g., classes, files), making it a time-consuming, effort-intensive, and non-trivial task [1], [2].

Large Language Models (LLMs) support repository-level comprehension by answering questions that link local implementation details to broader code semantics [5], [6]. However, their repository knowledge is temporal: as software evolves through feature additions and refactoring, previously correct answers may become outdated, while other, semantically related knowledge remains valid. Figure 1 shows this with a signature code change to the Executor.map(): the answer to Q1 must be updated, while the answers to Q2 and Q3 should remain unchanged as they capture retained and neighboring knowledge. This makes temporal adaptation a multi-dimensional challenge, i.e., a model must (update) new information, suppress knowledge that was valid before a change but is now incorrect, retain knowledge that remains valid after the change, and preserve neighboring knowledge (adjacent code elements) that was not directly modified and should remain unaffected.

Existing SE approaches, including inference-time grounding and training-time adaptation, address this challenge only partially, each focusing on a single dimension and carrying its own limitations for code comprehension. Inference-time grounding methods including Retrieval Augmented Generation (RAG), long-context prompting, or agentic exploration focus solely on surfacing updated knowledge, but do not resolve parametric misalignment. Specifically, RAG can miss or conflict with evidence [7], [8], long-context prompting remains sensitive to input length and position [9], [10] and agentic exploration can be costly while simpler methods remain competitive [11], [12]. Similarly, training-time approaches are narrow: fine-tuning risks catastrophic forgetting [13], [14], while model-editing methods inject updated facts without accounting for suppressed knowledge [15]–[17]. Although such techniques have been explored for code completion and migration [18], [19], none jointly address the four dimensions, making them insufficient for repository-level comprehension question-answer (QA), a recurring and essential task that remains underexplored.

We formulate this gap as temporal repository adaptation and propose Temporal Adaptive Fine-Tuning (TAFT) to address it: given a stream of evolving repository states, TAFT incrementally adapts repository-specialized models across all four dimensions (update, suppress, retain, neighbors). TAFT derives temporally grounded code comprehension question-answer data from repository transitions, pairing updated with suppressed knowledge while replaying retained knowledge to preserve stable repository comprehension.

Figure

Fig. 1. Repository Transition where a Code Change to the Executor.map() Signature creates Different Temporal Adaptation Requirements.

In summary, the primary contributions of this paper are (replication material available [20]):

• A formalization of temporal repository adaptation for code comprehension question-answer (QA), capturing how code evolution affects four knowledge dimensions: updated, suppressed, retained, and neighboring.

• A code comprehension evolution dataset of 255,295 repository-knowledge QA entries supporting evolution-based inquiries and evaluation.

• Temporal Adaptive Fine-Tuning (TAFT), a novel approach that incrementally learns updated knowledge, rejects suppressed knowledge, and preserves retained knowledge.

The remainder of the paper is organized as follows: Section II describes the approach, Section III the experimental design, and Section IV the results. Section V discusses threats to validity, Section VI related work, and Section VII future work, before we conclude in Section VIII.

References (61)