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
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), 1. Introduction, pp. 2493–2494
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), 1. Introduction, pp. 2493–2494
- 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).
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), 1. Introduction, pp. 2493–2494
2. The Benchmark Tasks
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), 2. The Benchmark Tasks, pp. 2494–2498
- 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).
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), 2. The Benchmark Tasks, pp. 2494–2498
3. The Networks
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), 3. The Networks, pp. 2498–2499
3.2 Transforming Words into Feature Vectors
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §3.2, pp. 2501–2502
3.3.1 Window Approach
- 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.
Each word is looked up in the shared table; the vectors are concatenated - Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §3.3.1, pp. 2502–2503
3.3.2 Sentence Approach
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §3.3.2, pp. 2503–2504
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §3.3.2, pp. 2503–2504
3.3.3 Tagging Schemes
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §3.3.3, p. 2505
3.4.1 Word-Level Log-Likelihood
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §3.4.1, p. 2506
3.4.2 Sentence-Level Log-Likelihood
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §3.4.2, pp. 2506–2507
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §3.4.2, pp. 2506–2507
3.5 Supervised Benchmark Results
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §3.5, pp. 2508–2510
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §3.5, pp. 2508–2510
4.2 Ranking Criterion versus Entropy Criterion
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §4.2, pp. 2511–2512
4.3 Training Language Models
- 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”.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §4.3, pp. 2512–2513
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §4.3, pp. 2512–2513
4.4 Embeddings
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §4.4, pp. 2513–2514
4.5 Semi-supervised Benchmark Results
- 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.
task benchmark NN NN + LM2 POS 97.24 96.37 97.20 chunking 94.29 90.33 93.63 NER 89.31 81.47 88.67 SRL 77.92 70.99 74.15 - Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §4.5, pp. 2514–2515
4.6 Ranking and Language
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §4.6, pp. 2515–2516
5. Multi-Task Learning
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), 5. Multi-Task Learning, pp. 2516–2518
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), 5. Multi-Task Learning, pp. 2516–2518
6. The Temptation
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), 6. The Temptation, pp. 2518–2521
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), 6. The Temptation, pp. 2518–2521
6.5 Parsing
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §6.5, pp. 2521–2524
6.6 Word Representations
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §6.6, pp. 2524–2526
6.7 Engineering a Sweet Spot
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), §6.7, pp. 2526–2527
7. Critical Discussion
- 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.
- Collobert et al., 2011, Natural Language Processing (Almost) from Scratch (Journal of Machine Learning Research), 7. Critical Discussion, pp. 2527–2528
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