Natural Language Processing (Almost) from Scratch

Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research)

Subscriber deck — free during early access

30 cards

1. Introduction

  1. What is the goal of “NLP (Almost) from Scratch”?
    A single neural architecture and learning algorithm for several NLP tasks (POS tagging, chunking, NER, SRL) that avoids task-specific feature engineering and instead learns internal representations, largely from vast unlabeled data.
  2. What criticism of the prevailing NLP methodology motivated Collobert et al.?
    Most state-of-the-art systems applied linear models to hand-engineered, task-specific features, often built from outputs of other systems. Optimizing for one benchmark teaches little about the broader goals of language understanding; Collobert et al. treat benchmarks as indirect measures of the quality of learned intermediate representations.
  3. Why “almost” from scratch?
    Some a priori NLP knowledge remained: lowercasing words, a capitalization feature, replacing digit sequences, and tokenization. A truly from-scratch system would learn from characters (or speech).

2. The Benchmark Tasks

  1. Which four benchmark tasks did Collobert et al. use?
    POS tagging (WSJ, per-word accuracy), chunking (CoNLL 2000, F1), named entity recognition (CoNLL 2003, F1) and semantic role labeling (CoNLL 2005, F1). The benchmark systems they compared with: 97.24%, 94.29, 89.31 and 77.92 respectively.
  2. What pattern did Collobert et al. observe between task difficulty and feature engineering?
    The harder the task (lower accuracies), the more engineered features the best systems used: POS needed few, while SRL systems relied on many parse-tree features (paths, voice, head words, subcategorization, multiple parse trees).

3. The Networks

  1. What is the general structure of the networks in “NLP (Almost) from Scratch”?
    A first layer maps each word to a feature vector; a second layer extracts features from a window of words or the whole sentence (as a sequence, not a bag of words); then standard layers, trained end to end by backpropagation, output one score per tag.

3.2 Transforming Words into Feature Vectors

  1. What is the lookup table layer?
    Words are indices into a dictionary \(\mathcal{D}\); the layer maps word \(w\) to the \(w\)th column of a trainable matrix \(W \in \mathbb{R}^{d_{wrd} \times |\mathcal{D}|}\). Other discrete features (e.g. capitalization) get their own lookup tables, and their vectors are concatenated.

3.3.1 Window Approach

  1. Describe the window approach network.
    To tag a word, take a fixed window of \(d_{win}\) words around it (padding at sentence edges), concatenate their lookup vectors, then apply Linear → HardTanh → Linear, giving one score per tag. HardTanh clips its input to \([-1, 1]\), a cheaper tanh.
    catsatonthematlinearHardTanhlinearone score per tag for on
    Each word is looked up in the shared table; the vectors are concatenated

3.3.2 Sentence Approach

  1. Why does SRL need the sentence approach rather than a window?
    A word’s role depends on a chosen predicate, which may lie outside the window. The sentence approach looks at the whole sentence, adding to each word features for its relative distance to the predicate and to the word being tagged.
  2. How does the sentence approach network turn a variable-length sentence into a fixed-size vector?
    Convolutional (time-delay) layers apply the same linear map to every window, giving local features per position; a max over positions then keeps, for each feature, its strongest value anywhere in the sentence. An average would make little sense, since most words don’t affect a given word’s role.

3.3.3 Tagging Schemes

  1. Which tagging scheme did Collobert et al. use for segment tasks, and what are its tags?
    IOBES for all tasks, the most expressive: B-X begins a segment, I-X is inside, E-X ends it, S-X is a single-word segment, O is outside. For chunking, a one-word NP is S-NP; longer NPs are B-NP … I-NP … E-NP. Output was converted back to IOB for evaluation.

3.4.1 Word-Level Log-Likelihood

  1. What is the word-level log-likelihood (WLL) criterion?
    Each word is classified independently: a softmax over the network’s tag scores gives \(p(i \mid x, \theta)\), and \(\log p(y \mid x, \theta) = [f_\theta]_y - \text{logadd}_j [f_\theta]_j\), where \(\text{logadd}_i z_i = \log \sum_i e^{z_i}\). It ignores dependencies between neighbouring tags.

3.4.2 Sentence-Level Log-Likelihood

  1. What is the sentence-level log-likelihood (SLL) criterion?
    A path of tags gets score \(s = \sum_t ([A]_{[i]_{t-1}, [i]_t} + [f_\theta]_{[i]_t, t})\), adding trained transition scores to network scores; the probability of the true path is its score normalized over all paths with logadd, computed in linear time by a forward recursion. Decoding uses Viterbi.
  2. How does SLL relate to a CRF?
    It maximizes the same likelihood as a linear-chain CRF, but with network scores instead of a linear model. The scores aren’t normalized per position, so they act like CRF potentials and avoid the label-bias problem; the non-linear network learns features for each task.

3.5 Supervised Benchmark Results

  1. How well did the purely supervised networks do?
    Behind the benchmarks: with SLL, POS 96.37 (vs 97.24), chunking 90.33 (94.29), NER 81.47 (89.31), SRL 70.99 (77.92). SLL beat WLL, mostly on chunking, NER and SRL.
  2. What was wrong with the word embeddings learned by supervised training alone?
    Nearest neighbours in the embedding space weren’t semantically related. Most parameters are in the 100,000 × 50 lookup table, and most words occur too rarely in labeled data to be trained well.

