Elamur Research

Neural Models for Documents with Metadata

Paper · 2018 · Dallas Card, Chenhao Tan and Noah A. Smith

Summary

A collection of articles can tell a different story depending on what a reader wants to know about it. In news coverage of immigration, a reader might want to find recurring subjects, identify which subjects tend to appear in favorable coverage, or see whether favorable and unfavorable articles use different words for the same subject. The dates and tone annotations attached to the articles help answer those questions, but each question asks the annotations to do a different job. Dallas Card, Chenhao Tan, and Noah A. Smith develop SCHOLAR, a framework for incorporating those distinctions into topic modeling.

SCHOLAR represents each document as a mixture of topics and uses that mixture to estimate which words the document contains. When the researchers want topics that help explain an annotation such as tone, they also ask the system to predict the annotation from the document representation. When they want to see how an observed attribute changes word choice, they give that attribute its own contribution to the word probabilities. They can also let that contribution vary by topic. A shared neural encoder estimates the topic mixture from the available inputs, allowing these choices to be explored with the same basic inference procedure.

Experiments on movie reviews, newsgroup posts, and Yahoo Answers documents examine how well the framework predicts words, discovers coherent topics, and classifies documents. On IMDB, the version with fixed pretrained word embeddings reaches an internal topic coherence score of 0.18, compared with 0.13 for latent Dirichlet allocation. Latent Dirichlet allocation has lower held-out perplexity on the same dataset. A sparsity penalty makes the vocabulary associated with each topic more selective, while lowering coherence in the reported comparison. In classification, both ways of using metadata outperform supervised latent Dirichlet allocation on all the reported datasets. The comparison with logistic regression varies by dataset.

The immigration study shows what the modeling choices mean in practice. Treating tone as a prediction target reveals which recurring subjects are associated with favorable coverage. Treating it as an observed input reveals differences in vocabulary within a subject, such as the prominence of “criminal” and “detainees” in opposing tone-specific variations. A combined analysis uses tone as a target and publication year as an input. It learns a representation in which nearby years tend to have similar effects on vocabulary, although the year inputs themselves carry no ordering. The study illustrates how the same collection can support several kinds of inquiry, each with a different interpretation of what its topics measure.

Deep dive: Neural Models for Documents with Metadata

SCHOLAR uses document metadata to guide topic discovery, explain differences in word choice, and predict labels from compact representations. · about 38 minutes to read

The problem and its context

What a topic represents

A document collection can contain more material than a reader can examine individually. Topic analysis offers a way to describe recurring content and to express how much of that content appears in a particular document. A researcher can inspect the words most strongly associated with a topic, then use the estimated topic proportions to find documents that give the topic particular prominence. The paper situates this kind of analysis in areas such as the digital humanities and political science, where the representation of the documents can be an object of study in its own right.

The authors explain the starting point through Latent Dirichlet Allocation, or LDA. Imagine a rectangular array of word counts, with a row for each document and a column for each vocabulary item. The array is large because it answers a separate question about every pairing of a document and a word. A topic representation describes its underlying structure with two smaller arrays. One associates documents with topics. The other associates topics with vocabulary items. A row in the document array specifies which topics contribute to that document. A row in the topic array specifies the words associated with that topic.

The probabilities in each such row are non-negative and add to one. That constraint gives a document representation a direct interpretation as a mixture. An increase in a topic's share changes its contribution relative to the others. At the vocabulary end, a distribution over words gives the reader a way to inspect what a topic captures. The paper also makes a probabilistic distinction between the observed counts and the mean parameters behind them. Thinking of the count array as a factorization target is a way to see the structure, while the generative account gives a role to variation in the observations.

The authors stress that the assumptions imposed on these arrays matter. A representation with unconstrained real-valued coordinates can also be used to produce normalized probabilities for words. The neural variational document approach they discuss uses that construction. Normalizing the predicted word scores, however, leaves the document coordinates themselves free to take values outside a mixture of topics. A probability distribution over words and a probability distribution over a document's topics are separate features of the architecture. For the kind of interpretation the authors want, they retain the latter as well as the former.

A topic representation is also a choice about which variation in a corpus deserves attention. When words alone determine that choice, themes emerge from patterns that help account for the text. Those patterns can be recognizable and still have little to say about a particular annotation. For example, an annotation may distinguish favorable from unfavorable tone, while a purely textual analysis organizes articles by the events or institutions they mention. There is no reason for the most prominent themes in the text to provide the most informative view of the annotation.

Two jobs for the same metadata

The paper calls attributes such as author, publication date, and rating metadata. It makes a further distinction based on the role the researcher assigns an attribute. A label is an outcome that the latent document representation helps predict. A covariate is an observed input that can affect the estimated probabilities of words or labels. The same field can take either role in separate analyses. What changes is the path by which that information enters the account of the document.

Supervised latent Dirichlet allocation, or SLDA, supplies the precedent for the label approach. In its simplified description, each document has a latent topic representation, and an observed response is generated conditional on that representation. A training procedure must then find topics that are useful for explaining both the words and the response. With ratings, for instance, a document representation can be assessed in part by whether it contains information that helps predict its rating. The topics still have a word-based interpretation, so the exercise connects a prediction task to a description of what the documents discuss.

Sparse additive generative modeling, or SAGE, supplies the precedent for a different question. It starts with a background level for each word and expresses topics as adjustments to those levels. An observed covariate can have adjustments of its own. Its effects can also depend on the topic. The distinction is between an attribute's broad association with vocabulary and the possibility that its association changes with the subject under discussion. Author ideology is the example the paper uses to motivate this distinction. It could have a general effect on the choice of words and a more specific effect on how an author writes about a given topic.

The structural topic approach discussed by the authors builds on SAGE and allows correlations among topics. In the paper's account, both approaches face practical restrictions on the ways they can efficiently use metadata. Another family of methods gives metadata a role earlier in the generative process. Dirichlet-multinomial regression, for instance, uses observed information to inform the prior over a document's topics. In that arrangement, metadata helps determine which mixtures are expected before the words are considered. This is a third placement of metadata, distinct from predicting an outcome from topics or adding an attribute's contribution to the word scores.

