Enhancing Continual Learning in Visual Question Answering with Modality-Aware Feature Distillation (2024)

Abstract: Continual learning focuses on incrementally training a model on a sequence of tasks with the aim of learning new tasks while minimizing performance drop on previous tasks. Existing approaches at the intersection of Continual Learning and Visual Question Answering (VQA) do not study how the multimodal nature of the input affects the learning dynamics of a model. In this paper, we demonstrate that each modality evolves at different rates across a continuum of tasks and that this behavior occurs in established encoder-only models as well as modern recipes for developing Vision & Language (VL) models. Motivated by this observation, we propose a modality-aware feature distillation (MAFED) approach which outperforms existing baselines across models of varying scale in three multimodal continual learning settings. Furthermore, we provide ablations showcasing that modality-aware distillation complements experience replay. Overall, our results emphasize the importance of addressing modality-specific dynamics to prevent forgetting in multimodal continual learning.

heading: 1 Introduction
text: Large Language Models (LLMs) (Touvron et al., 2023; Jiang et al., 2023) and Visual Language Models (VLMs) (Bai et al., 2023b; Liu et al., 2024), have achieved unprecedented performance and have become the go-to option for most NLP and Vision & Language (VL) tasks. However, once they have been trained, it is not straightforward how to update them to accommodate for novel concepts or concepts with reworked meanings. As a result, over time, the knowledge of these models may be obsolete or needs to be refined periodically to maintain their relevance. Consider two examples: 1) As of July 2023, Twitter has been re-branded to X with a new logo. 2) According to the Oxford English Dictionary (OED), as of March 2024, more than 1000 English words or phrases have been either
been revised or included as novel entries1. In these cases, models trained with data from a preceding period will inevitably show performance deterioration (Lazaridou et al., 2021). Commercialized LLMs circumvent this limitation (OpenAI, 2022; Gemini Team et al., 2023; Anthropic, 2024) with statements regarding the knowledge cutoff of these models. On the other hand, humans continuously update their knowledge and acquire new skills over time. Continual learning is a paradigm that aims to simulate this behavior, focusing on models that learn incrementally from a sequence of tasks with minimal catastrophic forgetting (McCloskey and Cohen, 1989; Ratcliff, 1990).
Continual learning has started being explored more widely in VL settings (Greco et al., 2019; Srinivasan et al., 2022; Nikandrou et al., 2022;
1OED March 2024 update lists entries appearing for the first time, or entries with updated meanings.
73
Zhang et al., 2023; Lei et al., 2023; Cui et al., 2024). However, existing approaches do not explicitly account for the dissimilarities in the representation space of multimodal inputs and their effect on the learning dynamics, which we argue is necessary for effective continual learning of VL tasks. Previous work on the optimization dynamics of multimodal learning has demonstrated that different modalities are learned at different speeds (Wang et al., 2020; Wu et al., 2022). Using encoder and decoder-only VLMs, we empirically showcase a similar forgetting discrepancy (Section 4.1), which indicates that representations from each modality evolve at different rates across a sequence of tasks.
Motivated by this observation, we propose MAFED, a Modality-Aware FEature Distillation approach summarized in Figure 1. We explore different strategies for weighting the distillation losses derived from the tokens of each modality, using either fixed balanced weights or adaptive weights derived from the loss gradients computed with respect to the inputs. We combine both variants with experience replay and show promising results across all VLM families compared to established continual learning methods. Additionally, we conduct experiments with decoder-only VLMs ranging from 100M to 1B parameters, showing that although scale alleviates forgetting, certain settings remain challenging. Our ablations comparing experience replay and feature distillation approach showcase that these methods are complementary and yield greater performance when combined. Overall, our results emphasize the need to address modalityspecific dynamics to effectively mitigate forgetting in multimodal continual learning.

heading: 2 Related Work

