This work connects language model adaptation with concepts of machine learning theory. We consider a training setup with a large out-of-domain set and a small in-domain set. We derive how the benefit of training a model on either set depends on the size of the sets and the distance between their underlying distributions. We analyze how out-of-domain pretraining before in-domain fine-tuning achieves better generalization than either solution independently. Finally, we present how adaptation techniques based on data selection, such as importance sampling, intelligent data selection and influence functions, can be presented in a common framework which highlights their similarity and also their subtle differences. Neural Language Models (LMs) trained on large generic training sets  over a billion sentences (Kaplan et al., 2020; Roziewski and Kozowski, 2021)  have been shown to be effective at adapting to smaller, specific target domains for language modeling and other downstream tasks (Bommasani et al., 2021). Neural LM adaptation is commonly performed via fine tuning (Devlin et al., 2018; Liu et al., 2019; Raffel et al., 2019; Radford et al., 2019), data selection (van der Wees et al., 2017) or their combination (Wang et al., 2018; Aharoni and Goldberg, 2020; Gururangan et al., 2020). However, the tradeoffs between fine-tuning and reweighting of pretraining data is not well understood and a theoretical framework for reasoning about the generalization performance of these methods is needed. In this paper, we connect language model adaptation with concepts of machine learning theory. Our derivations support past empirical observations: it has been observed that the size of the out-of-domain pre-training set is important for in  Work performed while interning at Google. domain generalization (Raffel et al., 2019; Devlin et al., 2018) or that domain adaptation is more effective on domains which are well represented in the the pre-training data (Radford et al., 2019). Our study consider a training setup with a large out-of-domain set and a small in-domain set. As a first contribution, we derive how the benefit of training a model on either set depends on the size of the sets and the distance between their underlying distribution. We also expose how fine-tuning can be viewed as a regularization method that can achieve a better trade-off than training only on either set. The research on data selection for LM adaption originates mainly from intelligent selection (Moore and Lewis, 2010; Axelrod et al., 2011). This method examines the out-of-domain training data to emphasize a subset deemed more likely by an in-domain model than by an out-of-domain model. Although intuitive, the connection of this method with statistical estimation is unclear, which makes studying its impact on generalization error difficult. Another family of selection methods stems from influence functions (Koh and Liang, 2017; Wang et al., 2021) which estimate whether the model updates from out-of-domain training examples are aligned with the in-domain updates. This approach is more principled and its impact on the generalization error is easier to study. In this work, as a second contribution, we show how intelligent selection and influence function methods are linked in the case of neural LMs. In particular, we show that they both can be derived from importance sampling (Owen, 2013), a classical, well-studied statistical estimation technique. The rest of our paper is organized as follows. We first presents the theoretical trade-offs between in-domain and out-of-domain training. We highlight the importance of the relative sizes of in-domain and out-of-domain training sets along with 3802 the distance between their underlying distributions. We also present how fine-tuning with a limited number of updates can be seen as a training method regularized with respect to the out-of-domain prior. Finally, we present data selection methods under a unifying framework. Language modeling refers to the generative modeling of natural language (Manning and Schutze, 1999). Commonly, natural language is represented as a sequence of symbols, tokens, from a finite vocabulary. For instance, language can be represented as a sequence of characters, a sequence of words or alternative units. A neural language model (LM) decomposes the estimates the log probability of a text y = ( y 1 , . . . y n ) , as log P ( y ;  ) = n (cid:88) i =1 log P ( y i | y i  1 1 ;  ) where P  maps a parameter vector  along with a sequence of past tokens y i  1 1 onto a probability distribution over the vocabulary. Different types of neural architectures have been used for neural language modeling. Most architectures used for LMs re-use intermediate computations from the previous steps for the next steps when estimating probabilities for successive tokens in the same sequence. Popular architectures include recurrent neural networks (Mikolov et al., 2010; Sundermeyer et al., 2012), convolutional networks (Dauphin et al., 2017) and transformer networks (Vaswani et al., 2017; Radford et al., 2019). The parameter vector    of a neural LM is identified by maximizing the log likelihood over a training set D sampled from the true distribution D using variants of stochastic gradient descent. The log likelihood of a held-out set, sampled from the same distribution, can evaluate model quality. One often reports perplexity, the exponentiated negative average log likelihood per token. This type of model is used for translation where ( x, y ) pairs are sentences in the source and target language (Koehn, 2009; Bahdanau et al., 2015) or summarization where ( x, y ) pairs are corresponding corresponding articles and summaries (See et al., 2017). For both conditional and regular LMs, the size of the training data is important to achieve a low held-out perplexity. This is an obstacle for domains with limited available training data. This issue has led to various model adaptation approaches. These methods leverage large amounts of generic training data D along with a small amount of target domain training data T from the domain of interest. Fine tuning is a popular domain adaptation method which trains a neural language model in two phases, first maximizing the likelihood of the generic set D (pre-training) before optimizing the likelihood of the target domain set T (fine-tuning). As an alternative to fine-tuning, some methods consider leveraging the small target-domain training set to identify and emphasize similar data in the larger generic training set. These emphasis methods can be used individually or in conjunction with fine-tuning. Emphasis methods include importance sampling, contrastive data selection and influence functions. This paper shows that these methods  although proposed in different context  can be presented in a unified way which allows light to be cast on their subtle differences. This section first examines in-domain training, i.e. when the training and test data are sampled from the same distribution. It then studies out-of-domain training, i.e. when the training and test data distribution differs. Finally, it examines out-of-domain pre-training followed by in-domain fine tuning. For the three cases, we decompose the loss relying on classical concepts from learning theory and study the trade-offs involved in each setup. Given a training set D sampled from a distribution D , learning an LM typically aims at minimizing the negative log-likelihood of D , also referred to as the cross-entropy loss i.e. over the true, unavailable distribution P ( y |D L (  ; D ) =  (cid:88) y   log P ( y |  ) P ( y |D ) = E y D [  log P ( y |  )] , where the distribution's support  is the set of all finite sequences. The true expected loss is bounded by the entropy of the distribution P ( |D ) , i.e. L (  ; D )  LH ( D ) = H ( P ( |D )) since H ( P ( |D )) = min q E y D [  log q ( y )] . The gap between the best likelihood from a neural network with the chosen parameterization and the entropy is called the approximation error L app ( D , ) = min    L (  ; D )  H ( P ( |D )) . This gap accounts for the fact that P ( |D ) generally cannot be represented by a parameterized function from the chosen family spanned by  . In addition to the approximation error, one should consider the estimation error to account that one relies on the empirical risk from the finite set D , L est ( D ,  , D ) = L (  D ; D )  min  L (  ; D ) with  D = arg min    L (  ; D ) . Therefore, the loss of  D over D decomposes as (Bottou and Bousquet, 2007) L (  D ; D ) = LH ( D ) + L app ( D , ) + L est ( D ,  , D ) (1) where the three terms accounts for the intrinsic uncertainty of D , the chosen neural architecture and the finite training set D respectively. The approximation error L app ( D , ) depends on the selected model family  . It can be reduced by selecting a more expressive family, i.e. a neural architecture with more capacity, a larger  , e.g. architectures with more, wider layers. The estimation error L est ( D ,  , D ) depends both on the selected model family  and the size of the training data D . Increasing model capacity will result in a higher estimation error for the same training set size, but training over a larger training set will decrease estimation error. Therefore, for a given training set size, capacity needs to be chosen to identify a good trade-off between the two error types. Two important properties of neural networks need to be kept in mind when examining this trade-off. The universal approximation property (Lecun, 1987; Funahashi, 1989) means that for any approximation error (cid:15) and any distribution D , there exists a capacity setting C ( (cid:15), D ) at which a neural network   C ( (cid:15), D ) whose error is below (cid:15) , i.e.  (cid:15) > 0 ,  C s.t. L app ( D , C )  (cid:15). In layman terms, the universal approximation property means that for sufficiently large capacity settings, the approximation error can become arbitrary low. The statistical consistency property means that for any (cid:15), (cid:15) (cid:48) > 0 , there exist a training set size N ( (cid:15), D ) such that sampling a training set of size N ( (cid:15), (cid:15) (cid:48) , D ) from D will result in an estimation error less than (cid:15) (cid:48) with probability 1  (cid:15) ,  (cid:15), (cid:15) (cid:48) > 0 ,  N s . t , P ( D  DN : L est ( D ,  , D ) < (cid:15) (cid:48) ) = 1  (cid:15) In layman terms, the statistical consistency property means that for sufficiently large training sets, the probability to get an estimation error below any positive value can be arbitrary close to 1. Universal approximation and consistency implies that, in the asymptotic case (i.e. as the size of D tends to infinity), the last two terms in Eq. 1 can be arbitrary close to zero with the appropriate model capacity (with high probability). In that case, the likelihood L (  D ; D ) amounts to the intrinsic entropy of D with the appropriate model capacity. This section considers a setup where one needs a specialized language model in a domain T and two training sets are available: a small training set T sampled from T and a large training set D sampled from D , a generic domain different from the specialized domain. In that context, the simplest options are either to train a model over T or D alone. Training only on the small set T results in the generalization loss L (  T ; T ) = LH ( T ) + L app ( T , ) + L est ( T ,  , T ) with  T = arg min    L (  ; T ) as in the previous section. Training on the larger set D results in L (  D ; T ) = LH ( T ) + L app ( T , ) + L est ( T ,  , D ) . 3804 Two factors are important to compare these two options: the size of the specialized set T relative to the size of the generic set D and the similarity between T and D distributions. When the T and D distributions are identical, D and T are sampled from the same distribution and training a model on the larger training set D is advantageous. For a constant capacity, this option will get a lower estimation error. When varying capacity, one might identify a setting with an even better trade-off in the compound loss of Eq. (1) with the larger training set D. When the distributions T and D differ and the size of D is fixed, the size of T determines which option to prefer. Statistical consistency means that L est ( T ,  , T ) will converge to zero in probability as the size of T grows. This means that when the size of T is greater than N ( (cid:15), L est ( T ,  , D ) , D ) , the probability that training on T results in a better generalization loss than training on D is above 1  (cid:15) . When the distributions T and D differ, the Kull-backLeibler (KL) divergence between the two distributions plays a key role. Theorem 1 The generalization of the loss of  D over T is upper bounded as  (cid:15) > 0 ,  N s.t.  D  D n , L (  D ; T )  H ( T ) + KL ( T , D ) + (cid:15) (2) with probability 1  (cid:15) . This bound justifies the intuition that, if given the choice between two generic domains D and D (cid:48) , training over the one with the lowest KL divergence to T will result in a better asymptotic behaviour. The proof of this bound is presented in Appendix A. 3.3 Fine-Tuning & Multitask Learning Fine-tuning for domain adaptation trains a model on a small in-domain set initializing optimization from the parameters of a model trained on a large out-of-domain set. Formally, fine-tuning minimizes L (  ; T ) the loss over T for a few steps, starting the optimization from  D = arg min    L (  ; D ) . This strategy implicitly targets a trade-off between the empirical losses over T and D . This trade-off is controlled by the number of fine tuning steps n ft . Few steps means that the identified parameters  ft achieve a low loss over D , while many steps expresses that the parameters achieve a low loss over T . This strategy leverages the regularization effect of early stopping (Caruana et al., 2001), i.e. the solution found by gradient descent is guaranteed to be in an Euclidean ball centered around the initialization whose radius grows with the number of steps (Grangier and Bengio, 2008), i.e. (cid:107)  ft   D (cid:107) 2   n ft g max where  refers to the (maximum) learning rate and g max to an upper bound on the update norm. The small distance between  ft and  D guarantees that the loss L (  ft ; D ) is close to the optimum L (  D ; D ) when   L (  ; D ) is a smooth function, e.g. a Lipschitz function. For the basic fine-tuning setup, several variants have been introduced. Some approaches (De-vlin et al., 2018; Liu et al., 2019; Raffel et al., 2019) consider leaving some parameters un-tuned or frozen which is the extreme case of regularization for these weights, penalizing any deviation from initialization. Other approaches consider introducing novel (unregularized) weights for fine tuning, often referred as adapter layers (Houlsby et al., 2019; Stickland et al., 2019; Pfeiffer et al., 2020). Other forms of regularization, such as dropout, have also been considered in conjunction with fine tuning (Miceli Barone et al., 2017). The selection of the regularization strength in fine-tuning is computationally efficient since it successively visits an optimization path from the most regularized model (  D trained only on D, Sec. 3.2) to the unregularized  T (Sec. 3.1). This is more efficient compared to explicit regularization methods, including multitask learning (Caruana, 1998; Collobert and Weston, 2008; Pilault et al., 2021), i.e. optimizing L multi (  ; T, D,  ) = L (  ; T ) +  L (  ; D ) . Data selection aims to improve out-of-domain training by selecting or giving stronger weights to some data points. The identification of these points aims to emphasize out-of-domain examples which have an impact on the model similar to the impact of the in-domain training examples. We study three independently proposed selection methods, importance sampling, contrastive data selection and influence functions. We show that these methods all train models through weighted log-likelihood training, L (  ; D, T, w ) =  1 | D | (cid:88) y  D w ( y ; T , D ) log P ( y |  ) 3805 but introduce their weights w ( y ; T , D ) with different justifications. Despite these differences, we show that these methods result in surprisingly similar selection weights in the specific case of neural language models. Data selection is particularly suited when the out-of-domain training distribution and the test distribution have a large KL divergence but the out-of-domain training set is large. In that case, the generalization of a model trained on out-of-domain data is poor due to the large KL divergence between T and D , see Eq. (2). When this KL divergence is large but out-of-domain data is abundant, data selection methods propose to select a subset of the out-of-domain data DT  D . Ideally, the training loss over such a subset L ( , DT ) would be a better proxy for the generalization loss over T , L ( , T ) , than the training loss over the full set D , L ( , D ) . Selection involves a delicate trade-off though. One one hand, data selection is attractive since it replaces the training set with another set closer to the test domain. On the other hand, this training set is smaller, which increases the impact of estimation errors. Additionally, data selection is imperfect since the target domain distribution T is only known through a small target training set T . This section successively presents importance sampling, contrastive data selection and influence functions and connect them into a single framework. Although intelligent selection also called contrastive data selection is more common (Moore and Lewis, 2010; Wang et al., 2018), we first examine importance sampling since this method will guide our understanding of other selection methods. Importance sampling is a generic statistical technique (Owen, 2013). In our case, it can be used to estimate the expectation of the cross-entropy loss over T while having access to samples from D . It relies on the identity L (  ; T ) = E y T [  log P ( y |  )] =  (cid:88) y   log P ( y |  ) P ( y |T ) =  (cid:88) y   log P ( y |  ) P ( y |T ) P ( y |D ) P ( y |D ) = E y D [  w ( y ; T , D ) log P ( y |  )] where w ( y ; T , D ) = P ( y |T ) P ( y |D ) , assuming full support on D , i.e.  y   , P ( y |D ) > 0 . In practice, one has not access to T and D but to finite samples T and D . With importance sampling, we can consider two alternative estimators of L (  ; T ) , either the empirical risk over T , L (  ; T ) =  1 | T | (cid:88) y  T log P ( y |  ) or the mean of the importance weighted cross entropy over D , i.e. L imp (  ; D, T,  w ) =  1 | D | (cid:88) y  D  w ( y ; T , D ) log P ( y |  ) where  w estimates of the weights w from the training sets D and T . The trade-off between these two estimators depends on the relative size of T and D , the imbalance of the weights w and the quality of their estimate  w . Importance sampling is interesting when the generalization error L (  imp( D,T ) ; T ) of the model  imp( D,T ) = arg min  L imp (  ; D, T,  w ) is less than the generalization error of  T selected by minimizing L (  ; T ) , i.e. classical empirical risk minimization. This error decomposes as, L (  imp( D,T ) ; T ) = LH ( T ) + L app ( T , ) + L impest ( T ,  , D, T ) . where L est / w ( T , D ,  , D ) refers to the estimation error resulting from the finite size of D , assuming access to the true importance weights, and L est / w ( T , D ,  , D ) = L (  imp( D, D ) ; D )  min  L (  ; T ) , L est / w ( T ,  , D, T ) = L (  imp( D, T ) ; D )  L (  imp( D,T ) ; D ) with  imp( D, D ) = arg min  L imp (  ; D, T,  w ) The first term depends on the size of D and the imbalance of the weights. For instance, if the weights are mostly concentrated over a small subset of D , this estimation error will be high. If this subset is smaller than T , estimation errors from L imp (  ; D, T,  w ) will be higher than from L (  ; T ) . The notion of effective sample size has been defined to quantify this effect (Kish, 1965). It is defined by examining the variance of the weighted sum of n independent random variables Z i with mean  Z and variance  2 Z , S w = (cid:80) i w i Z i (cid:80) i w i . This variance is  2 S w = (cid:80) i w 2 i ( (cid:80) i w ) 2  2 Z which can be compared to  2 S = 1 n  2 Z in the unweighted case. This means that the weighted sum variance matches the variance of an unweighted case with n e = ( (cid:80) i w ) 2 (cid:80) i w 2 i . Assuming that losses over D and T have comparable means and variances, the expected loss estimate with importance weighting over D has lower variance than the mean over T only when, n e = ( w ) 2 w 2 | D | (cid:29) | T | where w = 1 | D | (cid:80) y  D w ( y ) and w 2 = 1 | D | (cid:80) y  D w 2 ( y ) are the sample mean and variance of the weights over D . This means that the first term in the estimation error is L est / w ( T ,  , D, T ) advantageous compared to the estimation error from classical empirical risk minimization over T when T is small. Unfortunately, the second estimation error term L est / w ( T ,  , D, T ) gets larger as T gets smaller since estimating the importance weights w ( y ; T , D ) = P ( y |T ) P ( y |D ) from data is challenging when T is small. One can remark that language modeling is actually the very problem of identifying a model to estimate the probabilities in this ratio, P ( y |T ) and P ( y |D ) , from finite samples from the distributions T and D . Discriminative classi-fiers are also relevant to estimate this ratio since w ( y ; T , D )  P ( T | y ) P ( D| y ) . In fact the multiplying constant (prior ratio) does not matter since multiplying the weighted loss by a positive constant has no impact on optimization. When importance weights are estimated with an LM, one can estimate P ( |T ) by fine tuning on T a model pre-trained on D . The number of tuning steps n ft gives controls on (cid:107)  ft   D (cid:107) . When n ft = 0 ,  w = 1 and the importance sampling loss corresponds to L ( , D ) . As n ft grows, the estimate P ( y |  ft ) could overfit and assigns most of the probability mass to a small neighborhood around samples in T . The weights  w will in turn be concentrated in this small neighborhood, making the minimizer of the importance sampling loss close to the minimizer of the empirical loss over T . Therefore, fine-tuning a language model for estimating the importance weights allow to progressively transition between the in-domain and the out-of-domain empirical loss minimizers seen in Section 3.2. In the next sections, we refer to the estimated importance sampling weights as w imp D,T ( y ) =  w ( y ; T, D ) . Importance sampling has been used for model training for various application: either to improve training speed (Johnson and Guestrin, 2018; Katharopoulos and Fleuret, 2018) or to adapt to a changing training distribution (Mahmood et al., 2014; Metelli et al., 2018). Importance sampling has rarely been used to modify the training distribution of language models (Foster et al., 2010; Fernandez and Downey, 2018) as intelligent selection methods are more common. Intelligent selection (Moore and Lewis, 2010; Axelrod et al., 2011) and contrastive data selection, its extension to neural networks (van der Wees et al., 2017; Wang et al., 2018), have been introduced in the language modeling literature. We show that these methods are closely related to importance sampling, even if their original papers does not mention this link. Intelligent selection selects training samples from an out-of-domain dataset according to the log-odd between an in-domain LM and an out-of-domain LM. Typically, a binary decision is taken per sentence by comparing the average log-odd to a threshold  , L IntSel ( , D, T ) =  (cid:88) y  D b IntSel D,T ( y ) log P ( y |  ) where b IntSel D,T ( y ) is defined as I { log P ( y |  T )  log P ( y |  D ) >  } . Compared to importance sampling, the weights are binarized, i.e. b IntSel D,T ( y ) = I (cid:110) log w imp D,T ( y ) >  (cid:111) . The binarization decision was certainly driven by convenience as most n-gram LM training packages did not support weighted likelihood optimization when intelligent selection was introduced. Binarization also has the advantage of down-weighting extremely positive weight values from large log P ( y |  T ) due to over-fitting on the small set T . More recently, intelligent selection has been extended to neural models (van der Wees et al., 2017; Wang et al., 2018). Contrastive data selection (Wang et al., 2018) suggests to fine tune the in-domain model log P ( y |  T ) from log P ( y |  D ) and also observes that selection scores can effi-ciently be estimated from a model with a much smaller capacity than the final trained model. Dynamic selection (van der Wees et al., 2017) proposes to increase the selection threshold  t as training progresses, gradually transitioning from generic to in-domain training. This gradual adaptation of neural network is related to curriculum learning (Bengio et al., 2009) which studies the ordering of examples and tasks during model training. Intelligent selection methods have been applied both for unconditional models (language modeling) and conditional models (machine translation). In the conditional case, intelligent selection computes b IntSel D,T ( x, y ) = I (cid:110) log w IntSel D,T ( x, y ) >  (cid:111) with w IntSel D,T ( x, y ) = P ( y | x,  T ) P ( y | x,  D ) . This ratio of conditional probabilities is different from the ratio of joint probabilities stemming from importance sampling, i.e. L imp (  ; D, T,  w ) =  1 | D | (cid:88) y  DP ( x, y |T ) P ( x, y |D ) log P ( y | x,  ) . The two ratios match when P ( x |T ) = P ( x |D ) since w imp D,T ( x, y ) = P ( x, y |T ) P ( x, y |D ) = P ( x |T ) P ( x |D ) w IntSel D,T ( x, y ) . The formulation of intelligent selection therefore neglects the domain mismatch from the input distribution in the conditional case. This formulation aligns with the denoising goal (Wang et al., 2018) which assumes that D contains label noise, i.e. mistranslation in that case. As mentioned above, importance sampling and intelligent selection weights can be estimated by contrasting the log probabilities from a base model with those from a fine-tuned model. This use of fine-tuning connects intelligent selection to influence function and gradient alignment techniques. Influence functions (Koh and Liang, 2017; Pruthi et al., 2020) have been used as a diagnostic tool to identify the training instances which support or contradict with a given test label. This task is related to the selection of training data when the objective is to find instances in a generic training set D whose training updates increase the likelihood of a set T from a different domain. The influence of a training point y on a test point y (cid:48) is defined as I( y, y (cid:48) ) =  (cid:96)  ( y (cid:48) ;  ) (cid:62) H  1  (cid:96)  ( y ;  ) where (cid:96) ( y,  ) refers to the loss at y for a model with parameters  and H  refers to the Hessian of the model loss at  . This quantity can be derived by considering the impact of reducing the weight of point y during training on the test loss at y (cid:48) . If we increase the weight of a training example by (cid:15) ,  D,(cid:15) = min  1 | D | (cid:88) z  D (cid:96) ( z ;  ) + (cid:15)(cid:96) ( y ;  ) 3808 From (Cook and Weisberg, 1982), we derive  D,(cid:15) (cid:15) (cid:12)(cid:12)(cid:12)(cid:12) (cid:15) =0 =  H  1  (cid:96)  ( y ;  ) (cid:12)(cid:12)(cid:12)(cid:12)  =  D . Composing with the test loss on ( x (cid:48) , y (cid:48) ) , we get (cid:96) ( y (cid:48) ;  D,(cid:15) ) (cid:15) (cid:12)(cid:12)(cid:12)(cid:12) (cid:15) =0 =  (cid:96) ( y (cid:48) ;  ) (cid:62)  (cid:12)(cid:12)(cid:12)(cid:12)  =  DH  1  (cid:96) ( y ;  )  (cid:12)(cid:12)(cid:12)(cid:12)  =  D which matches the expression of influence introduced above. We now connect influence with the precedent sections on importance sampling and contrastive data selection. We consider an LM with weights  D , trained on the generic training set D . Its first order Taylor expansion at  D is log P ( y |  D +   ) = log P ( y |  D ) +   (cid:62) g ( y ;  D ) + O (cid:0) (cid:107)   (cid:107) 2 (cid:1) (3) where g ( y ;  D ) =   log P ( y |  ) (cid:12) (cid:12)  =  D . If the model pre-trained on D is fine-tuned on T by performing a single step of gradient descent with learning rate  , we get  T =  D     L ( T ;  ) (cid:12)(cid:12)(cid:12)(cid:12)  =  D =  D +  E y  T [ g ( y ;  D )] . In that case, the log-odd of the two models therefore has the following Taylor expansion, log P ( y |  T )  log P ( y |  D ) =  E y (cid:48)  T (cid:104) g ( y (cid:48) ;  D ) (cid:62) g ( y ;  D ) (cid:105) + O (cid:0) (cid:107)  D   T (cid:107) 2 (cid:1) . If we assume that the model's Hessian is the identity, H  = 1 , we therefore have log P ( y |  T )  log P ( y |  D ) =   E y (cid:48)  T (cid:2) I( y, y (cid:48) ) (cid:3) + O (cid:0) (cid:107)  D   T (cid:107) 2 (cid:1) . The Hessian assumption might be dropped when the model is fine-tuned with a Newton-style update (Boyd and Vandenberghe, 2014). The above relation means that the negative mean influence of a point y  D over the set T also corresponds to the log of the estimated importance weights introduced in Section 4.1, i.e. log w imp D,T ( y ) =   E y (cid:48)  T (cid:2) I( y, y (cid:48) ) (cid:3) + O (cid:0) (cid:107)  D   T (cid:107) 2 (cid:1) . Of course, this relation holds only in the case where a single gradient step is performed for fine-tuning. This relation allows estimating the reduction in test loss (here over T ) when removing training samples from D with positive influence which is also the goal of intelligent data selection. This strategy has been applied to label noise filter-ing (Koh and Liang, 2017), class rebalancing (Ren et al., 2018) and domain adaptation (Wang et al., 2021). Our analysis connects importance sampling, contrastive data selection and influence functions. In practice, contrastive data selection is the most popular approach. Unlike influence functions, contrastive data selection weights rely on fine tuning the generic model for more than one step on the in-domain data T . This has two effects. On one hand the contrastive data selection weights can be more reliable, closer to the ideal weights w ( y ; T , D ) = P ( y |T ) P ( y |D ) . On the other hand, multiple steps increase the risk of over-fitting to T . In the case where one first trains with data selection before fine tuning on T , it might actually be helpful to limit the influence of T on selected data, to increase the complementary effect of fine tuning (Iter and Grangier, 2021). When comparing contrastive data selection with importance sampling, the weight binarization is the main difference. This binarization might also have two opposite effects. On the positive side, it acts has a regularizer since binary weights are less likely to reflect statistics specific to T compared to unquantized ones. On the negative side, it cancels low weights which might collectively represent most of the weighted cross entropy. This interpretation of contrastive data selection as a regularized version of importance sampling opens the door to exploring more sophisticated regularization alternative to regularization, e.g. using a lower capacity model or different input features to estimate selection weights. This work focuses on domain adaptation for neural language modeling. It compares the generalization properties of a model trained over a large out-of-domain corpus as opposed to a model trained over a small in-domain corpus. It shows how fine-tuning, the most common approach for neural LM 3809 adaptation can achieve better trade-offs than either solution. We then focus on adaptation via data selection techniques, i.e. techniques to emphasize in-domain data in an out-of-domain training set. We show that common techniques, contrastive data selection and influence function selection, can both be derived from importance sampling. Our analysis currently assumes a pure language modeling setup, i.e. an auto-regressive model trained aiming high log-likelihood, both for out-of-domain and in-domain data. In the future, we want to extend our analysis of domain adaptation techniques to the popular setting (Bommasani et al., 2021) where model training combines language modeling over out-of-domain data and a different final task on in-domain data. Our theoretical work also raises empirical questions. The binarization of importance sampling weights in intelligent selection is a simple variance reduction technique and more sophisticated alternative might be beneficial empirically. The link between influence functions and importance sampling suggests that examples with importance sampling weights lower than one have only a negative effect on the in-domain likelihood, which is not a typical observation in practice. This contradiction suggests expanding influence scores to take into account effects beyond a single update. We thanks Wei Wang, Bowen Liang, Kelvin Guu and Nicolas Le Roux for their suggestions and comments.
abstain method method result result abstain abstain abstain abstain result abstain method objective result abstain abstain abstain abstain abstain objective result method objective result result method abstain abstain abstain other abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain method abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain other abstain other abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain other abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain method other abstain method abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain other abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain method abstain abstain abstain abstain abstain other abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain other abstain other other abstain method other method other method abstain other abstain abstain abstain method abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain method abstain abstain objective result objective abstain abstain abstain abstain abstain other