# A Convolutional Neural Network for Modelling Sentences

Dynamic convolutional network models sentences by pooling several top activations

Nal Kalchbrenner, Edward Grefenstette, Phil Blunsom · arXiv · 2014-4-8

- **Problem** Sentence models struggle to relate words far apart and to handle any input length. Max-TDNN keeps one maximum per feature row, which discards order and most of the signal.
- **Method** The DCNN stacks wide convolutions with dynamic k-max pooling. Unlike max pooling, it keeps several top values in their original order, and the number kept depends on sentence length and layer depth.
- **Results** The DCNN reached 86.8 binary and 48.5 fine-grained accuracy on movie review sentiment, and 93.0 on six-way TREC question classification.

## Why a single maximum per row loses information

A sentence model must map inputs of different lengths onto one representation, and the features it uses have to come from words and short n-grams that recur across sentences. The Max-TDNN does this by running a narrow convolution over the sentence matrix and keeping the largest value in each feature row, so each row contributes a single number.

That one maximum cannot tell whether a feature fired once or several times, and it forgets the order in which the features occurred.

Widening the filters or stacking narrow convolutions extends the reach of the detectors, but it also neglects the margins more and raises the minimum length of an input. Pooling a row of length s minus m plus one down to one value can be excessive even for moderate sentence lengths. The aim is a pooling scheme that keeps several strong activations in their original order and lets the number kept depend on depth and sentence length.

## Wide convolution keeps the margins in play

A wide convolution treats positions outside the sentence as zeros, so a filter also responds at positions where it overlaps the sentence only partly. The output sequence then has length \\(s+m-1\\), where \\(s\\) is the sentence length and \\(m\\) the filter width. A narrow convolution keeps only full overlaps and has length \\(s-m+1\\), so its output is a subsequence of the wide output.

The difference matters most for wide filters, such as widths of 8 or 10, because in a narrow convolution the words at the margins are covered by fewer filter positions. A wide convolution also always produces a non-empty output, whatever the filter width and the sentence length. In the DCNN each layer begins with this operation, applied to the matrix of activations from the layer below.

## Dynamic k-max pooling and the pooling schedule

k-max pooling takes a sequence of length at least k and returns its k largest values, kept in their original order. Because the positions of the values are discarded but their order is kept, the operator records how often and how strongly a feature is active across the sentence. Only the topmost pooling is fixed; below it the value of k is computed from the sentence and the layer.

For layer \\(l\\) of \\(L\\) convolutional layers, the pooling size is \\(k\_l = \\max(k\_{top}, \\lceil \\frac{L-l}{L} s \\rceil)\\), where \\(s\\) is the sentence length and \\(k\_{top}\\) is fixed. Lower layers therefore keep more values for longer sentences, and no layer keeps fewer values than \\(k\_{top}\\).

The authors read the schedule as a model of how many values are needed to describe the progression of an l-th order feature across a sentence.

## Feature maps, folding and training

Each layer can compute several feature maps in parallel, and each new map sums wide convolutions over all the maps of the layer below, so the weights form an order-4 tensor. Folding is a cheaper way to let rows interact than making the matrix of the convolution a full matrix instead of a sparse diagonal one. A folding layer adds every two rows of a feature map component-wise, so a map of d rows becomes a map of d/2 rows without any new parameters.

The top layer is a fully connected layer with a softmax that gives a probability distribution over the classes. Training minimises the cross-entropy between predicted and true distributions, with an L2 term over the parameters, which are the word embeddings, the filter weights and the fully connected weights. The network is trained with mini-batches by backpropagation using the Adagrad update rule, computes convolutions with Fast Fourier Transforms and runs on a GPU.

## The induced feature graph and its contrast with parse trees

A node in one layer links to a node in the next layer when the lower node took part in computing the higher one, and nodes that pooling does not select are dropped. The result is an acyclic graph over the input with weighted edges and one top node, and without folding each row of the sentence matrix forms a subgraph that meets the others only at that top node.

Folding joins pairs of these subgraphs at lower layers, before the top node.