4.2 Ranking Criterion versus Entropy Criterion

  1. What language-model training criterion did Collobert et al. use instead of cross-entropy, and why?
    A pairwise ranking criterion: \(\sum_{x} \sum_{w \in \mathcal{D}} \max\{0, 1 - f_\theta(x) + f_\theta(x^{(w)})\}\), where \(x^{(w)}\) is the text window \(x\) with its centre word replaced by \(w\). The network should score real windows at least 1 above corrupted ones. It avoids normalizing over the vocabulary, and unlike entropy is not dominated by frequent phrases: rare but legal phrases matter for learning syntax.

4.3 Training Language Models

  1. How were the large ranking language models trained?
    On Wikipedia (631M words) and then Wikipedia plus Reuters RCV1 (852M words), with window size 11 and 100 hidden units, using a curriculum of growing dictionaries (5k up to 100k words), each initialized from the previous network. LM1 took about four weeks, LM2 three more. Hyperparameters were chosen by “breeding”.
  2. What is “breeding” in Collobert et al.’s model selection?
    Without enough compute for grid search, train \(k\) parameter settings in parallel for some days, keep the best by validation ranking loss, and start the next round from slight variations of the winners, initialized with their parents’ embeddings so training continues online.

4.4 Embeddings

  1. What did the language model embeddings look like?
    Nearest neighbours were syntactically and semantically related: France near Austria, Belgium, Germany; XBox near Amiga, PlayStation; reddish near greenish, bluish. Supervised-only embeddings had shown no such structure.

4.5 Semi-supervised Benchmark Results

  1. How were the unsupervised embeddings used for the supervised tasks, and how much did they help?
    The lookup tables of the supervised networks were initialized with the language model embeddings and then fine-tuned. Results with SLL below. The larger language model helped more, suggesting even more unlabeled data would help.
    taskbenchmarkNNNN + LM2
    POS97.2496.3797.20
    chunking94.2990.3393.63
    NER89.3181.4788.67
    SRL77.9270.9974.15

4.6 Ranking and Language

  1. Why did Collobert et al. think a ranking criterion could capture syntax?
    It resembles Harris’s (1968) operator grammars, which grade the acceptability of sentences with one word class varied and find sentence forms with the same gradings, revealing structure through acceptability comparisons rather than explicit hierarchy.

5. Multi-Task Learning

  1. How did Collobert et al. train several tasks jointly, and what did it give?
    Networks for different tasks share the lookup tables and first hidden (or convolution) layer, with task-specific last layers; training alternates examples from each task’s own data set. Gains were marginal; the most important “multi-task” component was the unsupervised learning of word embeddings.
  2. Why does discovering shared internal representations require joint training rather than joint decoding?
    Joint decoding combines separately trained models at test time, so their extra dependency paths can’t involve unobserved variables. Shared hidden representations are unobserved, so they can only be learned by training the models together.

6. The Temptation

  1. What happened when Collobert et al. added standard task-specific features?
    Moderate gains, reaching or passing the benchmarks: two-character suffixes for POS (97.29), the CoNLL gazetteer for NER (89.59), POS tags for chunking (94.32), chunk tags for SRL (74.72). Ensembles of ten networks gave small further gains.
  2. Why did a gazetteer help the NER network so much?
    Gazetteers contain multi-word entities; the network only had per-word representations. united and bicycle are probably non-entities alone, but United Bicycle may be one, which needs higher-level information.

6.5 Parsing

  1. How did parse-tree information help the SRL network?
    Charniak parse levels were fed as IOBES segment tags in extra lookup tables: level 0 (leaf phrases) added almost 1.5 F1, further levels less, up to 76.06, close to the 77.92 benchmark that used six parse trees. A network predicting level-0 segments (PT0) worked as well as the parser and better than chunk tags.

6.6 Word Representations

  1. How did the language model embeddings compare with Brown clusters?
    In the non-linear network they did at least as well as Brown cluster features on all tasks, and fine-tuning them helped further. In a convex (linear, CRF-like) setup with fixed representations the results were mixed, and non-convex was usually better for both.

6.7 Engineering a Sweet Spot

  1. What is SENNA?
    The standalone C implementation of the networks (about 2500 lines): under 150 MB of memory and under a millisecond per word for all tags. With a few features it matched or beat benchmarks (POS 97.29, chunking 94.32, NER 89.59; SRL 75.49), and ran far faster with much less memory than existing taggers, e.g. SRL in 51 s vs 6253 s.

7. Critical Discussion

  1. How did Collobert et al. answer the criticism “why abandon painfully acquired feature engineering expertise”?
    No single NLP task covers the goals of NLP, so engineering that doesn’t generalize across tasks is undesirable, though they acknowledge their debt to task-specific research. They chose neural networks for their ability to discover hidden representations with stochastic learning that scales linearly with data.

Source

  • Ronan Collobert, Jason Weston, Léon Bottou, Michael Karlen, Koray Kavukcuoglu and Pavel Kuksa. 2011. Natural Language Processing (Almost) from Scratch. In Journal of Machine Learning Research, pp. 2493–2537. https://www.jmlr.org/papers/v12/collobert11a.html