본문 바로가기

딥러닝/Paper review

[논문리뷰] Time is Encoded in the Weights of Finetuned Language Models

 

Abstract

  • 언어 모델을 새로운 시간 기간에 맞추기 위한 간단한 도구인 시간 벡터를 제시
  • 시간 벡터: 언어 모델을 특정 시간(예: 연도 또는 월)의 데이터로 세세하게 조정한 후 원래 사전 훈련된 모델의 가중치를 뺀 것
  • 실험 결과에 따르면, 이 벡터는 해당 시간 기간의 텍스트에서 성능을 향상시키는 가중치 공간에서의 이동 방향을 지정
  • 인접한 시간 기간에 특화된 시간 벡터는 매니폴드 내에서 서로 더 가까이 위치
  • 이 구조를 활용하여 시간 벡터 사이를 보간하여 어떠한 추가 훈련 없이 중간 및 미래 시간 기간에 더 나은 성능을 발휘하는 새로운 모델을 유도할 수 있음
  • 다양한 작업, 도메인, 모델 크기 및 시간 척도에서 결과의 일관성을 입증
  • 결과적으로, 이 연구는 시간이 세세하게 조정된 모델의 가중치 공간에 인코딩되어 있음을 시사

1. Introduction

  • 배경
    • Temporal variation : 언어의 기본적인 성격
    • train 과 test 데이터의 시간적 편차가 큰 성능 저하를 일으킴
    • 모델을 특정 시간 기간으로 customizing 하는 기술의 필요성 → 어려움 ( 다수의 시간 scales, target time 시기의 data가 불가능할 가능성)
    • 최신 연구 - neural network를 통한 수정 (fine-tuned model의 파라미터 사이 closed-form 보간을 통해)
  • 제안
    • weight-space interpolation → 저렴하게 시간에 따른 언어 모델 수정 가능
    • time vector : simple tool to customize language models to new time periodsFigure 1: We present time vectors, a simple tool to customize language models to new time periods.
      • Time vector structure : Time vectors : 시간 기간 i의 텍스트에서 성능을 향상시키는 가중치 공간에서의 이동 방향을 지정 계산 : by subtracting the pretrained weights (θpre; left panel) from those finetuned to a target time period (θi).
      • Generalizing to middle times :
      • can customize model behavior to new time periods (e.g., intervening months or years) by interpolating between time vectors and adding the result to the pretrained model (middle panel)
      • Generalizing to future times
      • can also generalize to a future time period j with analogy arithmetic (right panel). This involves combining a task-specific time vector with analogous time vectors derived from finetuned language models (τ LM ).
    • finetune a pre-trained language model on text from a single time period, and then subtract the pretrained weights → represent a direction of movement in weight space that improves performance on text from the target time period

분석

  • datasets for language modeling, classification, and summarization
  • years or months that are closer together in time yield time vectors that are also closer together in weight space.
  • temporal degradation in yearly and monthly settings is strongly correlated with the angles between time vectors

효과

  • We use this structure of time vectors to induce models that generalize better to data from new time periods.
  • By interpolating between two time vectors, we discover vectors that, when applied to the pre- trained model, improve performance on intervening months or years.
  • The structure can also be used to generalize task-specific models across time periods with analogous time vectors specialized to unlabeled data.
  • Our results show that temporal variation is to some extent encoded in the weight space of fine- tuned models, and that weight interpolation can help customize language models to new time periods.

2. Data and Finetuning

2.1 Datasets

1) Language Modeling