Because k-max pooling ranges over the whole sentence, features of words many positions apart can be drawn together, and a subgraph can be short and local or long and spread out. A recursive network follows an external parse tree and combines children at each node, so low-order features of single words can meet higher-order features of whole clauses.

## Movie review sentiment results

The experiments use the Stanford Sentiment Treebank, with 6920 training, 872 development and 1821 test sentences in the binary setting and the standard 8544, 1101 and 2210 splits in the fine-grained setting. The fine-grained task has five outcomes, from negative to positive with two intermediate levels. The vocabulary has 15448 words.

The DCNN reached 48.5 accuracy fine-grained and 86.8 binary. The strongest baseline in the table is RECNTN at 45.7 and 85.4, a recursive network with a tensor-based feature function that uses external structure from a parse tree. The Naive Bayes, SVM and NBoW rows reach between 40.7 and 42.4 fine-grained and between 79.4 and 81.8 binary, and the first four baseline rows are taken from Socher et al.

(2013b).

The Max-TDNN reached 37.4 fine-grained and 77.1 binary, below the NBoW in both settings. The authors attribute this most likely to the excessive pooling of max pooling, which discards most of the sentiment features of the words.

The binary DCNN uses filter widths of 7 and 5, a top pooling value k of 4 and 6 and 14 feature maps, while the fine-grained DCNN uses widths of 10 and 7, a top k of 5 and 6 and 12 maps. The three neural models use word vectors of dimension 48, randomly initialised.

## Question type classification results

The TREC questions dataset has six question types, with 5452 labelled training questions and 500 test questions. The best rows in the table are SVM at 95.0 and MAXENT at 93.6, and the DCNN reached 93.0. The NBoW reached 88.2 and the Max-TDNN 84.4, using unsupervised vectors.

The authors report that the difference between the DCNN and the other high-performing methods is not significant (p \< 0.09). The non-neural rows depend on hand-coded features and resources, such as POS tags, named entity tags, a CCG parser and WordNet.

For this smaller dataset the neural models use mostly the same hyperparameters as in the binary sentiment experiment, with word vectors of dimension 32 initialised from unsupervised embeddings. The DCNN uses one convolutional layer with filters of size 8 and 5 feature maps.

## Twitter sentiment with distant supervision

Models are trained on 1.6 million tweets labelled by the emoticon they contain and tested on about 400 hand-annotated tweets. Tweets are preprocessed as in Go et al. (2009) and lowercased, giving a vocabulary of 76643 word types. The architecture is the same as in the binary sentiment experiment, and the randomly initialised word embeddings have dimension 60.

The DCNN reached 87.4 accuracy, against 83.0 for MAXENT, 82.7 for BINB, 81.6 for SVM, 80.9 for NBoW and 78.8 for Max-TDNN. The three non-neural classifiers use unigram and bigram features, and their results are taken from Go et al. (2009).

The authors read the gap to the NBoW as evidence that capturing long n-grams and combining them hierarchically is beneficial.

## What the first-layer detectors respond to

The first-layer filters of the binary sentiment network have width 7, and there are 288 detectors. For each detector the authors ranked all 7-grams in the validation and test sets by activation.

The top 7-grams for four detectors include clear positive and negative sentiment detectors, and a detector for the particle 'not', which negates sentiment, and one for 'too', which strengthens it. Other detectors respond to 'all', 'or', 'with...that' and 'as...as', which the authors describe as patterns with syntactic, semantic or structural significance.

## Limitations

On TREC the DCNN's 93.0 is below SVM's 95.0 and MAXENT's 93.6, and the authors report the difference to the high-performing methods as not significant at p \< 0.09.

The question experiment uses a smaller training set with lower-dimensional unsupervised vectors, and the Twitter test set has about 400 hand-annotated tweets.

The sentiment and TREC baseline rows are taken from earlier work as the tables state, and the Twitter baselines come from Go et al. (2009), so they are not part of the same run.

The four experiments cover movie reviews, TREC questions and tweets, so the authors' claim that the DCNN applies to sentences from any language is not tested here.

## Paper info