heading: 2.1 Continual Learning
text: Continual Learning Approaches Continual learning approaches can be categorized as regularization, replay, and architecture-based (Delange et al., 2021). Regularization-based approaches introduce auxiliary losses that aim to constrain the model weights (Kirkpatrick et al., 2017; Zenke et al., 2017; Aljundi et al., 2018), outputs (Li and Hoiem, 2018; Rebuffi et al., 2017), or internal representations (Hou et al., 2019). Replay-based approaches rely on storing (Chaudhry et al., 2019; Buzzega et al., 2020; Bagus and Gepperth, 2021) or generating samples (Van de Ven and Tolias, 2018; Sun et al., 2019) from past tasks so that they can be
sampled along with new samples during training. Finally, architecture-based approaches introduce task-specific parameters, either by masking the model parameters (Yoon et al., 2020; Serrà et al., 2018) or adding new ones for each task (Fernando et al., 2017; Madotto et al., 2021).
Most recent work tends to combine techniques from multiple categories in order to maximize performance. Similarly, our work utilizes replay and regularization through feature distillation. Distillation has been used in various continual learning approaches. Some focus on knowledge distillation on the output level, using the logits (Li and Hoiem, 2018) or pseudo-labels from a past checkpoint (Wang et al., 2022; Karim et al., 2022). Other work applies distillation on the internal model representations (Dhar et al., 2019; Douillard et al., 2020; Kang et al., 2022). MAFED expands this line of work by introducing different weighting schemes to balance the distillation loss from visual and textual representations.
VL Continual Learning Previous work has studied varying instantiations of VL continual learning problems, including image captioning (Del Chiaro et al., 2020; Nguyen et al., 2019), compositional phrase generalization (Jin et al., 2020), and taskincremental learning (Srinivasan et al., 2022). Within VQA, prior work has investigated continual learning based on question types (Greco et al., 2019), across varying domains (Zhang et al., 2022; Lao et al., 2023), and from a compositionality perspective (Zhang et al., 2023). Lei et al. (2023); Nikandrou et al. (2022) further study how VQA models evolve in different settings, including novel visual scenes or different question types. However, these works have not investigated the effect of modality-aware methods with the exception of Qian et al. (2023) that focus on multimodal prompt learning for vision, text and fusion modules. In contrast, feature distillation does not assume separate modality-specific and multimodal parameters and can be applied to more varied VLM architectures.

heading: 2.2 VLMs
text: Progress in representation learning has led to models that achieve impressive performance across multimodal benchmarks (Goyal et al., 2017; Hudson and Manning, 2019; Li et al., 2023). Early approaches relied on complicated architectures (Tan and Bansal, 2019; Lu et al., 2019), and multiple learning objectives (Chen et al., 2020; Li et al.,
2021; Jia et al., 2021). More recently, given the rapid development of increasingly capable LLMs (Touvron et al., 2023; Jiang et al., 2023; Bai et al., 2023a), these approaches have been superseded by a new paradigm where representations from visual experts (Radford et al., 2021; Oquab et al., 2024) are treated as input tokens for the LLM. This shift has led the development of modern VLMs (Liu et al., 2024; Dai et al., 2024; Laurençon et al., 2024a) that are based on the same underlying principles with deviations regarding the choice of the experts, or how the patch tokens are integrated into the language model. Our experiments demonstrate the effectiveness of our approach in both encoder-only (Chen et al., 2020; Kim et al., 2021) as well as decoder-only models.

heading: 3 Preliminaries

