# Distributed Representations of Sentences and Documents

Paragraph Vector learns fixed-length vectors for sentences and documents

Quoc V. Le, Tomas Mikolov · arXiv · 2014-5-16

- **Problem** Bag-of-words features drop word order and ignore word meaning, so similar texts can get identical or badly spaced vectors. Phrase methods and parse-tree methods each fix only part of this.
- **Method** Paragraph Vector gives each paragraph its own dense vector, trained with shared word vectors to predict the words in that paragraph. Unseen text gets a vector by fitting only that vector while the rest stays frozen.
- **Results** On IMDB, Paragraph Vector reached a 7.42% error rate, compared to 8.78% for NBSVM-bi, the strongest bag-of-n-grams baseline.

## Why fixed-length text vectors stall

Most classifiers need each document as one fixed-length vector, and bag-of-words is the usual default. Its simplicity and often surprisingly good accuracy explain why it is so common. The catch is that word order disappears, so sentences with the same words get identical vectors. Bag-of-n-grams keeps some local order, but it runs into data sparsity and very high dimensionality.

The second gap is semantic, because bag-of-words gives no sense of distance between words. Under that representation, powerful and strong sit as far apart as powerful and Paris. Phrase-level methods try to fix this by averaging word vectors, which loses order again, or by combining vectors along a parse tree. Parse-tree methods work only for sentences, because they depend on parsing.

## A paragraph token as a memory of its topic

The key idea is to treat each paragraph as one more token that gets its own vector. That vector is trained together with shared word vectors to predict the next word, so it captures what the local context leaves out. The authors call this the Distributed Memory model, PV-DM, because the paragraph token acts as a memory of the topic.

The starting point is the word-vector setup in which several context word vectors are concatenated to predict the next word. Word-level training maximizes the average log probability of each word given its surrounding window, written as \\\[ \\frac{1}{T}\\sum\_{t=k}^{T-k}\\log p(w\_t \\mid w\_{t-k},\\dots,w\_{t+k}) \\\] The softmax score is \\( y = b + U\\,h(w\_{t-k},\\dots,w\_{t+k};W) \\), where h is built from the word vectors in W.

For paragraphs, the only change is that h is built from W and the paragraph matrix D.

Training uses stochastic gradient descent, with gradients from backpropagation. At each step a fixed-length context is drawn from a random paragraph, and the error gradient updates the parameters. Word vectors are shared across paragraphs, while each paragraph keeps its own vector. The model has N × p + M × q parameters, excluding the softmax, and sparse updates keep training efficient.

For speed, the softmax can be replaced by a hierarchical softmax over a binary Huffman tree, which gives frequent words short codes.

## Inferring vectors for unseen paragraphs

Training only yields vectors for paragraphs in the training corpus, so new text needs an inference step. The inference step adds a column to D for the new paragraph and runs gradient descent on that column alone. The word vectors W, the softmax weights U and b stay fixed during this step. The inferred vector then goes to a standard classifier such as logistic regression.

Because the rest of the model is frozen, every inferred vector lives in the space learned during training. The authors also argue that the vectors come from unlabeled data, so tasks with little labeled data can still use them. They add that the vectors keep word order in a small context, in the way an n-gram model with a large n would.

## PV-DBOW and the combined vector

The second variant, PV-DBOW, ignores the context words and keeps only the paragraph identifier as input. At each step it samples a text window, picks a random word from it, and trains the paragraph vector to predict that word. Only the softmax weights need storing, which makes this variant lighter than PV-DM. It is also close to the skip-gram model for word vectors.

PV-DM usually works well alone, but the authors recommend pairing it with PV-DBOW because the pair is more consistent across tasks. In the experiments, the classifier input concatenates the PV-DBOW and PV-DM vectors, each with 400 dimensions.

## Stanford Sentiment Treebank: sentence-level results

The dataset has 11855 sentences from a movie review site, split into 8544 for training, 2210 for test and 1101 for validation. Its subphrases, 239,232 labeled phrases in total, are used as independent training sentences. The window size of 8 was chosen on the validation set, and word vectors are frozen at test time while sentence vectors are inferred.

On the positive versus negative task, Paragraph Vector reached a 12.2% error rate, compared to 14.6% for the Recursive Neural Tensor Network. On the five-way fine-grained task, the error was 51.3%, compared to 54.3% for the same baseline. The baseline numbers come from Socher et al., not from a rerun under the authors' own setup.

## IMDB: multi-sentence reviews

The IMDB set has 100,000 reviews, with 25,000 labeled training, 25,000 labeled test and 50,000 unlabeled training reviews. Word and paragraph vectors are learned on 75,000 documents, and the 25,000 labeled paragraph vectors feed a neural network with one hidden layer of 50 units. The window size of 10 words was selected by cross validation, and the test vectors are inferred with the rest of the network frozen.

Paragraph Vector reached a 7.42% error rate, compared to 8.78% for NBSVM-bi, the strongest bag-of-n-grams entry in the table. The authors say this is the only approach in the comparison that goes significantly beyond a 10% error rate. NBSVM-bi at 8.78% also falls below 10%, so the useful reading is the margin over that baseline rather than a unique crossing of the threshold.

PV-DM alone scored 7.63% error, and the PV-DM plus PV-DBOW combination reached 7.42%. Concatenation in PV-DM gave a better result than sum, which reached 8.06%.

## Information retrieval triplets

The data are the first 10 results for each of 1,000,000 popular queries, and each result is a snippet of a web page. Each triplet has two snippets from the same query and one random snippet from another query, and the method must place the same-query pair closer. An error is counted for each triplet where the method fails that distance ordering.

Bag-of-bigrams gets a learned weighting matrix that shrinks the first-second distance and enlarges the first-third distance. TF-IDF weighting worked better than raw counts, so only TF-IDF results are reported.