- **Authors**: Nal Kalchbrenner, Edward Grefenstette, Phil Blunsom
- **Venue**: arXiv · Preprint
- **First published**: 2014-4-8
- **Added**: 2026-11-12
- **Updated**: 2014-4-8
- **Version**: v1
- **arXiv**: 1404.2188
- **Category**: cs.CL
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/1404.2188v1) · [PDF ↗](https://arxiv.org/pdf/1404.2188v1)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Nal Kalchbrenner, Edward Grefenstette, Phil Blunsom (2014). A Convolutional Neural Network for Modelling Sentences. arXiv:1404.2188v1. https://arxiv.org/abs/1404.2188v1

**BibTeX**

```
@misc{kalchbrenner2014convolutional,
  title = {{A Convolutional Neural Network for Modelling Sentences}},
  author = {Nal Kalchbrenner and Edward Grefenstette and Phil Blunsom},
  year = {2014},
  eprint = {1404.2188},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1404.2188v1}
}
```

## Other paper commentary

- [In Defense of the Triplet Loss for Person Re-Identification](https://refivu.com/en/papers/9a193d31-bb38-4b07-8752-1bc32882197d-in-defense-of-the-triplet-loss-for-person.md)
- [Accelerating the Super-Resolution Convolutional Neural Network](https://refivu.com/en/papers/36219c92-ee60-4179-a5b4-065fdb8a7ff4-accelerating-the-super-resolution-convolutional-neural.md)
- [A Closer Look at Spatiotemporal Convolutions for Action Recognition](https://refivu.com/en/papers/2986e935-85a4-4ed6-b429-74af2338096c-a-closer-look-at-spatiotemporal-convolutions-for-action.md)
- [An Overview of Multi-Task Learning in Deep Neural Networks](https://refivu.com/en/papers/ec3f88d3-e942-4848-9ca0-597d43563c84-an-overview-of-multi-task-learning-in-deep.md)
- [FitNets: Hints for Thin Deep Nets](https://refivu.com/en/papers/1b4f0402-c689-4b22-8439-31aa101ca0fc-fitnets-hints-for-thin-deep-nets.md)
- [Temporal Fusion Transformers for Interpretable Multi-horizon Time Series Forecasting](https://refivu.com/en/papers/cb8f01c7-c9ff-43ea-879b-8d0eb97a6e96-temporal-fusion-transformers-for-interpretable-multi-horizon.md)
- [A large annotated corpus for learning natural language inference](https://refivu.com/en/papers/7e4b0424-7bbb-49b5-a1e2-69bf72d8d16b-a-large-annotated-corpus-for-learning-natural-language.md)
- [Learning to Prompt for Vision-Language Models](https://refivu.com/en/papers/c492cb20-7c19-4275-b139-f97eecec7359-learning-to-prompt-for-vision-language-models.md)
- [Soft Actor-Critic Algorithms and Applications](https://refivu.com/en/papers/27323517-0997-4493-a852-d624d86c70dd-soft-actor-critic-algorithms-and-applications.md)
- [Model Cards for Model Reporting](https://refivu.com/en/papers/9ad193b1-a348-4853-9835-2faeecfe0dc1-model-cards-for-model-reporting.md)
- [Segment Anything in Medical Images](https://refivu.com/en/papers/505368c7-a7cf-4cc6-b939-a8043e6cf7cd-segment-anything-in-medical-images.md)
- [Multi-Agent Actor-Critic for Mixed Cooperative-Competitive Environments](https://refivu.com/en/papers/cdbfc66c-b5f8-47cf-8741-06704dc59cc0-multi-agent-actor-critic-for-mixed-cooperative-competitive.md)

## Terms in this paper

- [Adagrad](https://refivu.com/en/terms/d6141e5e2b98-adagrad)
- [recurrent neural network](https://refivu.com/en/terms/7df8352fc823-recurrent-neural-network)
- [word embeddings](https://refivu.com/en/terms/750326b5ccc5-word-embeddings)
- [Max-TDNN](https://refivu.com/en/terms/6dcc81ec524f-max-tdnn)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/09b470f4-ff62-40ab-9355-2f9413d8271f-a-convolutional-neural-network-for-modelling-sentences)