heading: 3.1 Data
text: We leverage an existing evaluation suite for Continual Learning in VQA (Nikandrou et al., 2022) comprised of three settings based on the visual and the language input. In particular, each of these settings consists of five tasks and is designed to test the model’s performance on learning varying concepts or question types. Figure 2 illustrates exemplary images and questions from different tasks in each of the settings. Below, we provide a brief summary for each of these settings.
Diverse Content corresponds to a real-world use case as well as a common standard procedure within continual learning (Lomonaco and Maltoni, 2017; Rebuffi et al., 2017; Zenke et al., 2017; Lin et al., 2021), where a model is trained on new sets
of concepts progressively that do not necessarily comply to a taxonomy. Each task in this setting covers 10 distinct object categories from the COCO dateset (Lin et al., 2014).
Taxonomy Content In this setting, each task consists of questions regarding objects based on the same super-category. This setting contains questions from the following categories: Animals, Food, Interior, Sports, and Transport, and simulates a more progressive approach, where a model learns about a fixed (and similar) pool of concepts before being applied to a different domain. Importantly, we note that in both Diverse Content and Taxonomy Content, images containing objects shared between tasks are discarded to create clean task splits, preventing contamination between them. In total, there are 181K train, 45K validation, and 110K test samples for both settings.
Question Types The final setting resembles a scenario where the model learns to answer different categories of questions. In this setting, the model is tasked with learning from a sequence of five tasks: Count, Color, Scene-level, Subcategory, and Action recognition. Question Types have a total of 140K train, 35K validation, and 84K test samples.

heading: 3.2 Models
text: Throughout our experiments, we use two families of models, including encoder- and decoder-only pretrained models. Specifically, we use the encoderonly models, UNITER-base (Chen et al., 2020) and ViLT-base (Kim et al., 2021), that differ in terms of how the visual input is encoded. UNITER uses region features extracted from the Faster R-CNN
object detector (Anderson et al., 2018). On the other hand, ViLT is a patch-based model that does not use an additional vision encoder.
However, recent trends in the development of VLMs have moved towards decoder-only architectures that combine an expert vision encoder with an LLM using a connector module that learns a mapping between them (Liu et al., 2024). We employ a similar recipe to combine EVA02 (Fang et al., 2023) as the visual encoder and Pythia (Biderman et al., 2023) as our LLM. Regarding the connection module, we follow the LLaVA-1.5 (Liu et al., 2023) approach with a two-layer MLP that matches the dimensionality of the visual and the language embeddings. We refer to this model as VL-Pythia.
We refrain from using other existing VLMs for two reasons. First, we aim to match the parameters and pretraining data between the encoder-only and the generative models. Pythia models provide a collection of checkpoints covering a wide range of sizes that have been pretrained following a state-of-art transformer recipe (Su et al., 2024; Dao et al., 2022). For a controlled comparison with encoder-only models, we train VL-Pythia us-
ing the same data used to train UNITER and ViLT (see Appendix A.1 for additional details regarding the pretraining of the model). In particular, we use the checkpoints with 160M, 410M, and 1B parameters. The smaller model is on par with the encoder-only ones, while the larger models allow us to explore the role of model capacity. Secondly, existing VLMs (Liu et al., 2024; Dai et al., 2024; Bai et al., 2023a; Laurençon et al., 2024a,b) are typically instruction-tuned on datasets that include VQA-v2 (Goyal et al., 2017) on which the continual learning settings are based. This overlap is undesirable since we want to prevent any form of data contamination between tasks.
During continual learning, we keep the vision encoders of UNITER and VL-Pythia frozen. In encoder-only models, VQA is treated as a classification task. The classification (CLS) token is passed to a classification head that gets expanded with the new answers from each task. On the contrary, VL-Pythia is fine-tuned to generate answers autoregressively. In our experiments, we follow a greedy decoding strategy during inference.

heading: 4 Method

heading: 4.1 Motivation
text: In this work, we argue that modality-specific learning dynamics, and more specifically, the different speeds at which each modality is learned (Wu et al., 2022) or forgotten, should be accounted for in multimodal continual learning settings. We demonstrate this behavior by measuring the similarities of the question Q and image V representations from sequential model checkpoints using Centered Kernel Alignment (CKA) (Kornblith et al., 2019). In particular, we extract text Qt and image Vt representations for data of the first task after training on the first t = 1 and each subsequent task t = 2 · · ·T , and we compute the CKA similarity across time. Finally, we visualize the ratio Rt of the text over image similarities:
Rt = CKA(Q1, Qt)
CKA(V1, Vt) ∀t = 2 · · ·T (1)
Figure 3 shows the Text-to-Image CKA ratio per layer. We observe that there are differences in how the modalities evolve within the models and across settings. First, we note that the ratio is greater or equal to one in all cases, meaning that visual tokens exhibit decreasing similarity throughout the learning process. In UNITER, the ratio remains close to one for earlier layers and increases only for the last three layers. ViLT and Pythia exhibit a different trend, where the ratio peaks for intermediate layers. As a result, we hypothesize that incorporating the variability of each modality in a regularization technique can benefit continual learning strategies. Due to parameter sharing between the two modalities, we materialize this in a modality-aware feature distillation strategy, which we elaborate on below.