Paragraph Vector reached a 3.82% error rate, compared to 8.10% for bag-of-words and 7.28% for bag-of-bigrams. The weighted bag-of-bigrams variant reached 5.67%, and the paper reports a 32% relative improvement for Paragraph Vector. The authors read the margin over bag-of-words as evidence that the vectors capture semantics beyond word counts.

## Limitations

Paragraph Vector is expensive at test time, since computing vectors for the 25,000 IMDB test documents took about 30 minutes on a 16 core machine. The authors note that this test-time work can be run in parallel.

The experiments cover two sentiment datasets and one retrieval set built from search snippets. Baseline numbers for the sentiment tables are taken from earlier papers, so those comparisons are across papers. No experiment tests tasks beyond sentiment and this retrieval setup.

## Paper info

- **Authors**: Quoc V. Le, Tomas Mikolov
- **Venue**: arXiv · Preprint
- **First published**: 2014-5-16
- **Added**: 2026-11-11
- **Updated**: 2014-5-22
- **Version**: v2
- **arXiv**: 1405.4053
- **Category**: cs.CL · cs.AI · cs.LG
- **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/1405.4053v2) · [PDF ↗](https://arxiv.org/pdf/1405.4053v2)

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

Quoc V. Le, Tomas Mikolov (2014). Distributed Representations of Sentences and Documents. arXiv:1405.4053v2. https://arxiv.org/abs/1405.4053v2

**BibTeX**

```
@misc{le2014distributed,
  title = {{Distributed Representations of Sentences and Documents}},
  author = {Quoc V. Le and Tomas Mikolov},
  year = {2014},
  eprint = {1405.4053},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1405.4053v2}
}
```

## Other paper commentary

- [Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation](https://refivu.com/en/papers/39efa06e-40cb-4fbe-91f7-de5aa5b6269d-google-s-neural-machine-translation-system-bridging-the.md)
- [On the Properties of Neural Machine Translation: Encoder-Decoder Approaches](https://refivu.com/en/papers/63546f31-7951-40c2-8cd8-fccae107022a-on-the-properties-of-neural-machine-translation-encoder.md)
- [Enriching Word Vectors with Subword Information](https://refivu.com/en/papers/c9e8d8e6-e24f-4128-8771-cadeb8b6c17e-enriching-word-vectors-with-subword-information.md)
- [Training Verifiers to Solve Math Word Problems](https://refivu.com/en/papers/6eaa7788-f79e-40b8-87b7-3ca3217edfe9-training-verifiers-to-solve-math-word-problems.md)
- [Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translation](https://refivu.com/en/papers/a52e355d-5c49-4353-8d39-5013e656760c-learning-phrase-representations-using-rnn-encoder-decoder.md)
- [Effective Approaches to Attention-based Neural Machine Translation](https://refivu.com/en/papers/58ab56a7-1cd5-4c5e-be62-69ff9c1387c7-effective-approaches-to-attention-based-neural-machine.md)
- [TransUNet: Transformers Make Strong Encoders for Medical Image Segmentation](https://refivu.com/en/papers/28bfb581-8f1f-42dd-ab0d-1b3c56282f6a-transunet-transformers-make-strong-encoders-for-medical.md)
- [Accurate Image Super-Resolution Using Very Deep Convolutional Networks](https://refivu.com/en/papers/8f850d36-527c-4a2a-8e8a-5d7766bd5c35-accurate-image-super-resolution-using-very-deep.md)
- [Deep Inside Convolutional Networks: Visualising Image Classification Models and Saliency Maps](https://refivu.com/en/papers/d3437c7c-4a6a-4f65-b699-3116ccfbfdee-deep-inside-convolutional-networks-visualising-image.md)
- [An Empirical Evaluation of Generic Convolutional and Recurrent Networks for Sequence Modeling](https://refivu.com/en/papers/b568511a-a3c8-42b3-9fd2-bd1b072662ac-an-empirical-evaluation-of-generic-convolutional-and.md)
- [Artificial Intelligence: the global landscape of ethics guidelines](https://refivu.com/en/papers/d19d6be2-ce31-43ea-b84d-0b4bbe03543f-artificial-intelligence-the-global-landscape-of-ethics.md)
- [Machine Learning in Automated Text Categorization](https://refivu.com/en/papers/f3ed4c42-7556-47e0-bc36-a9acdd9bf6d0-machine-learning-in-automated-text-categorization.md)

## Terms in this paper

- [Stochastic Gradient Descent](https://refivu.com/en/terms/a49650824022-stochastic-gradient-descent)
- [backpropagation](https://refivu.com/en/terms/e09284f057ac-backpropagation)
- [Logistic Regression](https://refivu.com/en/terms/3551369d301a-logistic-regression)
- [sentiment analysis](https://refivu.com/en/terms/dcaa4b0924bc-sentiment-analysis)
- [hierarchical softmax](https://refivu.com/en/terms/3cdc16770ffd-hierarchical-softmax)
- [Skip-gram model](https://refivu.com/en/terms/7d1ed0f9f004-skip-gram-model)
- [Bag-of-words](https://refivu.com/en/terms/ab87ee9e2ea7-bag-of-words)
- [IMDB dataset](https://refivu.com/en/terms/2d33938220f9-imdb-dataset)
- [Paragraph Vector](https://refivu.com/en/terms/168cf8ac77ab-paragraph-vector)
- [PV-DBOW](https://refivu.com/en/terms/dd253beb24bd-pv-dbow)
- [Recursive Neural Tensor Network](https://refivu.com/en/terms/a28dec085ad2-recursive-neural-tensor-network)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/f945f364-5ce3-4c12-bc05-c40bf55f4f8d-distributed-representations-of-sentences-and-documents)