We create two new time specific language modeling datasets from unlabeled text in news and Twitter domains. we measure perplexity of the model on the test set.

  • WMT Language Modeling
    • the English subset of the WMT news dataset (2012-2021)WMT 뉴스 데이터 세트는 일반적으로 다양한 소스의 뉴스 기사로 구성되며 다양한 언어에 걸쳐 문장별로 정렬됩니다. 이러한 기사는 평판이 좋은 통신사로부터 수집되는 경우가 많으며 광범위한 주제와 영역을 다루고 있습니다. 데이터 세트에는 영어-프랑스어, 영어-독일어, 영어-스페인어 등과 같은 여러 언어 쌍 간의 번역이 포함되어 있습니다.
    • WMT(Workshop on Machine Translation) 뉴스 데이터 세트는 기계 번역 연구 및 평가에 일반적으로 사용되는 병렬 말뭉치 모음입니다. 기계 번역 시스템을 벤치마킹하고 서로 다른 언어 간 텍스트 번역 성능을 평가하는 데 자주 사용됩니다.
    • 2012 - 2016 , train/test data
    • missing WMT train and test splits for August 2012 and May 2016
  • Twitter Language Modeling
    • each year in the Internet Archive Twitter Stream Grab일반적으로, 트위터 스트림 데이터는 트위터에서 생성되는 실시간 트윗 데이터를 의미하며, 이 데이터는 트위터 사용자들의 트윗, 멘션, 리트윗 등의 활동을 포함합니다. Internet Archive Twitter Stream Grab을 사용하여 이러한 실시간 데이터를 수집하고 저장함으로써 연구나 분석을 위한 대규모 트위터 데이터셋을 구축할 수 있습니다.
    • 따라서, Internet Archive Twitter Stream Grab은 트위터 스트림 데이터를 수집하는 도구로, 연구나 분석을 위해 트위터에서 생성되는 다양한 데이터를 활용할 수 있도록 도와줍니다.
    • Internet Archive Twitter Stream Grab은 인터넷 아카이브에서 제공하는 트위터 스트림 데이터 수집 도구입니다. 이 도구를 사용하면 트위터에서 생성되는 실시간 스트림 데이터를 수집하고 저장할 수 있습니다.
    • from 2015–2020
    • use this dataset to study the domain-specificity of time vectors in §4.4

Bloom filter 로 the overlap between yearly train and test splits in both tasks 측정 결과 각 2%, 0.1%보다 적음

 

2) Downstream Tasks

"downstream tasks"는 기계 학습 또는 자연어 처리에서 사용되는 용어로, 주어진 모델이 특정 작업을 수행하는 데 어떻게 활용되는지를 나타냅니다. 일반적으로 이 용어는 사전 훈련된 모델(예: 언어 모델)을 특정 작업에 맞게 세부 조정(finetuning)하여 해당 작업을 수행하는 데 사용되는 경우에 사용됩니다.

예를 들어, 언어 모델을 사전 훈련한 후 특정 텍스트 분류 작업(예: 감성 분석)에 적용하는 경우, 해당 텍스트 분류 작업은 "downstream task"로 간주됩니다. 이러한 downstream tasks는 모델이 실제로 사용되는 환경에서의 작업을 의미하며, 모델의 성능을 평가하고 개선하는 데 중요한 역할을 합니다.

We measure each model’s performance on the test set in ROUGE-L for NewsSum and macro F1 for PoliAff.

  • NewsSum
    • news summarization task.
    • uniformly sized splits for each year from 2012 to 2016. ( 2012년부터 2016년까지의 WMT 데이터의 각 연도를 독립적으로 처리하고, 이를 동일한 크기의 데이터 구간으로 나누어 사용)
  • PoliAff
    • We use the Political Affiliation task from Luu et al. (2022) (텍스트가 어떤 정치적 성향인지 분류)
    • uniformly sized datasets for each year from 2015 to 2020.