The placement matters when someone interprets the output. A label-based analysis of tone asks which mixtures carry information about tone. A covariate-based analysis that includes interactions can ask how the vocabulary associated with a topic changes with tone. A document prior informed by metadata would instead express expectations about the prevalence of topics conditional on that metadata. These inquiries can be motivated by the same collection of documents. Each needs a different set of parameters to express the answer.

Why changing the setup was costly

The authors identify inference as a practical obstacle. Once a topic analysis specifies a process by which documents could have been generated, it needs a way to work backward from the observations to the hidden topic representations. For LDA, the Dirichlet prior and multinomial likelihood have a mathematical relationship called conjugacy. In the paper's account, that relationship supports efficient inference. Altering the assumptions can remove this convenience and require a fresh derivation.

Changing the type of outcome in supervised LDA is one example. Choosing a different conditional distribution for the response also changes the inference procedure that has to handle it. SAGE loses conjugacy through its additive construction in word score space. Its authors used L-BFGS to optimize a variational bound, and the implementation restricted the covariate structure to maintain efficiency. In both cases, a change motivated by the data can reach beyond the scientific question into the mathematics of fitting the system.

SCHOLAR draws on the variational autoencoder to reduce that coupling. A neural encoder estimates the distribution of a document's hidden representation. A sampling construction lets gradients pass through the encoder's estimates, and automatic differentiation handles their propagation through the chosen decoder. The paper builds on earlier uses of this approach for documents and on work such as Stochastic Backpropagation and Approximate Inference in Deep Generative Models.

The goal is to make it practical to explore what happens when metadata takes different roles or when the analyst adds a new component. The paper also points to other structures from earlier research that might fit this approach, including the gradual change of topic vocabularies represented by Dynamic Topic Models. Its own temporal example takes a different route through publication-year covariates. The important distinction for understanding the framework is between the generative assumptions that give the outputs their meaning and the inference procedure used to estimate them.

The method, step by step

From a word count vector to a topic mixture

SCHOLAR has an encoder and a decoder. The encoder starts with the observed document and the metadata available for that document. It estimates a distribution for the document's hidden coordinates. During training, the system draws a sample from that estimated distribution and converts it into topic proportions. The decoder then uses those proportions, together with any observed covariates, to estimate word probabilities. A separate component estimates a label distribution when the configuration includes supervision.

The decoder also specifies a generative story. In that direction, a prior supplies the hidden coordinates, the topic proportions are obtained from them, and words and labels follow from the resulting representations. During fitting, the encoder helps answer the reverse question of which hidden coordinates could explain a particular observation. It does so with a shared set of parameters. A newly encountered document can therefore be encoded using relationships learned across the training collection.

How SCHOLAR fits a document with optional metadata

The steps in order.

How SCHOLAR fits a document with optional metadataStep 1: Count vocabulary items in the document1. Count vocabulary items in the documentStep 2: Encode counts and available metadata2. Encode counts and available metadataStep 3: Estimate a distribution over hidden coordinates3. Estimate a distribution over hidden coordinatesStep 4: Sample coordinates and normalize them into topic proportions4. Sample coordinates and normalize them into topic proportionsStep 5: Combine topics and covariates to score vocabulary items5. Combine topics and covariates to score vocabulary itemsStep 6: Predict the label when supervision is enabled6. Predict the label when supervision is enabledStep 7: Update parameters using the variational objective7. Update parameters using the variational objective

Suppose the document is a news article with an observed year and a tone annotation. For a combined analysis, the year can enter the part that controls word probabilities and the tone annotation can serve as an outcome. During training, the encoder can also see the annotation when inferring which hidden variables explain the document. That access is legitimate because the annotation is part of the observation whose joint probability the training procedure is trying to explain. At prediction time, the authors use a different input convention for an unknown annotation. Keeping these stages distinct helps explain how the same attribute can be observed during inference training and predicted on held-out documents.

The vocabulary sets the possible word outcomes. The encoder receives the counts for those vocabulary items as a vector, so repeated occurrences contribute to the input as counts. The decoder, given the document's representation, gives each token position the same underlying word distribution. Document order therefore plays no role in this construction. The units of analysis are document-wide patterns of word use and the document-level attributes that may help account for them.

A prior for the hidden coordinates

Let a corpus contain a document indexed by i. The paper denotes its word sequence by wᵢ, its length by Nᵢ, and its observed covariates and labels by cᵢ and yᵢ. The size of the vocabulary is V, and the number of topics is K. For each document, the generative process begins with a multivariate normal draw.

rᵢ ∼ 𝒩(r | μ₀(α), diag(σ₀²(α)))

Here rᵢ is the hidden vector for document i, and ∼ means that it is drawn from the distribution on the right. 𝒩 denotes a normal distribution and r stands for its vector-valued argument. μ₀(α) is the prior mean vector, σ₀²(α) gives the prior variances, and diag places those variances on the diagonal of the covariance matrix. α is the hyper-parameter used to determine the prior. A diagonal covariance matrix has zero off-diagonal entries, so the prior in hidden-coordinate space has no fitted terms for pairwise correlations.

The authors choose this prior to approximate the behavior of a symmetric Dirichlet prior while retaining a convenient way to sample for gradient-based inference. They use a Laplace approximation to set the Gaussian terms. Its mean for a coordinate is given by the following expression.

μ₀,ₖ(α) = 0

Here μ₀,ₖ is the prior mean for coordinate k, with k identifying a topic coordinate. α is the same hyper-parameter as in the prior, and 0 is the common center of the Gaussian coordinates.

σ₀,ₖ²(α) = (K − 1) / (αK)

Here σ₀,ₖ² is the prior variance for coordinate k. K is the number of topics, αK denotes the product of the prior hyper-parameter and that count, and 1 is the constant subtracted from K in the numerator. The same rule applies to every coordinate. These are fixed settings of the prior in the reported approach.

The draw still consists of unconstrained coordinates. To use them as topic proportions, the decoder applies a softmax transformation.

θᵢ = softmax(rᵢ)

θᵢ is the topic mixture for document i, rᵢ is its Gaussian-space representation, and softmax exponentiates each coordinate and divides it by the sum of the exponentiated coordinates. Thus each component of θᵢ contributes a share of the whole. This probability simplex is the set of non-negative vectors whose entries add to one. Applying softmax to Gaussian coordinates is what gives the document mixture a logistic normal prior.

