The main idea behind contrastive learning is to divide an input data into multiple (possibly overlapping) views and maximize the mutual information between encoded representations of these views, using views derived from other inputs as negative samples. our proposed framework also gives rise to a general class of word representation learning models which serves as a basis for designing and combining self-supervised training objectives to create better language representations.
Mutual information measures dependencies between random variables. Given two random variabels A and B, it can be understood as how much knowing A reduces the unceertanity in B or vice viersa
$$ I(A,B)=H(A)-H(A|B)=H(B )-(B|A) $$
One particular lower bound that has been shown to work well in practice is InfoNCE
$$ I(A,B)\geq\mathbb E_{p(A,B)}\bigg[f_{\boldsymbol\theta}(a,b)-\mathbb E_{q(\tilde{\mathcal B})}\bigg[\log\sum_{\tilde{b}\in\tilde{\mathcal B}}\exp f_{\boldsymbol\theta}(a,\tilde{b})\bigg]\bigg]+\log|\tilde{\mathcal B}| $$
where $a,b$ are different views of an input sequences, $f_{\boldsymbol\theta}\in\R$ is a function prameterized by $\boldsymbol\theta$ (e.g. a dot product between encoded representations of a word and its context), and $\tilde{\mathcal B}$ is a set of samples drawn from a proposal distribution $q(\tilde{\mathcal B})$. The set $\tilde{\mathcal B}$ contains the positive sample $b$ and $|\tilde{\mathcal B}|-1$ negative samples
We assuam that $f_{\boldsymbol\theta}(a,b)=g_{\boldsymbol\psi}(b)^Tg_{\boldsymbol\omega}(a)$, where $\boldsymbol\theta=\{\boldsymbol\omega,\boldsymbol\psi\}$
Skip-gram is : $\mathbb E_{p(x_i,x_j^i)}[p(x_j^i|x_i)]$, where $x_i$ is a word token and $x_j^i$ is a context word of $x_i$. Let $b$ be the context word to be predicted $x_j^i$ and $a$ be the input word $x_i$. In the skip-gram $g_{\boldsymbol\psi}(b)$ and $g_{\boldsymbol\omega}(a)$ are embeddng lookup functions that map each word type to $\R^d$.
$p(x_j^i|x_i)$ cna either be computed using a standard softmax over the entire vocabulary or with negative sampling
We can see that the two views of an input sentence that are considered in Skip-gram are two words that appear in the same sentece, and they are encoded using simple lookup functions.
two self-supervised taskes for learning contextual word representations : masked language modeling, next sentence prediction
In masked language modeling, given a sequence of word tokens of length $T$, $\bold x=\{x_1,\cdots,x_T\}$, BERT replaces 15% of tokens in the sequence with