2.2 Finetuning

  • pretrained T5
    • T5 모델은 다양한 크기와 구조로 제공되며, 사전 훈련된 모델을 활용하여 다양한 자연어 처리 작업에 대해 미세 조정(finetuning)할 수 있습니다. T5는 텍스트 입력을 다양한 형태의 텍스트 출력으로 변환하는 능력을 갖추고 있어, 번역, 요약, 질문 응답, 문장 생성 등 다양한 작업에 적용할 수 있습니다.
    • 따라서, pretrained T5는 Text-to-Text Transformer 모델로, 다양한 자연어 처리 작업에 활용되며, 사전 훈련된 모델을 미세 조정하여 특정 작업에 대해 성능을 향상시킬 수 있는 강력한 언어 모델입니다.
    • Pretrained T5는 Colin Raffel 등이 개발한 Text-to-Text Transformer 모델입니다. T5는 "Text-to-Text Transfer Transformer"의 약자로, 입력과 출력을 모두 텍스트로 처리하는 혁신적인 접근 방식을 채택한 모델입니다. T5는 다양한 자연어 처리 작업을 하나의 일관된 형식으로 표현할 수 있도록 설계되었으며, 사전 훈련된 언어 모델로 널리 사용되고 있습니다.
  • finetune T5- small, T5-large, and T5-3b on each of our time- stratified datasets.
  • LM adaptation
    • LM adaptation은 주로 다음과 같은 상황에서 활용됩니다.
      1. 새로운 시간대에 대한 언어 모델의 성능 향상: 예를 들어, 과거 데이터로 사전 훈련된 언어 모델을 최신 데이터에 맞게 조정하여 성능을 향상시키는 작업.
        1. 특정 도메인에 대한 언어 모델의 적응: 특정 분야(의학, 법률, 금융 등)에 특화된 언어 모델을 만들기 위해 해당 도메인의 데이터로 언어 모델을 조정하는 작업.
        2. 데이터의 시간적 변화에 대한 대응: 언어 모델을 주기적으로 업데이트하여 최신 데이터에 대응하거나 변화하는 언어 사용 양식에 대응하는 작업.
      LM adaptation을 통해 언어 모델을 특정 시간대나 도메인에 더 적합하게 조정함으로써 모델의 성능을 향상시키고 실제 응용 분야에 더 적합한 모델을 만들 수 있습니다.
    • LM adaptation은 Language Model(언어 모델)을 새로운 시간적 상황 또는 도메인에 맞게 조정하거나 적응시키는 과정을 의미합니다. 기존에 사전 훈련된 언어 모델을 특정 시간대나 특정 도메인에 맞게 세부 조정(finetuning)하여 해당 시간대나 도메인에 더 적합한 모델로 만드는 작업을 말합니다.
  • Low-Rank Adaptation (LoRA)
    • 일반적으로, 대규모 언어 모델은 많은 파라미터를 가지고 있어 새로운 작업에 직접 적용하기에는 계산적으로 비용이 많이 들 수 있습니다. Low Rank Adaptation은 이러한 문제를 해결하기 위해 모델의 파라미터를 저차원으로 압축하고 새로운 작업에 맞게 조정하는 방법을 제공합니다.
    • 이 기술은 새로운 작업에 대한 데이터가 제한적인 경우에 유용하며, 모델의 파라미터를 효율적으로 조정하여 새로운 작업에 빠르게 적응시킬 수 있습니다. Low Rank Adaptation은 대규모 언어 모델의 활용성을 높이고 다양한 작업에 쉽게 적용할 수 있도록 도와줍니다.
    • Low Rank Adaptation은 대규모 언어 모델을 새로운 도메인이나 작업에 적응시키는 기술 중 하나입니다. 이 기술은 기존에 사전 훈련된 대규모 언어 모델을 새로운 작업이나 도메인에 미세 조정(finetuning)할 때 사용됩니다.
  • default hyperparameters (q and v attention target modules, r = 8, α = 32, dropout = 0.1)
  • When creating time vectors, we merge LoRA weights back into the base model before subtracting the pretrained model.
  • use a batch size of 2 with 8 gradient accumulation steps
  • finetune for a single epoch on LM splits and three epochs on downstream task splits.
  • finetuned models concurrently with a single GPU each

3. Revealing Temporal Misalignment at Multiple Time Scales

3.1 Yearly Degradation is Linear

Figure 2: Model performance degrades linearly year-to-year

  • evaluate each of these year-finetuned models on every other time split of the test data
  • percent perplexity change from the average on each year to avoid inherent year performance differences. (낮을수록 좋음)
  • linear patterns of degradation in each task for all model sizes
  • some tasks, like political affiliation classification, exhibit clearer degradation than others.

3.2 Monthly Degradation is Seasonal

    Figure 3: Monthly temporal degradation has seasonal patterns.

  • train T5-small on each WMT LM month split from 2012–2016 (58month-finetuned models)
  • non-linear patterns
  • parallel to the diagonal every 12 months → the model for a particular month tends to do better on the same month in other years.
  • quantify these differencesFigure 12: Seasonality makes a small, but noticeable impact on monthly misalignment. Distribution of perplexity change from the mean for aligned finetuning and evaluation months (left, mean=-4.36), seasonal "stripes" (middle, mean=0.04), and all finetuning and evaluation combinations which share neither the same month nor year (right, mean=0.77)