The two spaces serve different purposes. An analyst can read a value in θᵢ as a document's relative membership in a topic. The inference network works in the space of rᵢ, where it can describe uncertainty using a mean and a diagonal covariance. The decoder crosses from one space to the other whenever it needs topic proportions.

How topics and covariates score words

The general framework lets the researcher choose a function that translates topic proportions and covariates into word scores.

ηᵢ = f_g(θᵢ, cᵢ)

ηᵢ is the vector of vocabulary scores for document i. f_g is the chosen word generation network, θᵢ contains the document's topic proportions, and cᵢ contains its observed covariates. The scores become word probabilities after a softmax. In the experiments, the authors use a particular additive form because the terms of the sum can be inspected separately.

ηᵢ = d + θᵢᵀB + cᵢᵀBᶜᵒᵛ + (θᵢ ⊗ cᵢ)ᵀBⁱⁿᵗ

d is a vector of length V that represents background log frequencies across the vocabulary. B is the topic-by-word weight matrix, and θᵢᵀB combines its rows in proportion to the topics in document i. The superscript ᵀ denotes transpose so that the multiplying vector is oriented as a row. Bᶜᵒᵛ is the covariate weight matrix, and cᵢᵀBᶜᵒᵛ gives the vocabulary adjustments associated directly with the observed covariates. ⊗ forms the vector of pairwise products between topic proportions and covariate entries. Bⁱⁿᵗ is the weight matrix for those products, so the final term gives adjustments specific to combinations of a topic and a covariate. Each term contributes to the same V word scores.

The background provides a common starting point for every document. In a corpus where a word is generally frequent, the background can assign it a high score without requiring the topic weights to do so repeatedly. An entry in a topic row of B can therefore be read as an adjustment from the background. Adjustments can be positive or negative. Once a softmax normalizes the full score vector, the resulting probability of any word also depends on the scores assigned to the other words.

The covariate term answers a different question. With a categorical input represented by a vector with one active entry, that term can give the category its own vocabulary adjustments. The interaction term can give different adjustments to that same category depending on the document's topic mixture. A general tone effect, for example, can account for a tendency that cuts across the collection. An interaction can express that a tone difference is particularly visible when a document discusses enforcement or another specific subject. The reported immigration analysis examines such interactions directly.

The probability of an observed word follows from the normalized score vector.

wᵢⱼ ∼ p(w | softmax(ηᵢ))

wᵢⱼ denotes the word at position j in document i, and w denotes a possible vocabulary outcome. p is the word distribution specified by the normalized scores. softmax(ηᵢ) converts the values in ηᵢ into the probabilities of those outcomes, and ∼ marks the token as a draw from that distribution. The same probabilities govern every position in the document. In a likelihood calculation, a word therefore contributes its log probability as many times as it occurs.

This construction changes how topic weights work compared with LDA. LDA combines distributions over vocabulary items using the topic mixture. In the experimental SCHOLAR decoder, the weighted combination is formed in word score space and then normalized. A row of topic weights in the additive decoder is thus most directly interpreted as a pattern of deviations, while a word probability is defined by the combined and normalized scores. That difference matters when reading the most prominent words in a base topic alongside the most prominent words of a covariate interaction.

How the label enters the generative story

The label component uses a separate network to determine a conditional distribution over the document's outcome.

yᵢ ∼ p(y | f_y(θᵢ, cᵢ))

yᵢ is the observed label for document i, and y denotes a possible outcome. f_y is a multilayer network that takes the topic proportions θᵢ and any covariates cᵢ. Its output specifies the parameters of the conditional distribution p, and ∼ means that the observed label is treated as a draw from it. For categorical responses, the output is used to assign probabilities to the available classes. The paper also describes the component as flexible enough to specify distributions for real-valued outcomes.

The label contributes to training because the estimated document representation has to explain it as well as the words. In a configuration without labels, the word likelihood supplies the reconstruction objective. With labels, there is also a penalty for assigning a poorly fitting conditional distribution to the observed outcome. A useful topic under supervision is consequently one that can play a part in describing the text and make the label easier to predict.

The framework allows parts of this construction to be omitted. With no metadata or sparsity, the paper relates the resulting architecture to ProdLDA with an explicit background. With a supervised decoder, no covariates, and the appropriate LDA-style word parameterization and prior on the topic matrix, the authors describe a counterpart of SLDA that uses a logistic normal document prior. Conversely, retaining additive covariate effects while omitting labels gives the structure that motivates the comparison to SAGE. These relationships involve choices about how word probabilities are obtained as well as choices about which metadata are visible.

The authors also note a covariate-only construction in which latent topics are omitted altogether.

p(wᵢⱼ | cᵢ) ∝ exp(d + cᵢᵀBᶜᵒᵛ)

p(wᵢⱼ | cᵢ) denotes the word probability conditional on the covariates for document i. ∝ means that the exponentiated scores on the right are proportional to those probabilities before normalization. exp is applied to the vocabulary scores, d is the background, and cᵢᵀBᶜᵒᵛ is the contribution of the observed covariates. This option makes the roles of the additive terms especially clear. The background and covariate effects alone can provide a word distribution, while the full construction adds shared latent themes and, optionally, their interactions with the covariates.

Encouraging a selective vocabulary

A topic or metadata effect can assign a weight to every word in the vocabulary. For an analyst who wants to read the effect, it can help to concentrate the largest adjustments in a smaller set of words. SCHOLAR can encourage this property through a sparsity prior inspired by SAGE. The prior is applied to individual weights in the selected deviation matrices, including the topic and metadata terms.

τₘₙ ∼ Exponential(γ)

τₘₙ is a variance parameter associated with the weight at row m and column n of a deviation matrix. Exponential names the distribution over that positive parameter, γ is its hyper-parameter, and ∼ denotes a draw. The indices identify a particular deviation and vocabulary item within the selected matrix.

B*ₘₙ ∼ 𝒩(0, τₘₙ)

