natural language processing (almost) from scratch.: Difference between revisions

From statwiki
Jump to navigation Jump to search
Line 139: Line 139:
= References =
= References =
R. Collobert, J. Weston, L. Bottou, M. Karlen, K. Kavukcuoglu and P. Kuksa. Natural Language Processing (Almost) from Scratch. Journal of Machine Learning Research, 12:2493-2537, 2011.
R. Collobert, J. Weston, L. Bottou, M. Karlen, K. Kavukcuoglu and P. Kuksa. Natural Language Processing (Almost) from Scratch. Journal of Machine Learning Research, 12:2493-2537, 2011.
K. Toutanova, D. Klein, C. D. Manning, and Y. Singer. Feature-rich part-of-speech taggingwith a cyclic dependency network.  InHLT-NAACL, 2003.
K. Toutanova, D. Klein, C. D. Manning, and Y. Singer. Feature-rich part-of-speech taggingwith a cyclic dependency network.  InHLT-NAACL, 2003.

Revision as of 19:22, 13 November 2015

[Please don't edit yet - updating section-by-section]

Overview

Most current systems address a particular natural language processing (NLP) task by applying standard statistical models to ad-hoc, task-specific features. These features are often output of preexisting systems. The authors argue that the goal of NLP is, ideally, is to translate natural language text into a data structure which fully and unambiguously describes the meaning of the task. In this light, the drawback of existing approaches is that their representation of the text is optimized for a specific task and is not necessarily helpful in developing a more general representation.

This paper describes creates a single learning system to perform four standard NLP tasks(described below), using minimal pre-processing and minimal existing linguistic knowledge.

Benchmark Tasks

Four standard NLP tasks were chosen for testing and comparison with other systems: part of speech labelling (POS), chunking (CHUNK), named entity recognition (NER), and semantic role labelling (SRL).

Part of Speech Labelling (POS)

The goal of part of speech labelling is to tag each word with its semantic role (verb, plural noun, adverb, etc.) The experimental setup is borrowed from Toutonova et. al (2003). Sections 0-18 of the Wall Street Journal (WSJ) data are used for training, sections 19-21 for validation, and sections 22-24 for testing.

Chunking (CHUNK)

Chunking (CHUNK) or shallow parsing is intended to break a sentence into its syntactic components (noun phrase, verb phrase, etc.). Each word is tagged with the single component it belongs to, sometimes encoded with separate tags for a word at the beginning of the component and a word in the middle of the component. Experimental setup was taken from the CONLL 2000 task and uses WSJ data.

Named Entity Recognition (NER)

In named entity recognition, words are tagged with a relevant category such as "person" or "location", and additionally, the tags reflect whether a word begins or is inside an entity. Experimental setup is taken from the relevant CONL 2003 task and uses Reuters data.

Semantic Role Labelling (SRL)

SRL aims to give a semantic role to a component of a sentence (in this case, identifying predicates of a verb). Words may have multiple tags if the sentence has multiple verbs. SRL was evaluated using the CoNLL 2005 shared task.

Network Design

Traditional NLP systems use hand-designed, task-specific features relying both on linguistic intuition and empirical testing as input to standard classification algorithms (for example, support vector machines). The approach in this paper is to minimally pre-process features and instead use a neural network trained end-to-end.


Notation and Hyper-Parameters

[math]\displaystyle{ \,f_\theta }[/math](.) denotes any neural network with parameters [math]\displaystyle{ \,\theta }[/math]. Any feed-forward neural network with L layers can be written as a composition of functions as follows: [math]\displaystyle{ \,f_\theta = f_\theta^L(f_\theta^{L-1}(...f_\theta^1(.)...)) }[/math].

[math]\displaystyle{ \,[A]_{i,j} }[/math] denotes the element of a matrix A at row i and column j.

[math]\displaystyle{ \,\langle A\rangle_i^{d_{win}} }[/math] denotes the matrix obtained by concatenating the dwin columns vectors around the ith column vector of a matrix A ∈ Rd1xd2. i.e., [math]\displaystyle{ \,[\langle A\rangle_i^{d_{win}}]^T = ([A]_{1,i-d_{win}/2} ... [A]_{d_1,i-d_{win}/2},...., [A]_{1,i+d_{win}/2} ... [A]_{d_1,i+d_{win}/2}) }[/math].

[math]\displaystyle{ \,\langle A\rangle_i^1 }[/math] is a special case which denotes the ith column vector of A.

[math]\displaystyle{ \,[x]_1^T }[/math] denotes the sequences of elements [math]\displaystyle{ \left\{ x_1, x_2, ... , x_T \right\} }[/math] and [math]\displaystyle{ [x]_i }[/math] denotes the ith element of the sequence.

[math]\displaystyle{ \,d_{wrd} }[/math] is the word vector size, given by the user.

[math]\displaystyle{ \,d_{wrd}^k }[/math] is the vector size for a feature k, given by the user.

[math]\displaystyle{ \,k_{sz} }[/math] is the window size, given by the user.

[math]\displaystyle{ \,n_{hu}^l }[/math] is the number of hidden units for the lth layer, given by the user.

Feature Vectors

Words are fed into the network as indices in a finite dictionary D. The first layer of the network maps each of the word indices to a feature vector.

For each word w ∈ D the lookup table layer LTw(.) gives a dwrd-dimensional feature vector representation:

[math]\displaystyle{ LT_W(.) = \langle W\rangle_w^1 }[/math]

Where W ∈ Rdwrdx|D|. is a matrix of parameters to be learnt.

For a sequence of words [math]\displaystyle{ \,[x]_1^T }[/math], the lookup table layer produces the following output matrix:

[math]\displaystyle{ LT_W([w]_1^T) = (\langle W\rangle_{[w]_1}^1 \langle W\rangle_{[w]_2}^1) ... \langle W\rangle_{[w]_T}^1) }[/math]

