Abstract
Recently, large language models (LLMs) have demonstrated remarkablecapabilities in a wide range of tasks. Typically, an LLM is pre-trained onlarge corpora and subsequently fine-tuned on task-specific datasets. However,during fine-tuning, LLMs may forget the knowledge acquired in the pre-trainingstage, leading to a decline in general capabilities. To address this issue, wepropose a new fine-tuning algorithm termed Momentum-Filtered Optimizer (MoFO).The key idea of MoFO is to iteratively select and update the model parameterswith the largest momentum magnitudes. Compared to full-parameter training, MoFOachieves similar fine-tuning performance while keeping parameters closer to thepre-trained model, thereby mitigating knowledge forgetting. Unlike mostexisting methods for forgetting mitigation, MoFO combines the following twoadvantages. First, MoFO does not require access to pre-training data. Thismakes MoFO particularly suitable for fine-tuning scenarios where pre-trainingdata is unavailable, such as fine-tuning checkpoint-only open-source LLMs.Second, MoFO does not alter the original loss function. This could avoidimpairing the model performance on the fine-tuning tasks. We validate MoFOthrough rigorous convergence analysis and extensive experiments, demonstratingits superiority over existing methods in mitigating forgetting and enhancingfine-tuning performance.