B*ₘₙ stands for the selected weight at row m and column n, with * indicating that the expression can apply to the different deviation matrices. 𝒩 is the normal distribution, 0 is its center, and τₘₙ is its variance. Centering the prior at zero favors small departures from the background. The variance can vary across weights, which allows large departures where the data support them.

In practice, the authors use an improper Jeffreys prior to avoid tuning the exponential hyper-parameter.

p(τₘₙ) ∝ 1 / τₘₙ

p(τₘₙ) stands for the prior density assigned to the positive parameter τₘₙ. ∝ denotes proportionality, and 1 / τₘₙ is its reciprocal. The paper describes a variational expectation-maximization procedure for handling the auxiliary parameters and maximum a posteriori estimation for the weights. The latter means that the procedure seeks point estimates of the weights while taking account of the prior.

1 / Bₘₙ²

This is the reciprocal-square quantity the paper gives for the expectation update in that procedure. Bₘₙ denotes the current weight at row m and column n, and ² indicates squaring. The implementation alternates computing the auxiliary expectations and taking stochastic gradient steps for the other parameters. In practical terms, sparsity is a fitting option that changes the estimated word deviations. It leaves the role of the topic mixture and the distinction between labels and covariates intact.

What the encoder estimates

In the generative direction, the prior supplies a hidden vector and the decoder produces distributions for the observations. Inference starts with the observations and seeks the posterior distribution of the hidden vector. The exact posterior involves accounting for all the plausible latent representations of the document. SCHOLAR uses an approximation with a form that the encoder can compute directly.

qΦ(rᵢ | wᵢ, cᵢ, yᵢ) = 𝒩(μᵢ, diag(σᵢ²))

qΦ is the approximate posterior, with Φ denoting all of its shared encoder parameters. rᵢ is the latent vector, while wᵢ, cᵢ, and yᵢ are the words, covariates, and labels available for the document. 𝒩 is the Gaussian family chosen for the approximation. μᵢ contains the encoder's estimated means and diag(σᵢ²) forms a covariance matrix from its estimated coordinate variances. The prior parameters are fixed across documents. The approximate posterior parameters are outputs computed separately for each document by the same network.

The encoder first transforms each input type and combines the results.

πᵢ = f_e([Wₓxᵢ; W꜀cᵢ; Wᵧyᵢ])

xᵢ is the vector of vocabulary counts corresponding to wᵢ. Wₓ is the matrix that maps those counts into a representation for the encoder. W꜀ and Wᵧ do the same for the covariate vector cᵢ and the label vector yᵢ. The brackets with separators denote concatenation, which places the transformed inputs next to one another. f_e is a multilayer perceptron that processes the concatenated vector, and πᵢ is its output for document i. The transformed metadata inputs in this equation are part of inference. They are distinct from the additive word score weights that the decoder uses to describe vocabulary changes.

The encoder then uses separate affine transformations for the means and the log variances.

μᵢ = Wμ πᵢ + bμ

μᵢ is the mean vector for document i. Wμ is the weight matrix that maps the shared representation πᵢ to the posterior means, and bμ is its bias vector. This is a prediction of the center of the document's approximate distribution in the unconstrained coordinate space.

log σᵢ² = Wσ πᵢ + bσ

σᵢ² is the vector of variances for document i, and log denotes an elementwise logarithm. Wσ and bσ are the matrix and bias for predicting these log variances from πᵢ. Predicting on the log scale makes it possible to obtain positive variances by exponentiation. The parameters of these transformations, the input matrices, and the perceptron are all part of Φ.

The word input matrix offers a way to incorporate information learned outside the corpus. A trainable matrix can be estimated along with the other parameters. Another option is to fill it with pretrained vectors and hold those vectors fixed. In that case the encoder receives a representation built from the vectors of the observed vocabulary items, weighted by their counts. Related words can then provide related signals to the network even when their patterns of occurrence in the corpus differ. The decoder continues to assign probabilities to vocabulary items. The pretrained information changes how the document is encoded.

The paper also describes using low-dimensional representations for metadata. In the combined immigration analysis, the authors represent publication years as positions in a learned space and associate deviations with its dimensions. A year encoded initially as a category can thus have word effects that resemble another year's effects if their learned positions are close. Embedding a category for inference and giving a dimension of the embedding a vocabulary deviation provide different ways to inspect what the category contributes.

What the training objective asks for

The encoder is trained to approximate the posterior induced by the prior and the decoder. The authors derive an evidence lower bound, or ELBO, for this purpose. A lower bound means that the optimized quantity sits below the relevant log evidence. Improving that quantity allows the procedure to fit the observations while taking account of the assumed prior over the document coordinates. For the configuration with labels and covariates, the per-document objective has the following form.

ℒ(wᵢ) = 𝔼_qΦ[Σⱼ₌₁ᴺⁱ log p(wᵢⱼ | rᵢ, cᵢ)] + 𝔼_qΦ[log p(yᵢ | rᵢ, cᵢ)] − D_KL[qΦ(rᵢ | wᵢ, cᵢ, yᵢ) ∥ p(rᵢ | α)]

ℒ(wᵢ) is the paper's notation for the document objective, which also uses metadata when the configuration includes them. 𝔼_qΦ means expectation under the document's approximate posterior qΦ(rᵢ | wᵢ, cᵢ, yᵢ). Σⱼ₌₁ᴺⁱ sums across positions j from the first word to the document length Nᵢ. In the first expectation, log p(wᵢⱼ | rᵢ, cᵢ) is the log probability of the observed token given the latent coordinates and covariates. In the second, log p(yᵢ | rᵢ, cᵢ) is the log probability of the observed label under the same conditions. D_KL is the Kullback–Leibler divergence. The ∥ separates its two distribution arguments, the encoder's approximate posterior and the prior p(rᵢ | α) determined by α.

The first term rewards document representations that assign high probability to the observed words. The second gives a similar role to the label whenever the configuration includes it. Taking an expectation means that the objective evaluates plausible hidden coordinates under the encoder's distribution. The divergence term charges the approximation for departing from the prior. The encoder therefore has an incentive to move its estimates away from the prior where doing so helps explain the actual observations.