3.3 Summary

  • measure temporal misalignment across a variety of domains, tasks and time scales
  • performance decays linearly on a yearly scale
  • seasonal trends in month-to-month misalignment

4. Temporal Adaptation with Time Vectors

  • a new source of data to study temporal misalignment : model weights
  • analyze these weights through the lens of time vectors
  • time vectors are formed by taking the difference of a model finetuned on a specific time and the pre- trained model.

4.1 Background and Definition

  • Task vectors : formed by taking the difference of a model finetuned on a specific time and the pre- trained model.
    • Adding and subtracting task vectors from finetuned models is a simple and effective way to improve performance on other settings, or reduce unwanted behavior without further training.
    • 본 연구에서는 task vector를 제안하여, PLM을 down-stream task에 적용할때 task에 맞게 모델을 edit 하거나, biases를 mitigate, unwanted behavior를 컨트롤, 새로운 information으로 update 하는데에 이용
    • 목적에 따라 negating a task vector, adding task vectors together, combining task vectors와 같이 3가지의 vector 연산을 사용Figure 1: An illustration of task vectors and the arithmetic operations we study for editing models.
  • Time vectors : an extension of task vectors to the time domain.
    • Given the weights of the pre-trained model, θpre and those of the model fine- tuned on data from only a single time period t, θt, a time vector τt = θt − θpre .
    • we add back the pretrained weights at inference time and evaluate θpre + τt
    • call time vectors from models finetuned on individual years and months “year-vectors” and “month-vectors.

 

4.2 Correlation of Time Vector Similarity and Temporal Degradation

Figure 4: Time vectors are organized in a manifold that reflects temporal variation.

time vectors closer together in weight space are also closer together in time.

⇒ verify this hypothesis, we measure the cosine similarity between model weights from each pair of time vectors trained on different time periods. (다른 시간 기간에 대해 훈련된 모델 가중치 간 코사인 유사성)

  1. Yearly
  • similarity metric and performance decay similarly over time.
    • similarity metricFigure10 : Cosine similarities between all pairs of year time vectors
    • performanceFigure 11 : Yearly language modeling perplexity decay
  • the correlation between cosine similarity and relative performance change on different years is highest in WMT language modeling.Table 1: The similarity between time vectors correlates with temporal degradation.
    • similar across T5 sizes
    • a higher score for T5-small in the WMT LM
    • no absolute values less than 0.6

2. Monthly

  • also extends to the monthly scale.
  • Seasonal stripes are visible in the cosine similarities between each pair of monthly WMT time vectors.Figure 9: Cosine similarity between monthly time vectors also exhibits seasonality.Figure 9: Cosine similarity between monthly time vectors also exhibits seasonality.
  • We observe similar "stripes" every 12 months when measuring the cosine similarity between each pair of T5-small WMT month vectors. The correlation between this heatmap (including the diagonal) and figure 3 is −0.667 with p < 1 × 10−16.
  • The monthly performance degradation from the mean (Figure 3) and cosine similarity matrices (Figure 9) have a negative correlation (Pearson r = −0.667; p < 10−16).

time vectors are organized in way that is predictive of their performance on corresponding time periods. (시간벡터가 해당 시간 기간에 대한 모델 성능 예측에 활용됨)

 

4.3 Generalizing to Intervening Time Periods

  • intervening time periods by interpolating between models finetuned on the oldest and newest times

Method

  • For two time vectors τj , τk , we compute their interpolation α·τj +(1−α)·τk with α ∈ [0, 1].
  • interpolate between the earliest year time vector τ0 and latest year time vector τn and evaluate on times t0, ..., tn for each α ∈ [0.1, 0.2, ..., 1.0].

Results

Figure 5: Interpolating between two year vectors improves performance on the years between them.

  • interpolating between start and end-year finetuned models improves performance on intervening years in both WMT LM and PoliAff tasks. (가중치 1이나 0보다 α를 조정해서 적용한 성능이 더 좋음)
  • when interpolating between 2012 and 2016, the best result on 2013 occurs with a higher percentage of 2012 and vice versa for 2015.
  • Improvement is generally greatest on the exact middle years (2013-WMT, 2017-PoliAff)
  • Patterns of improvement also vary depending on setting, with flatter changes in performance near α = 1.0, 0.0