heading: 4.2 Modality-Aware Feature Distillation
text: Feature Distillation (FD) is an established continual learning technique (Hou et al., 2019; Douillard et al., 2020; Kang et al., 2022) that adds a regularization loss term to prevent the drift of model representations. Given two model checkpoints ft−1 and ft from consecutive tasks, we extract representations H from an intermediate layer and compute the feature distillation loss li using the representations of each token hi:
LFD = 1
N
N∑
i=1
li = 1
N
N∑
i=1
∥ hi,t − hi,t−1 ∥22 (2)
Assuming an example has Q text tokens and V visual tokens, we can rewrite Equation (2) in terms of the average loss contributed by the language and the vision tokens, LFD,Q and LFD,V respectively:
LFD,weighted = α · LFD,Q + (1− α) · LFD,V (3)
In the simplest case, α is proportional to the number of tokens available from each input modality. In practice, this might be suboptimal since it depends on the input tokenization strategy. In fact, across the examined settings, the average tokenized inputs have approximately 9 question tokens and 33 or 199 visual tokens for region and patch-based image features, respectively. Consequently, visual tokens will dominate the distillation loss of Equation (3) potentially leading to inferior performance.
Therefore, we experiment with two modifications: i) MAFED-B which balances the losses from each modality by fixing α to 0.5, and ii) MAFED-A which uses an adaptive weighting approach based on modality importance inspired by Kang et al. (2022). Modality importances IQ and IV are estimated using the gradient of the VQA classification loss2, with respect to the intermediate model representations Hm from each modality m. IQ and IV are updated at the beginning of each training task using the available memory data Mt as follows:
Im = E(x,y)∼Mt [ ∥ ∇HmLcls(ft(x), y) ∥2F ] (4)
where ∥ · ∥ corresponds to the Frobenius norm. Finally, the weight α is computed by normalizing the importance of the question tokens:
α = IQ
IQ + IV (5)
We apply feature distillation to all layers except the last since only the representation of CLS token in encoder-only and the final question token in decoder-only models is propagated to the model output’s head. Furthermore, in Section 4.1, we showcased that the representations of deeper layers are affected more during continual learning. Therefore, we introduce a discount factor wd that is used to weigh the contribution of the loss from each layer proportionally to its distance d from the model’s head:
wd = γd
∑D d=0 γ d (6)
2Or the language model head in the case of Pythia.
where γ ∈ (0, 1] is a hyperparameter such that lower γ values assign more weight to deeper layers, and γ = 1 weighs the losses from all layers equally. Unless stated otherwise, we combine feature distillation with replay since it requires no computational overhead and helps mitigate the miscalibration of the output layer, which can negatively impact performance on past tasks (Wu et al., 2019).

heading: 5 Experiments

heading: 5.1 Baselines
text: We compare our methods against naive Fine Tuning (FT), where a model is trained sequentially on each task. Our continual learning baselines include Elastic Weight Consolidation (EWC) (Kirkpatrick et al., 2017) and Experience Replay (ER) (Chaudhry et al., 2019), which have been shown to perform competitively. Finally, we report the upper bound performance of Multitask learning, where the model is trained on all tasks simultaneously. Note that this is the de facto standard for instructiontuning in VLMs (Dai et al., 2024; Liu et al., 2023).