The likelihood expectations are approximated by sampling. To keep the sampling operation compatible with gradient-based optimization, the paper separates the source of randomness from the quantities estimated by the encoder. It first draws noise from a standard multivariate normal distribution.

ε⁽ˢ⁾ ∼ 𝒩(0, I)

ε⁽ˢ⁾ is the noise vector for sample s. 𝒩 is the multivariate normal distribution, 0 denotes its zero mean, and I is the identity covariance matrix. The draw is independent of the encoder parameters. It is converted into a sample of the document's hidden coordinates by shifting and scaling it.

rᵢ⁽ˢ⁾ = gΦ(wᵢ, cᵢ, yᵢ, ε⁽ˢ⁾) = μᵢ + σᵢ · ε⁽ˢ⁾

rᵢ⁽ˢ⁾ is the resulting sample for document i, and gΦ denotes the deterministic computation that takes the words, covariates, labels, and sampled noise to that result. μᵢ is the vector of estimated means. σᵢ is the vector of standard deviations obtained from the predicted variances, and · here means elementwise multiplication. Given the noise, the sample remains a differentiable function of the means and standard deviations. The reparameterization trick is this separation of a fixed noise draw from the differentiable transformation that gives it the desired distribution.

For training, the authors replace the expected likelihood terms with their values at a single sample. They can evaluate the divergence between the Gaussian distributions in closed form.

ℒ(wᵢ) ≈ Σⱼ₌₁ᴺⁱ log p(wᵢⱼ | rᵢ⁽ˢ⁾, cᵢ) + log p(yᵢ | rᵢ⁽ˢ⁾, cᵢ) − D_KL[qΦ(rᵢ | wᵢ, cᵢ, yᵢ) ∥ p(rᵢ | α)]

≈ indicates the sample-based approximation to the objective ℒ(wᵢ). The sum over j gives the log probabilities of the observed words, and the next term gives the observed label's log probability. Both use the same sampled latent vector rᵢ⁽ˢ⁾ and observed covariates cᵢ. The final term compares the whole approximate posterior qΦ with the prior at α, exactly as in the expectation form of the objective. The authors mention averaging over more draws as another option.

Stochastic gradient updates can now fit the encoder parameters, the word and label generation networks, and the selected deviation weights. This is the step that makes the setup adaptable. Changing which covariates are used, including or excluding interactions, or choosing a different label distribution changes the computed objective. The general procedure of sampling a differentiable representation and optimizing the bound still applies. Sparse configurations add the auxiliary update described above.

How unseen documents are handled

For an unseen document, the encoder can estimate the posterior parameters with a forward pass. A conventional variational procedure of the kind discussed in the paper would keep the global topics fixed and carry out a separate optimization to obtain the variational parameters for the new document. The shared encoder supplies those parameters directly from the new inputs. In an analysis without a label target, the paper describes supplying the document's counts and any observed covariates.

A supervised configuration has to handle the absence of the target label at test time. The authors describe an option in which the decoder is fixed after fitting and the encoder is retrained to operate without labels. In the reported experiments they use a simpler convention. Training categorical labels are represented by one-hot vectors, which have a single active category. At test time the encoder receives an all-zero label vector. The label decoder then predicts from the inferred representation and any available covariates.

ŷᵢ = argmaxᵧ∈𝒴 p(y | rᵢ, cᵢ)

ŷᵢ is the predicted label for document i. 𝒴 is the set of possible labels, y is a candidate, and argmax returns the candidate with the highest value of the expression that follows. p(y | rᵢ, cᵢ) is the conditional label probability evaluated using the inferred latent representation and observed covariates. This use of rᵢ includes its conversion to topic proportions for the label decoder.

A second prediction procedure trains with the category as a covariate. At test time the category is unknown, so each candidate category is placed in the covariate position in turn. The system then compares how well the candidate explains the words.

ŷᵢ = argmaxᵧ∈𝒴 Σⱼ₌₁ᴺⁱ log p(wᵢⱼ | rᵢ, eᵧ)

ŷᵢ is the prediction, argmax searches the candidate labels y in 𝒴, and the sum ranges over the Nᵢ positions of document i. wᵢⱼ is the observed word at position j, rᵢ is the document representation used to evaluate the word distribution, and eᵧ is the one-hot covariate vector for the candidate category y. log p provides the candidate's log probability for that word. The winning candidate is the one with the largest total word log probability.

The criteria answer different questions about the same text. In the supervised setup, the label decoder chooses which outcome is most probable given the representation. In the covariate setup, the word decoder chooses which candidate condition gives the best account of the observed vocabulary. The experiments use both routes to assess whether a compact topic representation can carry information useful for text classification.

Experiments and results

Datasets and measures

The experiments cover unsupervised topic discovery, classification, and exploratory analysis. Three collections serve as benchmarks: 20 Newsgroups, IMDB’s corpus of 50,000 movie reviews, and UIUC’s Yahoo Answers collection of 150,000 documents across 15 categories. The immigration study uses roughly 4,000 timestamped news articles and annotations marking their tone as favorable or unfavorable towards immigration. The movie-review and newspaper data are associated with Learning Word Vectors for Sentiment Analysis and The Media Frames Corpus.

The unsupervised experiments use several criteria because prediction and interpretation place different demands on the topics. Held-out perplexity summarizes how well the system assigns probability to words in unseen documents. Lower values correspond to better performance on that measure. For SCHOLAR, the paper derives the reported perplexity from the variational bound, so the result is an upper bound. The test concerns the probability of the observed words over the document and includes the influence of the whole predicted vocabulary distribution.

Topic coherence instead focuses on the top 10 words of each topic. The authors use NPMI to score the association among those words. They report an internal measure based on the test documents and an external measure based on a decade of articles from English Gigaword. The internal version asks how well the selected words fit together within the collection at issue. The external version checks them against a separate source of word associations. The two evaluations give different contexts for a numerical assessment of coherence. This use of word associations belongs to the line of research represented by Automatic Evaluation of Topic Coherence.

The unsupervised table also reports sparsity for each configuration. Sparsity is of interest because the additive formulation lets an analyst inspect deviations from the general vocabulary, and a selective set of weights can make that inspection easier. Classification has a separate measure, test accuracy, which reflects the proportion of held-out documents assigned the correct category. It evaluates the outcome prediction directly. A useful representation can score differently on any of these measures because each examines a different part of its behavior.