To add additional features, we can represent the word as K discrete features w ∈ D1×...×Dk, where Dk is the dictionary for the kth feature. Each feature is associated with a lookup table LTwk(.) with parameters Wk ∈ Rdwrdx|D|, and the outputs are concatenated to form the final feature vector.

[math]\displaystyle{ LT_{w^1,...,w^K}(w)= \left( \begin{array}{c} LT_{w^1}(w_1) \\ \vdots \\ LT_{w^2}(w_2)\end{array} \right) = \left( \begin{array}{c} \langle W\rangle_{[w]_1}^1 \\ \vdots \\ \langle W\rangle_{[w]_K}^1 \end{array} \right) }[/math]

Windowed Approach

This approach assumes the tag for a word depends mostly on its surrounding words. Given a word to be tagged, we feed a window of ksz words around the word of interest to the lookup table layer, which outputs a matrix of size dwrd×ksz. Finally, the columns of this output matrix are concatenated to use as input to the next layer.

[math]\displaystyle{ f_\theta^1 = \langle LT_W([w]_1^T) \rangle _t ^{d_{win}} = \left( \begin{array}{c} \langle W\rangle_{[w]_{t-d_{win}/2}}^1 \\ \vdots \\ \langle W\rangle_{[w]_{t}}^1 \\ \vdots \\ \langle W\rangle_{[w]_{t+d_{win}/2}}^1 \end{array} \right) }[/math]

The output from the first layer is fed to one or more linear layers:

[math]\displaystyle{ f_\theta^l = \langle W \rangle^l f_\theta^{l-1} + b^l }[/math]

Where [math]\displaystyle{ \,W^l \in R^{n_{hu}^l × n_{hu}^l-1} }[/math] and [math]\displaystyle{ b^l \in R^{n_{hu}^l} }[/math] are parameters to be trained.

Linear layers may be interleaved with layers which apply a hard hyperbolic tangent function over their inputs:

[math]\displaystyle{ \left[f_\theta^l\right]_i = HardTanh(\left[f_\theta^{l-1} \right]_i) }[/math]

Where HardTanh is defined as:

[math]\displaystyle{ HardTanh(x) = \left\{ \begin{array}{l} -1\ if\ x \lt -1 \\ x\ if\ -1 \leq x \leq 1 \\ 1\ if\ x \gt 1 \end{array} \right. }[/math]

Finally, the output size of the last layer is the number of tags for a particular task, and each output entry can be interpreted as a score for that tag.

File:nlp fig1.png

Sentence-Level Approach

The windowed approach described above is appropriate for tasks where only information about the surrounding words is needed, but is not appropriate for tasks like SRL where the appropriate tag for a word may depend on the whole sentence. A convolutional approach is taken to solve this problem.

The convolutional network produces features for each word in the sentence and for each verb in the sentence. For each word i, two extra features are added which encode the distance between i and the word to tag (i - posw), and i and the verb being considered (i - posv).

We can view this as generalizing the previous windowed approach. The tth column of the lth layer is given by:

[math]\displaystyle{ \langle f_\theta^l \rangle _t^1 = \langle W \rangle^l \langle f_\theta^{l-1} \rangle _t^{d_{win}} + b^l }[/math]

Where Wl is the same for all windows in the sequence. Convolutional layers may be stacked, in which case they must be separated by a non-linearity

The convolutional layers are followed by a max layer to force the output into a fixed-length feature vector:

[math]\displaystyle{ \left[ f_\theta^l \right]_i = \max_t \left[ f_\theta^{l-1} \right]_{i,t} \ \ \ \ 1 \leq i \leq n_{hu}^{l-1} }[/math]

The output of the max layer may then be used as input to standard linear layers (as described in the previous section).

File:nlp fig2.png

Results

Approach POS (PWA) CHUNK (F1) NER (F1) SRL (F1)
Benchmark Systems 97.24 94.29 89.31 77.92
NN+WLL 96.31 89.13 79.53 55.40
NN+SLL 96.37 90.33 81.47 70.99

The results given above compared two versions of the neural nets described above (one using word-level log likelihood for training and the other using sentence-level log likelihood) to benchmark results. Per-word accuracy is reported for the POS task, and the F1 score is reported for all other tasks.

Unlabelled Data

Discussion

Task-Specific Engineering

References

R. Collobert, J. Weston, L. Bottou, M. Karlen, K. Kavukcuoglu and P. Kuksa. Natural Language Processing (Almost) from Scratch. Journal of Machine Learning Research, 12:2493-2537, 2011.

K. Toutanova, D. Klein, C. D. Manning, and Y. Singer. Feature-rich part-of-speech taggingwith a cyclic dependency network. InHLT-NAACL, 2003.