heading: 5.2 Evaluation Metrics
text: We measure the performance of a model using three metrics. First, we report the macro-average accuracy at the end of a training sequence, A = 1 T ∑T i=1AT,i, where AT,i depicts the performance of the model on the data from task i after training on final task T . Additionally, we report the Semantic Backward Transfer (SBWT) (Nikandrou et al., 2022), which captures the impact of catastrophic forgetting, weighted by the semantic similarity of the prediction and the target:
SBWT = 1 T − 1 T−1∑
i=1
ST,i (7)
where ST,i is the average weighted accuracy difference for task i.

heading: 5.3 Implementation Details
text: We train all models using the Adam optimizer (Kingma and Ba, 2014) and a learning rate schedule that follows linear decay after a warmup for 10% of the training steps. The maximum learning rate is optimized through grid search separately for each setting based on the performance of the finetuning method. For UNITER and ViLT, we set the number of epochs per task to 60 with a patience of 5. We found that VL-Pythia models reach their peak accuracy for fewer updates, possibly because they do not use a randomly initialized classification head. As a result, we set the maximum number of epochs to 15. For all replay and feature distillation runs, we keep a memory of 1000 randomly selected samples per task, ensuring that the same samples are stored across methods for the same task order. Further details about the selected hyperparameters are listed in Appendix A.2.

heading: 5.4 Results

heading: 5.4.1 Encoder-only Models
text: Table 1 reports the results across the three settings using the encoder-only models UNITER and ViLT. Adding the feature distillation loss improves upon the ER baseline in all settings. Although the benefits with UNITER are moderate, as ER already achieves low forgetting, when using ViLT,
FD offers substantial accuracy gains of up to 2.6 in Question Types. Comparing the feature distillation variants, modality-aware weighting (MAFED-A or MAFED-B) consistently boosts performance. For UNITER and ViLT in Question Types, equally balancing the modality losses with MAFED-B shows the best performance. In the image-based settings with ViLT, adaptive weighting performs better. Given the similarity ratios shown in Figure 3, these results suggest that MAFED-B is more effective when the relative change of text and vision representation is small, while MAFED-A is more appropriate in cases of larger discrepancies.

heading: 5.4.2 Scaling to larger decoder-only VLMs
text: As decoder-only architectures have become more widely used, we also experiment with three model sizes of VL-Pythia (160M, 410M, 1B parameters). In our initial results shown in Table 3, we find that larger models exhibit no forgetting in the image-based settings of Diverse and Taxonomy Content. As a result, we focus on more challenging Question Types setting.
Table 2 provides the results for different continual learning strategies using the VL-Pythia variants. We observe that scaling leads to higher final accuracy and less catastrophic forgetting similar to previous work (Mirzadeh et al., 2022; Ramasesh et al., 2022). Nevertheless, even the largest explored model has a gap of almost 8% between naive finetuning and multitask learning. Compared to experience replay, we find that the benefit of EWC
diminishes for larger models. As in encoder-only models, the inclusion of feature distillation further improves performance, and modality-aware weighting of the distillation losses is beneficial in all cases. For VL-Pythia, MAFED-A leads to the best performance, improving the accuracy on average by +2.6 compared to ER and +0.87 compared to FD. As mentioned in Section 5.4.1, we hypothesize that adaptive modality weighting can be particularly effective where the text and visual representations change more unequally. Overall, our results indicate that stabilizing the representations from vision and language tokens separately can improve multimodal continual learning.

heading: 6 Analysis

heading: 6.1 Distillation without Replay
text: In the previous section, we applied feature distillation in conjunction with experience replay. Table 4 shows the performance when applying feature distillation with and without experience replay on VL-Pythia (1B) for one task order on the Question Types setting. Feature distillation improves the model performance, while standalone modalityaware methods are competitive with experience replay. The combination of the two approaches yields the greatest performance with no additional
cost over standalone feature distillation. Both methods require maintaining a memory of past samples that are passed through the current model. Therefore, applying replay puts no additional overhead on training time and memory.