For LDA the authors use Mallet. The SAGE and SLDA comparisons use the implementations from the authors of those approaches. SCHOLAR is implemented in TensorFlow, and the authors also make a preliminary PyTorch implementation of its core available. For the unsupervised experiments they follow the ProdLDA setup for learning rate, momentum, batch size, and training duration. The classification experiments build on that setup while selecting the training duration for the new system using development data.

Topic coherence and word prediction on IMDB

The main unsupervised comparison uses IMDB with a 5,000-word vocabulary and 50 topics. It includes LDA, SAGE, and the neural variational document approach, abbreviated NVDM. Within SCHOLAR, it compares a configuration without the background, the basic configuration with the background, a version with fixed pretrained word vectors, and a sparsity-regularized version. Labels and covariates are omitted throughout this comparison. Thus the experiment isolates the behavior of the topic analysis before the supervised and metadata-conditioned uses of the framework.

Internal topic coherence on held-out IMDB reviews

Fixed pretrained word vectors give SCHOLAR the highest internal coherence in the comparison.

Internal topic coherence on held-out IMDB reviewsLDA: 0.13LDA0.13SAGE: 0.12SAGE0.12NVDM: 0.06NVDM0.06SCHOLAR without background: 0.09SCHOLAR without background0.09SCHOLAR: 0.14SCHOLAR0.14SCHOLAR with fixed word vectors (this paper): 0.18SCHOLAR with fixed word vectors (thispaper)0.18SCHOLAR with sparsity regularization: 0.10SCHOLAR with sparsity regularization0.10
The numbers
System or settingNPMI
LDA0.13
SAGE0.12
NVDM0.06
SCHOLAR without background0.09
SCHOLAR0.14
SCHOLAR with fixed word vectors (this paper)0.18
SCHOLAR with sparsity regularization0.10

The basic version of SCHOLAR scores 0.14 for internal coherence on held-out IMDB reviews, compared with LDA's 0.13. On the external Gigaword measure for those IMDB topics, the basic version scores 0.13 and LDA scores 0.14. The results make the choice of reference corpus relevant when describing whether the topics are more coherent. With fixed pretrained word vectors, SCHOLAR reaches 0.18 internally and 0.17 externally, the highest scores in the IMDB comparison for both measures.

Held-out word perplexity on IMDB reviews

LDA has the lowest perplexity, and the configuration with the strongest topic coherence has higher perplexity than basic SCHOLAR.

Held-out word perplexity on IMDB reviewsLDA: 1508LDA1508SAGE: 1767SAGE1767NVDM: 1748NVDM1748SCHOLAR without background: 1889SCHOLAR without background1889SCHOLAR (this paper): 1905SCHOLAR (this paper)1905SCHOLAR with fixed word vectors: 1991SCHOLAR with fixed word vectors1991SCHOLAR with sparsity regularization: 2185SCHOLAR with sparsity regularization2185
The numbers
System or settingperplexity
LDA1508
SAGE1767
NVDM1748
SCHOLAR without background1889
SCHOLAR (this paper)1905
SCHOLAR with fixed word vectors1991
SCHOLAR with sparsity regularization2185

LDA's held-out IMDB perplexity is 1508, compared with 1905 for the basic SCHOLAR configuration. The word-vector configuration has perplexity of 1991 on the same split. Its advantage on the coherence calculation therefore comes with a higher perplexity value than the other unregularized SCHOLAR settings in the comparison. The contrast between the measures is also visible for NVDM. Its perplexity is 1748, while the coherence of its IMDB topics is 0.06 internally and 0.04 externally. The result illustrates how a distribution that assigns relatively high probability to the held-out text can yield a less closely associated set of top words.

SAGE has reported sparsity of 0.79 on IMDB and the regularized SCHOLAR configuration has 0.58. The other configurations in the unsupervised table have reported sparsity of 0. The sparsity-regularized SCHOLAR topics have internal coherence of 0.10 and external coherence of 0.12. SAGE has 0.12 on each coherence measure. These results give different rankings according to whether the objective is to restrict word deviations, obtain associated top words, or predict held-out words. The authors also report that the fixed-vector configuration gives the strongest internal coherence among the evaluated settings on Yahoo Answers and ranks next to the best on 20 newsgroups.

Classifying documents

For the classification comparison, the authors use a random 20% of the training data as development data to tune the number of training epochs for SCHOLAR. They use development data to tune the regularization of the logistic regression baseline as well. The results are test accuracies. The 20 newsgroups setup uses a vocabulary of 2000 and 50 topics. IMDB uses a vocabulary of 5000 and 50 topics. Yahoo Answers uses a vocabulary of 5000 and 250 topics.

The comparison includes SLDA, SCHOLAR trained with the category as a label, SCHOLAR trained with the category as a covariate, and logistic regression with ℓ₂ regularization. SLDA provides a comparison with another method designed to learn label-relevant topics. Logistic regression provides a direct classification baseline. The two SCHOLAR settings test whether a category is more usefully estimated from a predictive label component or through the words the category helps explain.

Test classification accuracy on IMDB movie reviews

The covariate configuration matches logistic regression and the label configuration performs close to both.

Test classification accuracy on IMDB movie reviewsSLDA: 0.64SLDA0.64SCHOLAR with labels: 0.86SCHOLAR with labels0.86SCHOLAR with covariates (this paper): 0.87SCHOLAR with covariates (this paper)0.87Logistic regression: 0.87Logistic regression0.87
The numbers
System or settingaccuracy
SLDA0.64
SCHOLAR with labels0.86
SCHOLAR with covariates (this paper)0.87
Logistic regression0.87

On 20 newsgroups, the test accuracy is 0.60 for SLDA, 0.67 for the label-based SCHOLAR configuration, 0.71 for the covariate-based configuration, and 0.70 for logistic regression. The ordering changes on Yahoo Answers. There the corresponding test accuracies are 0.65, 0.73, 0.72, and 0.76. IMDB gives logistic regression and covariate-based SCHOLAR the same reported test accuracy of 0.87, with the label-based system at 0.86 and SLDA at 0.64.

