arXiv(opens in a new tab)Computer ScienceMay 2014Cited by 2 papers on PaperVantage

Manuscript Offprint

arXiv:1405.4053

Distributed Representations of Sentences and Documents

Quoc V. Le, Tomas Mikolov

Abstract

Many machine learning algorithms require the input to be represented as a fixed-length feature vector. When it comes to texts, one of the most common fixed-length features is bag-of-words. Despite their popularity, bag-of-words features have two major weaknesses: they lose the ordering of the words and they also ignore semantics of the words. For example, “powerful,” “strong” and “Paris” are equally distant. In this paper, we propose Paragraph Vector, an unsupervised algorithm that learns fixed-length feature representations from variable-length pieces of texts, such as sentences, paragraphs, and documents. Our algorithm represents each document by a dense vector which is trained to predict words in the document. Its construction gives our algorithm the potential to overcome the weaknesses of bag-of-words models. Empirical results show that Paragraph Vectors outperform bag-of-words models as well as other techniques for text representations. Finally, we achieve new state-of-the-art results on several text classification and sentiment analysis tasks.

1 Introduction

Text classification and clustering play an important role in many applications, e.g, document retrieval, web search, spam filtering. At the heart of these applications is machine learning algorithms such as logistic regression or K-means. These algorithms typically require the text input to be represented as a fixed-length vector. Perhaps the most common fixed-length vector representation for texts is the bag-of-words or bag-of-n-grams (Harris, 1954) due to its simplicity, efficiency and often surprising accuracy.

However, the bag-of-words (BOW) has many disadvantages. The word order is lost, and thus different sentences can have exactly the same representation, as long as the same words are used. Even though bag-of-n-grams considers the word order in short context, it suffers from data sparsity and high dimensionality. Bag-of-words and bag-of-n-grams have very little sense about the semantics of the words or more formally the distances between the words. This means that words “powerful,” “strong” and “Paris” are equally distant despite the fact that semantically, “powerful” should be closer to “strong” than “Paris.”

In this paper, we propose Paragraph Vector, an unsupervised framework that learns continuous distributed vector representations for pieces of texts. The texts can be of variable-length, ranging from sentences to documents. The name Paragraph Vector is to emphasize the fact that the method can be applied to variable-length pieces of texts, anything from a phrase or sentence to a large document.

In our model, the vector representation is trained to be useful for predicting words in a paragraph. More precisely, we concatenate the paragraph vector with several word vectors from a paragraph and predict the following word in the given context. Both word vectors and paragraph vectors are trained by the stochastic gradient descent and backpropagation (Rumelhart et al., 1986). While paragraph vectors are unique among paragraphs, the word vectors are shared. At prediction time, the paragraph vectors are inferred by fixing the word vectors and training the new paragraph vector until convergence.

Our technique is inspired by the recent work in learning vector representations of words using neural networks (Bengio et al., 2006; Collobert & Weston, 2008; Mnih & Hinton, 2008; Turian et al., 2010; Mikolov et al., 2013a; Mikolov et al., 2013c). In their formulation, each word is represented by a vector which is concatenated or averaged with other word vectors in a context, and the resulting vector is used to predict other words in the context. For example, the neural network language model proposed in (Bengio et al., 2006) uses the concatenation of several previous word vectors to form the input of a neural network, and tries to predict the next word. The outcome is that after the model is trained, the word vectors are mapped into a vector space such that semantically similar words have similar vector representations (e.g., “strong” is close to “powerful”).

Following these successful techniques, researchers have tried to extend the models to go beyond word level to achieve phrase-level or sentence-level representations (Mitchell & Lapata, 2010; Zanzotto et al., 2010; Yessenalina & Cardie, 2011; Grefenstette et al., 2013; Mikolov et al., 2013c). For instance, a simple approach is using a weighted average of all the words in the document. A more sophisticated approach is combining the word vectors in an order given by a parse tree of a sentence, using matrix-vector operations (Socher et al., 2011b). Both approaches have weaknesses. The first approach, weighted averaging of word vectors, loses the word order in the same way as the standard bag-of-words models do. The second approach, using a parse tree to combine word vectors, has been shown to work for only sentences because it relies on parsing.

Paragraph Vector is capable of constructing representations of input sequences of variable length. Unlike some of the previous approaches, it is general and applicable to texts of any length: sentences, paragraphs, and documents. It does not require task-specific tuning of the word weighting function nor does it rely on the parse trees. Further in the paper, we will present experiments on several benchmark datasets that demonstrate the advantages of Paragraph Vector. For example, on sentiment analysis task, we achieve new state-of-the-art results, better than complex methods, yielding a relative improvement of more than 16% in terms of error rate. On a text classification task, our method convincingly beats bag-of-words models, giving a relative improvement of about 30%.

References (32)

  • Neural probabilistic language models
  • A unified architecture for natural language processing: Deep neural networks with multitask learning
  • Natural language processing (almost) from scratch
  • Training Restricted Boltzmann Machines on word observations
  • Finding structure in time
  • DeViSE: A deep visual-semantic embedding model
  • Multi-step regression learning for compositional distributional semantics
  • Distributional structure
  • Exploiting generative models in discriminative classifiers
  • A neural autoregressive topic model
  • Learning word vectors for sentiment analysis
  • Statistical Language Models based on Neural Networks
  • Efficient Estimation of Word Representations in Vector Space
  • Exploiting similarities among languages for machine translation (opens arXiv in a new tab)
  • Distributed representations of phrases and their compositionality
  • Linguistic regularities in continuous space word representations
  • Composition in distributional models of semantics
  • Hierarchical probabilistic neural network language model
  • Seeing stars: Exploiting class relationships for sentiment categorization with respect to rating scales
  • Fisher kernels on visual vocabularies for image categorization
  • Large-scale image retrieval with compressed fisher vectors
  • Nature, 323(6088):533–536, 1986
  • Parsing natural scenes and natural language with recursive neural networks
  • Recursive deep models for semantic compositionality over a sentiment treebank
  • Modeling documents with deep boltzmann machines
  • Word representations: a simple and general method for semi-supervised learning
  • From frequency to meaning: Vector space models of semantics
  • Simple, good sentiment and text classification
  • Compositional matrix-space models for sentiment analysis
  • Estimating linear models for compositional distributional semantics
  • Combining heterogeneous models for measuring relational similarity
  • Bilingual word embeddings for phrase-based machine translation