heading: 6.2 Distillation Layer Ablation
text: Next, we explore the effectiveness of applying modality-aware feature distillation from a single layer, as well as a subset of layers. Figure 4 illustrates the performance of VL-Pythia (1B) after applying MAFED-B and MAFED-A every three layers. As expected, applying both methods on a deeper layer of the model but also distilling from all previous layers yields greater performance. However, the performance of all four variants does not increase monotonically with the layer depth. More specifically, we observe that distilling from layer 6 leads to performance degradation. This behavior correlates with the results in Figure 3, where the per-modality similarities diverge the most at layer 6 and gradually align throughout the deeper layers of the model.

heading: 6.3 Modality Weights in MAFED-A
text: Figure 5 shows the weight α placed on the distillation loss of the language tokens using the MAFEDA method. In all models, MAFED-A assigns more weight to language tokens. Interestingly, we observe that in encoder-only models, the language weight progressively increases up to layer 8 and then drops. On the other hand, in VL-Pythia (1B), more than 90% of the weight is assigned to language tokens for all layers. We hypothesize that this is because the model is causal, and the last token before the answer is a text token.

heading: 7 Conclusion
text: In this paper, we argued that applying approaches that were developed with unimodal models in mind is suboptimal for continual learning in VQA since this ignores modality-specific learning dynamics. We empirically showcased that the visual and the textual representations evolve at different rates – a phenomenon that occurs in both encoder-only and decoder-only VLMs. Given this observation, we proposed two modality-aware feature distillation approaches that equally weigh the distillation loss from each modality or adaptively estimate the importance of a modality based on the gradients with respect to the inputs. We believe this is a promising direction towards closing the gap with multitask training in multimodal continual learning.

heading: 7.1 Limitations & Future Work
text: Despite the promising results, our method has certain limitations. First, distillation is more computationally expensive than replay, as it requires accessing the representations from the previous model. However, compared to established distillation methods, MAFED-B improves performance with no overhead, while MAFED-A requires computing importance weights, which are only updated between tasks. Furthermore, our work does not investigate the potential effectiveness of architecturebased approaches, which could offer greater control over the learning of each modality through novel parameter-isolation approaches. Finally, we show that larger models exhibit less or even no forgetting depending on the setting. Future work should explore whether increasing the model size or the VL pretraining data (Ostapenko et al., 2022) can further decrease forgetting in VQA settings.

heading: Acknowledgements
text: This work was supported by the Edinburgh International Data Facility (EIDF) and the Data-Driven Innovation Programme at the University of Edinburgh.

heading: A Experiments
text: A.1 Pretraining VL-Pythia We pretrain all VL-Pythia models following the LLaVA-1.5 recipe (Liu et al., 2023). The only difference is that we skip the first stage for multimodal alignment as recent work (Karamcheti et al., 2024) has shown that the two-stage training can be redundant and the same performance can achieved when omitting the first stage of training. Throughout VL pretraining, the vision encoder remains frozen, while the LLM and connector parameters are trained using the Adam optimizer (Kingma and Ba, 2014) with a batch size of 256 and a learning rate of 1e-3. For all models, we used the same data to train UNITER and ViLT - COCO (Lin et al., 2014), SBU captions (Ordonez et al., 2011), Visual Genome captions (Krishna et al., 2017) and Conceptual Captions 3M (Sharma et al., 2018). We perform one epoch of pretraining and keep the final checkpoint.
We tune the hyperparameters using grid search based on the validation accuracy of a single task order. For VL-Pythia variants, we use the same hyperparameters for all model sizes, as we find them to perform reasonably well. For UNITER and ViLT, we keep the batch size, learning rate (LR), and EWC loss weight λ reported in prior work (Nikandrou et al., 2022). For the remaining values, we perform the following grid search: lr ∈ {1e − 5, 5.e − 5, 8e − 5, 1e − 4}, EWC λ ∈ {500, 1K, 5K, 10K}, FD discount factor γ ∈ [0.3, 1.0] with a step of 0.1.

heading: Future Work
text: Future work should explore whether increasing the model size or the VL pretraining data (Ostapenko et al. , 2022) can further decrease forgetting in VQA settings