Both SCHOLAR configurations exceed SLDA's test accuracy on every dataset in the table. The comparison between the two SCHOLAR configurations depends on the corpus, and so does the comparison with logistic regression. The authors' aim is to assess whether limited-dimensional topic representations can be useful for prediction while retaining a vocabulary-based description. On that question, the supervised comparison matters because it shows that the topic-based systems can carry information relevant to the category. Accuracy alone gives no account of which words or topics provide that information.

Exploring news coverage of immigration

The immigration analysis uses 8 topics to make the outputs easy to present. The paper fits separate configurations to the same collection so it can ask different questions about the relationship between annotation, publication year, and text. The evidence here consists of the structures the system learns and how the authors interpret them. The classification experiments provide the paper's quantitative test of label prediction.

In the first configuration, tone is a label. The authors display prominent words from the learned topics and the predicted probability of favorable tone conditioned on each topic. One topic centers on arrests, charges, and enforcement operations. It has the weakest association with favorable tone among the topics shown. The analysis lets a reader inspect which kinds of subject matter the label decoder associates with the annotation. Its unit of comparison is the topic as summarized by its prominent vocabulary and its predicted relationship to tone.

In the second configuration, tone is a covariate and the decoder includes tone-by-topic interactions. The authors display the most prominent vocabulary of each base topic alongside the words most strongly associated with the unfavorable and favorable variations. In an enforcement-related topic, the unfavorable side includes “criminal,” while the favorable side includes “detainees.” Another contrast places “illegals” and “newcomers” on opposing sides. The interaction includes broader differences as well. A topic involving licenses and cards has an unfavorable variation with words such as “visas” and “smuggling,” while the favorable variation emphasizes words such as “citizenship” and “apply.”

These are comparisons between vocabulary adjustments conditional on a topic. Treating tone as a covariate gives the decoder a way to assign some variation to tone while retaining a base topic shared across tones. In the license example, the different sets of words are connected to the same subject through the base topic. Reading the interaction in this way gives a more specific description than a list of words that are generally frequent in favorable or unfavorable articles.

The combined configuration uses tone as a label and year of publication as a covariate. The input identifies each year by a one-hot vector, and the learned representation places the years in a two-dimensional continuous space. Each dimension has an associated word deviation, allowing the authors to inspect the vocabulary that grows more prominent along it. Adjacent years tend to be placed where they have similar deviations, even though the input encoding treats the years as separate categories.

The authors read one direction as a rough temporal shift. At one end, prominent terms include Clinton and INS. At the other, the associations shift toward Obama and ICE. They interpret another direction through vocabulary associated with 9/11, including “hijackers” and “attacks.” The placement of the years and the words with large deviations supply a joint reading of the temporal representation. The axes summarize variation in the article vocabulary under the chosen configuration.

What the ablations show

A shared background changes the visible topics

The comparison with and without the background term is a direct test of a decoder component. On held-out IMDB data, removing the background changes perplexity from 1905 to 1889. Internal topic coherence changes from 0.14 to 0.09. For the same IMDB topics evaluated against the external reference corpus, both configurations have coherence of 0.13. The authors describe the background as having little effect on perplexity and an important role in the quality of the topics. The internal and external scores show where that role appears in this particular comparison.

The paper connects these scores to recognizable words. Film and movie are common in IMDB reviews. With a background term, the decoder can allocate a corpus-wide score to words like these. A topic can then give large deviations to words that distinguish its content. Without the background, film and movie acquire more prominent topic weights. The authors also observe their prominence in LDA topics. This comparison gives a concrete interpretation of the architecture because it shows what disappears from the top of a topic list when the decoder has a shared place for common vocabulary.

The results also delimit the mechanism. The background changes how the decoder can distribute a word score among shared frequencies and topic deviations. That change is particularly visible in the words selected for inspection. A probability estimate for held-out text takes all vocabulary items into account, so a feature that changes the top words can have a smaller effect on perplexity. The evaluation captures the distinction between looking at a topic's leading words and looking at the probability assigned to a whole document.

Fixed word vectors and sparse weights do different work

The pretrained-vector comparison changes the encoder. It supplies lexical relationships learned from unlabeled text and keeps those vectors fixed while the rest of the system is trained. On IMDB, internal coherence is 0.18 for this configuration and 0.14 for the basic configuration. External coherence is 0.17 and 0.13, respectively. Held-out perplexity is 1991 with the fixed vectors and 1905 for the basic configuration. The reported comparison evaluates the combination of pretraining and fixing the word vectors. The measured gain is in the coherence of the inferred topics under the test used here.

This result is informative because the words are still generated as vocabulary outcomes. The method influences what the encoder can learn about documents by changing the representation from which it estimates their mixtures. A related pair of words can generate related input signals even if the words occupy distinct columns of the count array. The authors' interpretation is that such information can promote coherence. The experiment measures the output of the resulting topic analysis instead of identifying individual word similarities responsible for the gain.

Regularization changes a different part of the system. It encourages the deviation matrices to concentrate their effects on selected words. The reported IMDB sparsity increases from 0 for the basic system to 0.58 with regularization. Internal coherence is 0.10 for the regularized configuration compared with 0.14 for the basic one. The regularized configuration also has higher held-out perplexity, at 2185 compared with 1905. A simple principle follows for reading these scores. Sparsity describes the distribution of weights, while coherence depends on the associations among words that appear at the top of a topic. A set of deviations can be more selective without improving the latter measure.

SAGE supplies a related baseline with high sparsity, at 0.79 on IMDB. Its behavior supports the authors' observation that explicit sparsity can involve tradeoffs with the other metrics. The NVDM comparison highlights a separate design choice, the constraint on document coordinates. The authors attribute its weaker coherence to the absence of a topic simplex. That comparison involves a separate architecture, so it provides supporting evidence alongside the within-SCHOLAR comparisons of the background, embeddings, and regularization.

Training duration and the role of annotations

The paper reports a qualitative training-duration analysis. Running for more epochs tends to lower perplexity on held-out documents, while coherence tends to decline. This is another example of the metrics tracking different outcomes. A fitting trajectory that improves word probabilities can change which associations rise to the top of the topic lists. The paper gives the direction of the observed tendency, instead of an epoch-by-epoch record from which to choose a stopping point for a different collection.

