Abstract
Word2vec (Mikolov et al., 2013) has proven to be successful in natural language processing by capturing the semantic relationships between different words. Built on top of single-word embeddings, paragraph vectors (Le and Mikolov, 2014) find fixed-length representations for pieces of text with arbitrary lengths, such as documents, paragraphs, and sentences. In this work, we propose a novel interpretation for neural-network-based paragraph vectors by developing an unsupervised generative model whose maximum likelihood solution corresponds to traditional paragraph vectors. This probabilistic formulation allows us to go beyond point estimates of parameters and to perform Bayesian posterior inference. We find that the entropy of paragraph vectors decreases with the length of documents, and that information about posterior uncertainty improves performance in supervised learning tasks such as sentiment analysis and paraphrase detection.
Introduction
In natural language processing, "paragraph vectors" (often known as doc2vec) are a popular way to map variable-length pieces of text—like sentences, paragraphs, or entire documents—into fixed-length, dense mathematical vectors. These vectors are then used as features for machine learning tasks.
However, standard paragraph vector models only provide a single "point estimate" for each text snippet. They fail to capture a fundamental intuition: we should be much more uncertain about the semantic meaning of a three-word sentence than a 500-word essay. Because paragraph vectors are local to specific, often short pieces of text (unlike word vectors, which are trained across an entire corpus), they are highly susceptible to uncertainty. This paper addresses this gap by reformulating paragraph vectors as latent variables within a Bayesian framework, allowing the model to quantify its uncertainty about a document's representation.
Methodology
The authors build upon a recently proposed Bayesian interpretation of the word2vec (skip-gram) model, extending it into a new generative model called Bayesian Paragraph Vectors (BPV).
The Generative Model
The model assigns Gaussian priors to global word embeddings ($U$), global context embeddings ($V$), and local paragraph vectors ($d_n$). When predicting if a word pair appears together in a specific document, the model calculates the probability using a sigmoid function applied to the dot product of the word vector and the sum of the context vector and the paragraph vector.
Two-Stage Inference
Fully Bayesian inference on massive text corpora is computationally expensive. To solve this, the authors use the probabilistic programming library Edward to perform a two-stage inference process:
- Global Variables: Maximum A Posteriori (MAP) estimation via stochastic gradient descent is used to find point estimates for the global word and context embeddings. Since these are shared across the whole corpus, their posterior distributions are expected to be sharp.
- Local Variables: Keeping the global vectors fixed, black-box Variational Inference (VI) is used to fit a Gaussian distribution to the local paragraph vectors. This yields both a mean (the embedding itself) and a variance (the uncertainty).
Experiments and Results
The model was evaluated on two standard NLP binary classification benchmarks: the IMDB Dataset (100k movie reviews for sentiment analysis) and the Microsoft Research Paraphrase Corpus (MSR) (5,801 sentence pairs for paraphrase detection).
By utilizing the full posterior distribution (mean + standard deviation) derived from Variational Inference (VI), the BPV model consistently outperformed the baseline MAP point estimates on supervised tasks:
- Sentiment Analysis (IMDB): VI achieved 87.0% accuracy, compared to 86.9% for MAP.
- Paraphrase Detection (MSR): VI achieved 71.0% accuracy, compared to 70.0% for MAP.
Key Insights
A key empirical finding is that uncertainty scales inversely with document length. The authors plotted the entropy (uncertainty) of the inferred paragraph vectors against document length. As the word count of a document increases, the entropy of its vector representation reliably and smoothly decreases.
Furthermore, the variance calculated by the Bayesian model contains useful signal. By concatenating the variational mean and the standard deviation into a single feature vector, downstream classifiers are given explicit information about how much they should "trust" the embedding.
Conclusion
The BPV model demonstrates that explicitly modeling the uncertainty of document embeddings provides a strictly better feature representation than point estimates alone. While absolute accuracy gains are modest, the approach offers a practical way to scale Bayesian deep learning in NLP. Future work could apply this Bayesian treatment to more sophisticated document embedding architectures.
Summary updated