Table 2 : Interpolation between start and end-year finetuned models reduces temporal misalignment on intervening years.

  • interpolation closes the gap on intervening years between temporally aligned and misaligned models
  • Best interpolations : use the best performing α values for each year (각 연도에 대해 가장 우수한 성능을 보이는 α 값을 사용하여 시작 및 끝 연도로 finetuned된 모델 사이를 보간한 결과)
  • Eval-year finetuned : 각 연도에 대해 finetuned된 모델의 성능
  • Improvements are particularly large for PoliAff, nearly eight macro-F1 points just by averaging the start and end-year time vectors

Figure 6: Interpolating between two month vectors improves performance on the months between them.

  • extend to the monthly scale for WMT LM
  • a higher percentage of the January model leading to better performance on earlier months and vice versa.
  • The stars in the upper plots correspond to the best performing interpolations for each evaluation month; these optimums are mirrored in the lower line plots. (작을수록 better)

 

4.4 Generalizing to the Future

  • language models that rely on supervision for finetuning are quickly outdated. Updating these models can be expensive, involving extra finetuning and creating labeled datasets from more recent examples.
  • a new technique for updating task models finetuned on a source time period j to a target time period k with only unlabeled data from j(labeled data), using task analogies.

Method

  • Given θLM, θLM, θj
    • language models with weights θLM, θLM finetuned on unlabeled text from times j,k
    • a task-specific model with weights θj fine-tuned on labeled data from time j
  • estimated θk
    • target time $t_k$
    • sweeping over all combinations of α1 ∈ [0.6,0.8,...2.2], α2,α3 ∈ [0.1,...0.6] and reporting the best result
  • $$ τ_j = θ_j − θ_{pre} \\ τ^{LM}_j = θ^{LM}j − θ{pre} \\τ^{LM}_k = θ^{LM}k − θ{pre} \\τ_k ≈ α_1 ·τ_j +(α_2·τ^{LM}_k − α_3·τ^{LM}j) \\θ_k = τ_k + θ{pre} $$
  • update a 2012 News- Sum model to 2013–2016, and a 2015 PoliAff model to 2016–2020
  • using WMT LM and Twitter LM time vectors respectively.

Results

Figure 7 : Task analogies can offset downstream temporal misalignment without labeled data from the target time.

  • Task analogies improve performance on future years in both PoliAff and NewsSum tasks
  • improvement compared to fine-tuning on the start year increases as the target and start years become more misaligned (시작 년도와 target 년도가 차이가 많이 날수록 성능 개선 ↑ )
  • Model size also affects performance, with T5-large and T5-3b showing greater improvements.
  • find that only scaling α1 can also improve performance on future years.Figure 15: Time vector analogy ablations for three sizes of T5
    • "task addition" : only adding the language modeling vector (α1, α2 ̸= 0, α3 = 0)
    • "scaling only" : only scaling the base τj model ( α1 ̸= 0, α2, α3 = 0).

 

4.5 Generalizing to Multiple Time Periods

  • test if we can build models that perform well on multiple time periods by interpolating between all time vectors for a task.

Method

  • model soup techniqueensemble 처럼 추가적인 inference나 cost 없이 모델의 parameter를 평균냄으로써 성능 개선
    • 장점
      • time-specific models can be trained independently (on smaller compute budgets) and combined at any time
      • the multi-year model does not need to be retrained to include new time periods; new time periods can be incorporated by merely growing the soup with additional fine- tuned models.
  • 여러 개별 모델을 결합하여 하나의 강력한 모델을 형성하는 기술
  • two soup variants
    • uniform soup : a uniform weight among all constituent models in the interpolation
      • $θ_{pre} + \frac{1}{|T|}\sum_{t\in T}τ_t$
      • T : the set of all years for a given task
      • → θpre + 각 시간대의 시간벡터의 평균합
    • greedy soup : only includes models in the soup that improves validation performance
      • samples time vectors from each year in order of decreasing performance and adds them to the average model soup if they improve performance.
  • 평가
    • measure the average performance across all evaluation years for each task.
    • compare our model soups against two baselines:
        1. a model trained on all shuffled available data at once
        1. the best-performing model finetuned on only a single year of data.