The label and covariate configurations compare two routes to classification. On IMDB and 20 newsgroups, the covariate route has the higher accuracy of the two. On Yahoo Answers, the label route has the higher accuracy. Each configuration includes its own test-time decision rule. The observed differences therefore compare the combination of how the category is used during training and how a prediction is made with the fitted system. The change in ordering across datasets limits any claim that one route will generally be preferable for prediction.

The immigration study provides a complementary comparison of the same modeling choices. Tone as a label yields topic-level associations with the annotation. Tone as a covariate with interactions yields vocabulary differences within topics. Those outputs address different questions, even when the same annotation is involved. The combined configuration adds publication year and shows what can be inspected when an analysis uses both a label and a covariate. Its learned layout illustrates the choice of representation. The paper does not give a measured comparison between that layout and a version with independent effects for each year.

Limitations

Limits the authors identify

The authors qualify their claims about computational efficiency. Their implementation ran much faster than the SLDA and SAGE implementations in the experiments and was competitive with Mallet. They point out that a fair timing comparison depends on implementation differences, stopping tolerances, and the stochastic nature of their own procedure. The observation concerns the implementations and settings used in the paper. It gives practical context for the reported experiments without establishing a general ranking of algorithmic cost.

The authors also qualify the likelihood evaluation. SCHOLAR's reported perplexity uses the ELBO, yielding an upper bound. Readers comparing estimates across approaches should keep the estimation procedure in view, especially when interpreting close values. The paper's discussion of training duration and regularization further shows that choosing a configuration on the basis of perplexity alone can lead to a different choice than selecting on topic coherence or sparsity.

The candidate-search method for predicting a category used as a covariate has limits that follow from the decision rule. It evaluates possible category inputs by comparing the word probabilities they yield. The authors describe the procedure as useful for a small categorical prediction problem and caution about scaling to larger or more general label spaces. The direct label network offers a way to specify outcome distributions that do not fit a search over a small set of one-hot vectors. The classification results concern the categorical setups reported in the paper.

The Gaussian prior uses fixed parameters and a diagonal covariance. The authors suggest that a richer prior could learn relationships among topics, drawing an analogy to the correlated topic approach. They also identify a metadata-dependent document prior and the generation of word vectors as possible extensions. These are examples of how the architecture could be changed. The findings in the paper concern the prior, token decoder, and metadata placements the authors actually fit.

For immigration coverage, the authors suggest that a researcher interested in year-specific differences could dispense with the shared year embedding and estimate sparse interactions between topic and year. The published analysis instead uses the embedding as a compact way to examine temporal patterns. The suggestion clarifies that the scale of the desired comparison affects the parameterization. A low-dimensional layout pools information into shared directions, whereas the proposed year interactions would present a different view of the data.

Limits visible in the experimental setup

The word likelihood is based on document-level counts. This is suitable for finding recurring vocabulary and expressing how word probabilities vary with topics and metadata. The evidence for a tone-related difference is a shift in the importance of vocabulary within that construction. It does not directly identify who used the word, whether an article quotes that usage, or how a sentence conveys its stance. Those distinctions would require information that the document representation does not retain about the contexts of individual occurrences.

The coherence score covers associations among the top 10 words. It is an evaluation of topic vocabulary, informed by the choice of reference corpus. The main IMDB comparison itself shows that an internal gain need not appear in the external measure. The study of immigration also uses the authors' reading of the learned topics and deviations to assess their plausibility. These evaluations provide evidence about intelligibility at the level of prominent words. The paper does not report a reader study of whether people independently give the same interpretations to the supervised topics or to the metadata interactions.

The accuracy comparisons establish performance on the chosen splits, vocabularies, and topic counts. Each comparison is relevant to whether the representation helps on a defined prediction problem. The reported accuracy values contain no estimates of variation across repeated runs, which limits how precisely a reader can interpret the small gaps between configurations. On IMDB, for example, the paper can report that covariate-based SCHOLAR and logistic regression have the same displayed accuracy. More detailed claims about how frequently they perform equally would require additional measurements.

The immigration results are observational. Tone and year are attributes of a preexisting collection, and the inferred deviations describe associations in that collection. A contrast between two tone-conditioned sets of words can also reflect differences in the particular events, institutions, or people the articles cover. Sharing a base topic makes the comparison more focused, but a broad topic can still group texts whose circumstances differ. The displayed interaction words support a reading of the vocabulary as framing. They cannot establish what would happen if the tone of an otherwise identical article were changed.

The year plot has a similar boundary. The method learns associations between years and word use. The nearby placement of adjacent years is an observation the authors make from the learned space, and the mapping of particular terms onto events and institutions is their interpretation of its directions. The paper presents the result for the fitted corpus. It gives no evidence about predicting vocabulary in future years or tracking the changing meaning of a particular topic over time. The reported construction describes year-related deviations while keeping the broader topic analysis in view.

Finally, the experiments test selected alternatives within the framework. They show how the common inference procedure accommodates the configurations considered and give examples of changes to the input representation, the word decoder, and the supervision. The paper's broader flexibility claim is grounded in that shared construction. Empirical conclusions about another label distribution, a richer prior, or a different interaction design would require fitting and evaluating those choices in their own settings.

What came after

Multilingual Topic Classification in X: Dataset and Analysis cites Card, Tan, and Smith's paper. Its stated subject is a dataset and analysis for multilingual topic classification in X. The documented connection is the citation. The citation leaves open whether the later study reused SCHOLAR's encoder, its distinction between labels and covariates, or its additive account of vocabulary differences.

Cite

Cite as Dallas Card, Chenhao Tan and Noah A. Smith. 2018. Neural Models for Documents with Metadata. Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers).

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.18653/v1/p18-1189

@inproceedings{card2018neural,
  title = {{Neural Models for Documents with Metadata}},
  author = {Dallas Card, Chenhao Tan and Noah A. Smith},
  booktitle = {Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)},
  year = {2018},
  doi = {10.18653/v1/p18-1189},
  url = {https://doi.org/10.18653/v1/p18-1189}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/card-2018-neural-models-documents-metadata/