Results

Table3 : Interpolation does not enable generalization to multiple time periods simultaneously

  • time soups perform worse than the model finetuned on all shuffled available data.
  • uniform soup
    • For WMT LM and NewsSum, worse than even the best single year model, despite having access to five times the amount of finetuning data.
  • greedy soup
    • only improves over the best single-year model on PoliAff with a single macro F1 point gain.

→ a model which generalizes to multiple time periods does not lie in a region of weight space bounded by models finetuned on single years of data.

 

4.6 Summary

  • We find that interpolating between two time vectors improves performance on unseen intervening times at both yearly and monthly scales.
  • we can improve performance on the future with unlabeled data from target times using time vector analogies
  • Building a multi-year model with a “soup” of time vectors, however, does not approach the performance of a model finetuned on all times at once.

→ task arithmetic can be a simple way to update models to new times, but it does not help to improve genearlization across the board within a single model.

 


5. Related Work

  • Semantic Drift
    • semantic changes in word em- beddings over time are well-documented(Hamilton et al., 2016).
    • Temporal misalignment (Bamler and Mandt, 2017; Gonen et al. 2021) and word analogies over time (Szymanski, 2017) have also been studied in embeddings.
      → Our work extends these analyses to the full set of language model parameters.
  • Temporal Misalignment
    • The phenomenon of temporal misalignment in language models has gained attention in the last three years.
      • Lazaridou et al. (2021) show that increasing model size does not help mitigate temporal misalignment.
      • Luu et al. (2022) find that degradation varies greatly over both domain and task.
      • Longpre et al. (2023) report similar degradation over time in pretraining regardless of model size
  • Updating LMs
    • Recent attempts at updating language models to new time periods have used a range of techniques.
      • keeping models up to date in the QA domain by adding flags with the year for each example (Dhingra et al., 2022) by discarding outdated facts (Zhang and Choi, 2023)
        → updating models to new time periods without data in the target time and without additional finetuning.
  • Interpolation
    • Our work draws heavily on recent techniques for editing models directly with interpolation and task analogies.
      • Time vectors : an application of task vectors (Ilharco et al., 2023)
      • interpolation experiments : inspired by previous work on patching mod- els for multiple tasks (Ilharco et al., 2022)
      • time soup : an application of models soups (averaging multiple models trained with different initializations) (Wortsman et al., 2022).

6. Conclusion

We connect studies of temporal misalignment and weight arithmetic with time vectors

  • the weights of time vectors are more similar if their corresponding times are closer.
  • These similarities are highly correlated to temporal misalignment at both yearly and monthly scales.
  • induce new models that perform better on intervening years by interpolating between adjacent time vectors.
  • use task analogies to improve downstream performance on future time periods using only unlabeled data from those times.

    ⇒ task arithmetic can be a simple tool for com- bating temporal misalignment.

  • 언어 모델을 새로운 시간 기간에 맞추기 위한 간단한 도구인 시간 벡터를 제시
  • 시간 벡터: 언어 모델을 특정 시간(예: 연도 또는 월)의 데이터로 세세하게 조정한 후 원래 사전 훈련된 모델의 가중치를 뺀 것
  • 실험 결과에 따르면, 이 벡터는 해당 시간 기간의 텍스트에서 성능을 향상시키는 가중치 공간에서의 이동 방향을 지정
  • 인접한 시간 기간에 특화된 시간 벡터는 매니폴드 내에서 서로 더 가까이 위치
  • 이 구조를 활용하여 시간 벡터 사이를 보간하여 어떠한 추가 훈련 없이 중간 및 미래 시간 기간에 더 나은 성능을 발휘하는 새로운 모델을 유도할 수 있음
  • 다양한 작업, 도메인, 모델 크기 및 시간 척도에서 결과의 일관성을 입증
  • 결과적으로, 이 연구는 시간이 세세하게 조정된 모델의 가중치 공간에 인코딩되어 있음을 시사

논문 링크 : https://arxiv.org/abs/2312.13401

    •