Elamur Research

Sentiment Classification with Supervised Sequence Embedding

Paper · 2012 · Dmitriy Bespalov, Yanjun Qi, Bing Bai et al.

Summary

A review can contain the words a classifier expects to see in praise and still express disappointment. The order of nearby words helps resolve what the reviewer means. In this study of sentiment classification, the authors ask how to keep that local order without assigning a separate input feature to every phrase. Their answer is supervised sequence embedding, or SSE. It represents a phrase by combining learned vectors for its words, with a different vector for each position a word can occupy within the phrase. The same word in the same slot contributes the same vector wherever it occurs, so examples of different phrases can train shared parameters.

The system moves a window through a review, converts each window into a vector, and combines those vectors into a fixed-length representation. SSE gives every window equal weight. A variant called SSE-W learns a weighting curve based on where each window starts relative to the length of the review. A classifier predicts the review’s rating from the combined vector. Rating labels guide the learning of the phrase representation, the position weights in SSE-W, and the final classifier. The authors compare both versions with classifiers that use explicit phrase features.

On the Amazon test split, SSE-W achieves a macro-average error of 24.61% for the task with 4 rating labels, compared with 25.30% for SSE and 27.98% for the reported support vector machine baseline with phrase features. On TripAdvisor, when the neutral rating is included in the task with 5 labels, the corresponding errors are 40.54%, 42.88%, and 45.12%. The benefit of learning position weights is less consistent when the task is simply to tell positive reviews from negative ones. Uniform averaging actually gives the lower binary error on TripAdvisor.

The paper also tests the approach on Reuters news topics and examines what trained classifiers respond to in individual phrases. The topic results vary with the category, and the phrase examples show how short passages can carry competing evidence within a review. The strongest case for the method comes from the held-out classification results. They show that a representation learned from individual words in local context can compete with a large inventory of explicit phrase features, and that relative position can help when the classifier must distinguish finer grades of sentiment.

Deep dive: Sentiment Classification with Supervised Sequence Embedding

Supervised sequence embedding learns which short phrases and review positions help predict sentiment without building a dictionary of phrases. · about 35 minutes to read

The problem and its context

When the words are right but the evidence is wrong

The task belongs to text classification, where a system assigns a pre-defined label to a document. The labels can describe a topic, distinguish broad classes of opinion, or identify a particular rating. The paper situates sentiment alongside tasks with different label structures, including those in which a document can receive several labels and those in which labels form a hierarchy. For its review experiments, the authors start from an overall rating attached to each review. A review can discuss several aspects of the same hotel or product, and each aspect can elicit a different judgment. The target is the overall label associated with the review.

The paper motivates this problem through the growth of online reviews and other publicly expressed opinions. A classifier has to make decisions across many documents, each of which can vary in length, phrasing, and what it chooses to discuss. The text supplies several kinds of evidence at once. There may be a decisive recommendation, a few favorable remarks that qualify a complaint, or descriptions whose significance depends on nearby words. A representation determines which of those distinctions a classifier can see.

The familiar starting point is the bag of words. It gives each dictionary entry a coordinate and records its occurrence or frequency in a document. This converts documents of different lengths into vectors with the same layout. Earlier supervised classifiers often used this representation, and the paper identifies support vector machines as strong performers for text categorization and sentiment. The authors also describe earlier generative and discriminative approaches, along with semisupervised work that learns from both labeled and unlabeled documents. Text Classification from Labeled and Unlabeled Documents using EM is their example of the latter direction.

With individual words as features, positions disappear. A favorable adjective and a nearby negator both get counted. Their counts give no indication that the negator qualifies the adjective, or even that the words occur in the same part of a long review. The paper illustrates the problem with a favorable adjective qualified by negation and an intensifier. Keeping those words together gives a classifier an opportunity to distinguish the qualified phrase from the adjective used on its own.

An n-gram is a contiguous run of words of a specified length. A bag of n-grams extends the input vocabulary to include such runs. It preserves order inside each feature, so a sequence can get a different coefficient from another sequence made of the same words. At the document level, it still pools occurrences without tracking where they appeared. Its improvement over a word-only bag comes from giving the classifier a way to recognize local combinations.

Why a phrase dictionary creates a second problem

A phrase vocabulary makes local order visible at the price of a much larger feature space. The authors illustrate the scale with a word dictionary of size 10,000. Every slot in a phrase can take a word from that dictionary, so possible combinations multiply as another slot is added. The entries observed in a particular corpus occupy only part of that space. Even so, their number can make estimation and optimization difficult. A phrase can also occur too infrequently for its own feature to receive much training evidence.

Feature selection was a common response. A selection procedure scores candidate features and keeps a subset before the classifier is trained. The paper names information gain, chi-square, mutual information, and optimal orthogonal centroid selection among the choices. Its concern is practical. Which procedure is appropriate can depend on the corpus, and tuning the settings of a candidate procedure adds another validation problem. An explicit phrase vocabulary also establishes an all-or-nothing distinction at the input. A sequence with a retained feature can register as that feature, while an omitted sequence has to register through whatever smaller features remain.

The authors propose changing how a phrase is represented. An explicit phrase feature gives each retained sequence its own address. Their method gives an address to each word in each possible slot of a window. Phrases then share parameters whenever they have a word in the same slot. This creates a way to represent a sequence even if the system has never stored that exact phrase as a vocabulary entry. It also means that the effect of adding a word is constrained by what the system has learned about that word in the slot it occupies. A classifier with a dedicated feature for a particular expression can learn a separate coefficient for that expression. SSE instead has to capture the evidence through the word-and-slot vectors and their combination.

There is a separate question about where evidence occurs in the document. A reviewer may use the opening to state an immediate judgment or the ending to decide whether to recommend a hotel. The paper treats this as a hypothesis about sentiment classification. A bag of phrases cannot distinguish a phrase at the beginning from the same phrase near the end. The authors ask whether a classifier should weight the phrase differently in those locations, and whether review labels can teach it a shared pattern of weights.

Earlier ways of representing text in a latent space

The paper places SSE among techniques that express text using learned coordinates. A latent coordinate is part of an internal representation, with a value computed from the input. It need not correspond to an identifiable word or phrase. The authors discuss latent semantic indexing, probabilistic latent semantic indexing, and latent Dirichlet allocation as examples of unsupervised approaches to document representation. The dividing question for SSE is what governs the choice of coordinates. The representations here are trained to predict the labels of the designated task. A useful distinction for recognizing review sentiment could differ from one that explains broad similarities among documents.

The authors’ closest predecessor is Lookup Table Convolution, which they had already applied to sentiment classification. That technique first maps each word to a common lookup vector and then uses a separate projection to combine the vectors for a window. It establishes that a phrase can have a dense representation without occupying a dedicated dictionary entry. SSE preserves this aim and changes how the projection is parameterized. The relationship matters experimentally because the authors are comparing two ways of learning phrase representations as well as comparing learned representations with bags of phrases.

Earlier work discussed in the paper also gives a precedent for preserving location. Lebanon and colleagues represent documents as smooth curves in a space whose coordinates correspond to vocabulary items. Their procedure is unsupervised and preserves information about the locations of phrases. SSE-W puts relative position to a narrower use. It uses position to determine each phrase’s contribution to a vector trained for a document label.

The authors point to a further parallel with string kernels. In the work they discuss, methods for comparing protein sequences or classifying text can allow inexact matches between short segments. SSE supplies a route to inexact matching through a learned representation. Two windows can produce similar vectors even if their word sequences differ, because the words’ contributions can place them close together in the latent space. The effect depends on what the classifier learns to group. A particular kind of linguistic equivalence is neither supplied as supervision nor required for the resulting representation to help with sentiment.

The method, step by step

From an ordered review to a fixed-size vector

Start with a review as a sequence of words. Place a window over its opening words, then slide the window forward by a word. Each position yields another contiguous phrase. The overlap matters because a token usually participates in more than one window. In successive windows it can occupy different slots and appear alongside different neighbors. The representation records the identity of each selected word and its slot within that window.

The phrase projection retrieves a learned vector for every selected word-and-slot pair and adds the vectors. In the terminology of word embeddings, each word has several embeddings here, one for each slot. The vectors are combined in a common latent space, and a nonlinear function is applied to their sum. This makes every window a vector of the same size. A long review provides more vectors than a short review, with the same dimensions used for all windows and documents.

The next step pools those vectors. SSE takes their mean. SSE-W calculates a position weight for each window and takes a weighted sum. In either case, the resulting document vector contains as many coordinates as an individual phrase vector. The number of windows ceases to determine the size of the input to the classifier.

Finally, the classifier assigns a score associated with each candidate label and predicts the label with the highest value. During training, the difference between the expected label and the classifier’s prediction supplies a learning signal. The updates can change the document classifier, the word-and-slot vectors, and the parameters of the position curve when the weighted variant is used. The training examples carry document labels. The system learns which phrase contributions help from their effect on those labels.

From review words to a sentiment prediction

The steps in order.

From review words to a sentiment predictionStep 1: Slide a fixed-length window over the review1. Slide a fixed-length window over the reviewStep 2: Encode each word in its window slot2. Encode each word in its window slotStep 3: Project the window into a phrase vector3. Project the window into a phrase vectorStep 4: Apply tanh to the phrase vector4. Apply tanh to the phrase vectorStep 5: Average phrases or pool with learned position weights5. Average phrases or pool with learned position weightsStep 6: Score the candidate ratings6. Score the candidate ratingsStep 7: Choose the highest-scoring rating7. Choose the highest-scoring rating

What a word selector records

The authors first establish the bag-of-words representation that their system replaces. They use a dictionary whose entries index the input coordinates. An individual token is represented by a selector, a vector that activates the coordinate of its word type. A convenient way to write the rule is to give the value of the selector at any coordinate.

(e_w)ᵤ = 𝟙[u = w]

Here e_w is the selector for dictionary word w, and u is the dictionary entry indexing the coordinate being checked. The subscript ᵤ denotes that coordinate. The indicator 𝟙 takes the value 1 when the equality inside the brackets holds and 0 otherwise. A selector therefore carries the identity of the token without encoding its neighbors or its role in the document.

The word bag averages the selectors over the document.

ẽₓ = (1/N) ∑ᵢ₌₁ᴺ e_wᵢ

Here ẽₓ denotes the bag vector for document x, N is the number of words in that document, and i indexes its token positions from 1 through N. The summation ∑ adds the selectors e_wᵢ for the words wᵢ at those positions. Division by N expresses the sum relative to document length. Coordinates are identified by word type, so permuting the tokens leaves the bag unchanged.

In the paper’s account of TF-IDF, the active coordinate can carry an inverse document frequency rather than a unit value. For the explicit phrase baseline, the coordinates are dictionary phrases. The baseline keeps their identities and uses frequency to describe their presence in a review. SSE needs to preserve more of the input structure at this stage because the same word can make a different contribution in different slots.

From selectors to phrase vectors

Let D denote the word dictionary and S the set of finite word sequences drawn from it. An input x in S contains N words. The paper uses Γ for the vocabulary of phrases under discussion. An explicit bag uses phrases from that vocabulary as coordinates. The latent method constructs a window from the words that occur at consecutive positions in x.

γⱼ = (wⱼ, wⱼ₊₁, …, wⱼ₊ₙ₋₁)

Here γⱼ is the phrase whose start position is j. The w symbols identify the words at the indexed positions in the review, and n is the window length. The ellipsis includes the words between the displayed boundaries. The last subscript j+n−1 places the last word n positions into the window when the opening word is included in the count.

The input vector for the window puts its word selectors next to each other.

ê_γⱼ = [e_wⱼ, e_wⱼ₊₁, …, e_wⱼ₊ₙ₋₁]

Here ê_γⱼ denotes the concatenated input for the phrase γⱼ. Each e is the selector of the word indicated by its subscript. The brackets denote concatenation in window order, with the ellipsis standing for successive selectors between the opening and closing entries. If the dictionary has |D| entries, the resulting vector has n · |D| coordinates. Vertical bars around D give the number of entries in the dictionary. The dot indicates multiplication by the number of window slots.

This representation distinguishes a word in the opening slot from that same word in a later slot. The active coordinates fall in different blocks. Even if a word appears twice within a window, its selectors still activate separate coordinates because they belong to different blocks. The input remains sparse since only the coordinate for the observed word is active within each block.

The phrase projection maps this sparse input to a dense vector.

p_γⱼ = G × ê_γⱼ

Here p_γⱼ is the latent vector for window γⱼ, G is the learned projection matrix, and ê_γⱼ is its concatenated selector input. The multiplication × is matrix–vector multiplication. The projection has M rows, where M is the chosen size of the latent space, and n · |D| columns. Each column is the vector associated with one dictionary word in one window slot.

For unit selectors, applying the matrix amounts to retrieving the active columns and adding them. This explains how a projection with many columns can work on each window without processing every possible phrase. It also explains the sharing pattern. If two windows agree on a word in a given slot, that part of their projections comes from the same column. A change in word order generally changes the active columns. The method consequently represents order within the window even though it adds the vectors after lookup.

For a fixed word dictionary and latent dimension, the size of G grows linearly with the window length. Each new slot adds a block of columns for the dictionary. In an explicit bag, a longer phrase introduces new possible word combinations. The authors’ complexity claim concerns this difference in parameterization. It does not imply that each word slot receives equal training evidence. A column used only rarely can still be hard to estimate.

How phrases become evidence for a document

Before pooling the vectors, the system applies the hyperbolic tangent, written tanh, to each coordinate of a phrase projection. The function converts unbounded inputs into values within the range given in the paper as [−1, 1]. A coordinate can still distinguish positive and negative responses, but large magnitudes are compressed. Applying the function before pooling also matters for the role of phrase boundaries. The contribution of a word passes through the nonlinearity together with the other contributions in its window. Adding word contributions across the whole document first would bypass that phrase-level operation.

Using J for the number of windows being pooled makes the document formula explicit about which positions contribute.

φ(x) ≡ dₓ = ∑ⱼ₌₁ᴶ qⱼ × h(p_γⱼ)

Here φ is the document embedding function, x is the input document, and dₓ is the resulting vector. The equivalence sign identifies φ(x) with dₓ. The sum ∑ runs over the J windows, starting from index j = 1. Each qⱼ is the scalar weight of window γⱼ. The function h applies tanh coordinate by coordinate to the projected phrase vector p_γⱼ, and × scales the transformed vector by the weight. The paper writes the pooling sums with N as the upper limit while introducing N as the word count. Its construction describes pooling the sliding phrase windows. J here distinguishes that set from the token count used to define relative document position.

In SSE the weights are uniform. The authors express each as 1/N in their pooling notation and describe the operation as a mean. With window counts made explicit, the mean gives every vector the same share of the result. This makes the representation invariant to the order in which a fixed collection of window vectors is pooled. Changing the word order can still change the collection itself by changing which windows occur.

SSE-W uses the start of the window relative to document length. Its pre-normalization weight is the sum of sigmoid responses. Writing that unnormalized quantity as sⱼ keeps it distinct from the weight after division by the normalizer.

sⱼ = ∑ₖ₌₁ᴷ sigmoid(aₖ · j/N + bₖ)

Here sⱼ is the unnormalized weight for the window starting at position j, and N is the number of words in the document. The ratio j/N describes relative location. The summation adds K components indexed by k. For each component, aₖ is a learned multiplier on relative position and bₖ is a learned offset. The dot denotes multiplication and the plus sign adds the offset. The sigmoid is the nonlinear function applied to the resulting scalar inside the parentheses.

The method divides each window’s unnormalized value by the total before pooling.

qⱼ = sⱼ / Q

Here qⱼ is the normalized weight, sⱼ is the unnormalized value for window j, / denotes scalar division, and Q is the sum of the unnormalized values across the windows being pooled. The paper uses q for the quantities summed in its description of Q as well as for the output of normalization. The distinction here implements the stated weighted pooling interpretation.

Relative location lets the same rule operate on documents of different lengths. A phrase near the end of a long review can be assigned similar emphasis to one near the end of a short review. In the positional variant this rule has no direct input about what the words say. Moving a window changes its weight by changing its relative position. Changing the words at a given position changes its vector. This distinction is important when interpreting the authors’ illustration of a learned curve. A high weight near a boundary expresses a preference for evidence found there, whatever polarity the phrase projection assigns to the evidence.

From the document vector to a label

The last stage is multinomial logistic regression. Each candidate class has its own coefficient vector. A class score comes from multiplying its coefficients by the corresponding document coordinates and adding the contributions. The paper displays the class decision with a normalization that includes an added 1 in the denominator.

g(x) = arg maxᵢ∈{1,…,C} exp(βᵢ · dₓ) / (1 + ∑ₖ₌₁ᶜ exp(βₖ · dₓ))

Here g(x) is the predicted label for document x. The operator arg max returns the class index i producing the largest value, and the candidate set runs from 1 through C, the number of candidate classes. The vector βᵢ contains the coefficients for class i, and dₓ is the document vector. The dot denotes an inner product. The function exp exponentiates that score, and the denominator adds the exponentiated scores for all candidate classes, indexed by k, to the constant 1. The denominator is shared by the candidates for a document, so the largest normalized value comes from the largest class score.

For training, the paper gives the negative log-likelihood as the loss. It takes the score assigned to the observed label, applies a logarithm, and sums the resulting penalties across the labeled documents.

ℒ(X) = −∑ᵢ₌₁ᴸ log(exp(β_yᵢ · d_xᵢ) / (1 + ∑ⱼ₌₁ᶜ exp(βⱼ · d_xᵢ)))

Here ℒ(X) is the loss on the labeled training collection X, and L is the number of labeled documents in it. The outer sum indexes training examples by i. Example i has document xᵢ, pooled vector d_xᵢ, and observed label yᵢ. The vector β_yᵢ supplies the coefficient weights for that label. The second sum indexes the candidate classes by j, with coefficient vector βⱼ and class count C. The inner products, exponential function, division, and added 1 are the same operations as in the decision formula. The function log takes the logarithm of the normalized value for the observed class. The minus sign gives a larger penalty when that value is smaller.

Back-propagation transfers the error signal from classification through pooling and into the phrase projections. For example, a window with a larger pooling weight has a larger direct contribution to the document vector. A word-and-slot column is updated through the windows in which that column is used. In SSE-W the learning signal also passes through the normalized weights and into the sigmoid parameters. There is no separate fitting stage in which the system scores phrases for sentiment before learning to classify documents.

The paper uses stochastic gradient descent. An update uses a randomly chosen training example to estimate a gradient, so it can be computed without running through the whole training set before changing the parameters. The authors use a fixed learning rate of 0.05 for their perceptron-based methods. They hold the latent dimension at M = 50 across their latent setups. They choose n = 5 for SSE and SSE-W after examining the explicit phrase baselines at different lengths. They fix K = 3 for the positional curve, motivated by their hypothesis about the opening and closing of a review.

How the closest alternative builds a phrase

Lookup Table Convolution, or LTC, starts with a word lookup that is shared across slots. It then uses a separate matrix to project the resulting window into the phrase space. Its word lookup is written as follows.

LT_E(wⱼ) = E × e_wⱼ = E_wⱼ

Here LT_E is lookup with the matrix E, wⱼ is the word at position j, and e_wⱼ is that word’s selector. The product × retrieves the column E_wⱼ of E indexed by the dictionary entry. The matrix has m rows, the size of an individual word’s latent vector, and |D| columns, one for each dictionary word.

Once the word vectors are retrieved, LTC puts them in window order and projects the concatenation.

p̃_γⱼ = F × z_γⱼ = F × [E_wⱼ, E_wⱼ₊₁, …, E_wⱼ₊ₙ₋₁]

Here p̃_γⱼ is the LTC phrase vector for γⱼ, F is the phrase projection, and z_γⱼ is the concatenation displayed in brackets. Each E with a word subscript is a lookup column for the word at that position. The ellipsis stands for the intermediate word vectors. The index j gives the start of the window and n gives its length. The projection F has M rows, the phrase vector size, and n · m columns, the total size of the concatenation. Multiplication by F maps the concatenated slot inputs to the phrase space.

In LTC the shared word table and the slot-specific blocks of the second projection both contribute to the effective vector for a word in a slot. SSE estimates the equivalent type of contribution directly through G. In LTC, updating either matrix requires taking account of the other matrix’s current values. The authors argue that SSE avoids much of the multiplication associated with these coupled gradients. This is a claim about the operations involved in learning the phrase projection. The classification comparisons address the separate question of how the resulting representations perform on held-out text.

Experiments and results

The reviews and their prediction targets

Amazon supplies product reviews from 25 categories, including apparel, electronics, and home or hardware purchases represented in the corpus. TripAdvisor supplies hotel reviews. A hotel review can have separate ratings for features such as the location or the room. The authors use the overall rating. In both corpora a low rating means unfavorable sentiment and a high rating means favorable sentiment. The paper’s first description of the binary task reverses the names of those groups. The later description of the scale and the balanced splits establishes 1 and 2 stars as negative, and 4 and 5 stars as positive.

For Amazon, the training split contains 257,900 reviews, the development split contains 10,000, and the test split contains 110,562. For TripAdvisor, the corresponding sizes are 55,306 for training, 5,000 for development, and 10,078 for testing. The authors made the splits available and explain that the main results use a different split from their previous sentiment paper. They also made results available for SSE on the earlier split to support a comparison under matching conditions.

The binary task groups reviews by positive or negative polarity and uses balanced splits. The task with 4 labels treats 1, 2, 4, and 5 stars as distinct outcomes. That gives the classifier a harder distinction within each side of the polarity scale. A classifier can recognize that a review is favorable and still make a rating error by choosing the wrong favorable label. TripAdvisor additionally supports a task with 5 labels that includes the neutral 3-star rating. The Amazon corpus used here was assembled without neutral reviews, so it has no counterpart to that TripAdvisor experiment.

The paper reports macro- and micro-average error. Macro-average error first computes the error separately for each label and then gives each label equal weight in the mean. Micro-average error pools the test cases and measures the overall fraction classified incorrectly. A label with many test examples has more influence on the latter. The metrics coincide for the balanced binary tests. In the finer rating tasks they answer different questions. A method’s macro error can fall because its per-label errors improve on average, even when the effect on the pooled test cases is smaller.

Baseline features and development choices

The explicit phrase baselines first form a vocabulary of retained n-grams. To show the scale of the candidate inventories, the paper reports training counts in thousands. On Amazon those counts include 448 for n = 1, 6,446 for n = 2, 23,400 for n = 3, and 78,864 for n = 5. On TripAdvisor the corresponding counts in thousands are 158, 1,175, 5,172, and 21,741. These are counts of distinct observed phrases for the listed sizes. The classifiers use selected vocabularies, so the sizes of the candidate inventories should be distinguished from the numbers of retained features.

Feature selection for the review baselines relies on mutual information with the binary polarity label. Mutual information measures the dependence between the presence of a phrase and the label. For Amazon the procedure selects 25,000 phrases per product category from the training split and joins the selected lists. For TripAdvisor the selection is performed over the entire training corpus with a vocabulary limit of 500,000 n-grams. The finer rating tasks are also compared against baselines using vocabularies selected by their association with the binary labels.

For a retained phrase, the implementation combines frequency within the document with an inverse document frequency term estimated across documents. The paper’s implementation formula can be written in compact form as follows.

tfidf(γⱼ, x, X) = (1/|x|) · tf(γⱼ, x) · idf(γⱼ, X)

Here tfidf is the feature weight, γⱼ is the phrase, x is the document being represented, and X is the document collection used for the corpus frequency. The quantity |x| is the document length, so 1/|x| is its reciprocal. The function tf returns the number of times the phrase appears in x. The function idf supplies its inverse document frequency and the dots multiply these scalar quantities.

idf(γⱼ, X) = log(|X| / |{xᵢ ∈ X : γⱼ ∈ xᵢ}|)

Here idf is inverse document frequency, γⱼ is the phrase, X is the collection and |X| is the number of its documents. The set inside the second pair of vertical bars contains the documents xᵢ belonging to X that contain γⱼ. The symbol ∈ denotes membership in the collection or occurrence of the phrase in the document, as appropriate. The colon inside the set introduces the occurrence condition. Vertical bars give the number of documents satisfying that condition. The division compares the size of the collection with the number of documents containing the phrase, and log takes the logarithm of the ratio.

The support vector machine uses a linear kernel. The authors chose it in view of the corpus sizes and the number of feature coordinates, and because they regarded a linear SVM as an established sentiment baseline. They used LIBLINEAR and selected the penalty parameter by grid search on the development set before evaluating the selected setting on the test set. They used Torch5 for the linear perceptron baseline and the systems that learn latent representations. During training they periodically evaluated those systems on the full development split and kept the parameters from the best checkpoint. The held-out error comes from that checkpoint. The learning rate and latent dimension were chosen from prior experience. The paper did not tune them as part of these experiments.

What explicit n-grams contribute

The SVM comparison establishes that explicit phrase features are already valuable, especially on Amazon. On the Amazon binary test, macro-average error is 10.68% with unigrams, 6.60% with the bigram setting, 6.39% with the trigram setting, and 6.48% with the setting that includes phrases up to length 5. On the Amazon task with 4 labels, the respective errors are 35.78%, 28.26%, 27.98%, and 28.02%. The paper flags all the longer settings as significantly better than the unigram setting on these Amazon tasks at p < 0.0001.

On the TripAdvisor binary test, the corresponding SVM macro errors are 8.97%, 7.60%, 7.46%, and 7.53%. For the 4-label TripAdvisor task, the errors are 35.41%, 33.68%, 33.50%, and 33.45%. The TripAdvisor task that includes neutral reviews differs in where its best explicit setting lies. There the unigram error is 46.41%, the bigram setting reaches 44.68%, the trigram setting gives 45.12%, and the longest setting is back at 46.41%. These comparisons concern the vocabulary-plus-selection procedure used for the SVM. They show the value of going beyond individual words, with the best maximum phrase length varying across tasks.

The paper uses the SVM with trigrams in the main sentiment comparison. It also includes a linear perceptron with the same type of explicit phrase representation. The perceptron helps check how much of the comparison depends on using the SVM as the sole yardstick. When reading the results, it matters that the explicit baselines have a direct feature for each retained phrase, while the learned systems build a vector for each observed window out of slot-specific word vectors. The comparison tests these complete routes to a document decision.

Amazon and TripAdvisor test errors

The clearest gains on Amazon appear when the rating levels remain distinct. The learned phrase systems lead both of the explicit phrase baselines on that task. The position-weighted variant has the lowest test macro error among the systems in the chart.

Amazon 4-label test macro-average error by classifier

Learned phrase embeddings improve on the explicit phrase baselines, and position weighting gives the lowest error.

Amazon 4-label test macro-average error by classifierSVM BoW-3g: 27.98SVM BoW-3g27.98Linear perceptron BoW-3g: 26.45Linear perceptron BoW-3g26.45SSE: 25.30SSE25.30SSE-W (this paper): 24.61SSE-W (this paper)24.61
The numbers
System or settingerror %
SVM BoW-3g27.98
Linear perceptron BoW-3g26.45
SSE25.30
SSE-W (this paper)24.61

On the same Amazon 4-label test, the micro-average errors are 23.45% for the trigram SVM, 23.00% for the linear perceptron, 22.40% for SSE, and 22.05% for SSE-W. The ordering among the classifiers is the same as with macro-averaging. On the binary test, SSE reaches 5.69% and SSE-W reaches 5.63%, compared with 6.39% for the trigram SVM and 6.55% for the linear perceptron. The binary LTC result in the macro table is 7.05%. The table marks both Amazon SSE variants as better than the trigram SVM at p < 0.0001 for both label settings. Those markers concern comparisons with the SVM. They provide a different comparison from testing the effect of weighting SSE’s windows.

TripAdvisor’s binary result shows a different ordering. SSE has a test error of 6.90%, compared with 7.01% for SSE-W, 7.46% for the trigram SVM, and 7.54% for the linear perceptron. LTC has a macro error of 8.49%. In the TripAdvisor task with 4 labels, macro error is 34.22% for SSE and 32.25% for SSE-W. The trigram SVM comes between them at 33.50%, and the linear perceptron gives 34.73%. The corresponding micro errors are 33.90% for SSE, 31.41% for SSE-W, 32.00% for the trigram SVM, and 33.94% for the linear perceptron. In that comparison the position-weighted version leads on either metric. Uniform pooling yields a different conclusion about the value of switching from the trigram SVM to latent phrase vectors.

When TripAdvisor’s neutral rating is included, both latent versions lead the explicit baselines shown in the main comparison. The SVM depends in part on which maximum phrase length was chosen. Its separate phrase-length comparison gives a lower macro error with the bigram setting than with the trigram entry shown here. SSE-W also leads that bigram result.

TripAdvisor 5-label test macro-average error by classifier

Position-weighted phrase pooling gives the lowest error when the rating task includes neutral reviews.

TripAdvisor 5-label test macro-average error by classifierSVM BoW-3g: 45.12SVM BoW-3g45.12Linear perceptron BoW-3g: 43.58Linear perceptron BoW-3g43.58SSE: 42.88SSE42.88SSE-W (this paper): 40.54SSE-W (this paper)40.54
The numbers
System or settingerror %
SVM BoW-3g45.12
Linear perceptron BoW-3g43.58
SSE42.88
SSE-W (this paper)40.54

For that TripAdvisor test, the micro errors are 43.07% for the trigram SVM, 43.05% for the perceptron, 42.21% for SSE, and 40.76% for SSE-W. The macro table flags SSE at p < 0.01 and SSE-W at p < 0.0001 against the trigram SVM. The micro table flags SSE-W at p < 0.01 against that baseline. The overall pattern is that SSE-W has lower observed error than the trigram SVM in every review setting reported in the main comparison. The significance annotations and the comparisons with uniform SSE are more selective.

Reuters as a test beyond sentiment

The Reuters RCV1 experiments change the target from review ratings to news topics. The original split has 23,149 training documents and 781,265 test documents, drawn from a corpus categorized with 103 topics. The authors also construct a split with 380,000 training examples. They refer to the splits as RCV1 23k and RCV1 380k. For each, they randomly sample 10,000 documents from its test portion to make a development set. They use raw text features, whereas the Reuters benchmark publication they cite used stemming.

The study selects the categories with the most positive examples, covering corporate and industrial news, government and social news, markets, and corporate and industrial performance. The paper labels them CCAT, GCAT, MCAT, and C15. The explicit vocabulary is capped at the 500,000 most frequent n-grams selected from the training set. This frequency rule differs from the mutual-information selection used in the review experiments. The Reuters comparator is a linear SVM with the bigram representation.

On RCV1 23k, the SVM, SSE, and SSE-W respectively reach macro errors of 5.82%, 5.74%, and 5.71% for CCAT. For GCAT the same systems yield 5.42%, 4.79%, and 4.70%. On MCAT the errors are 5.60%, 4.41%, and 4.45%. For C15 they are 7.62%, 6.21%, and 5.50%. Thus the uniform phrase representation is already competitive with the explicit features across this split. The relative-position extension leads on several topics, while the uniform version leads on MCAT.

With the larger training split, the outcomes depend more visibly on the topic. On CCAT the SVM leads at 4.07%, followed by SSE-W at 4.15% and SSE at 4.29%. On GCAT the two SSE variants share an error of 3.81% against 4.47% for the SVM. On MCAT the SVM gives 3.95%, SSE gives 3.42%, and SSE-W gives 3.47%. C15 is the instance in which SSE-W leads and uniform SSE trails the SVM.

Reuters RCV1 380k C15 test macro-average error by classifier

Position weighting gives the lowest error for corporate and industrial performance, while uniform pooling trails the bigram baseline.

Reuters RCV1 380k C15 test macro-average error by classifierSVM BoW-2g: 4.93SVM BoW-2g4.93SSE: 5.76SSE5.76SSE-W (this paper): 4.28SSE-W (this paper)4.28
The numbers
System or settingerror %
SVM BoW-2g4.93
SSE5.76
SSE-W (this paper)4.28

The paper proposes that the specificity of C15 may matter. A category devoted to performance reports could have a more consistent pattern of where relevant language appears than a broad category covering corporate news or markets. The table establishes a category-specific difference between uniform and weighted pooling. It does not identify article structure as its cause.

What the ablations show

The effect of explicit phrases and the effect of learned composition

The clearest controlled comparison in the paper is between the uniform and position-weighted versions of SSE. The experiments also vary the maximum phrase size in the explicit SVM and compare the direct projection with a lookup followed by a separate phrase projection. These comparisons answer different questions. Increasing the maximum size in the SVM asks whether selected longer sequences provide evidence for a classifier with explicit coordinates. Changing the projection asks how a latent phrase vector should be learned. Adding position weights asks which already constructed windows should contribute more strongly to the document vector.

The SVM phrase-length comparison supports the decision to keep local order. Longer features lower macro error compared with unigrams on both Amazon tasks, and at least one longer setting also improves each TripAdvisor task. For a reader assessing the choice n = 5 in SSE, the distinction between baselines and latent systems is important. The SVM sweep shows that access to longer phrases can be useful, but it places the best explicit setting at different lengths across the tasks. It does not test whether n = 5 is the best window for SSE. An explicit bag with a maximum length can retain shorter phrases as dedicated features. SSE uses fixed-length overlapping windows and learns a composition within them.

The binary comparison with LTC gives some evidence about the direct projection. The uniform SSE variant is already ahead of LTC on both review corpora. Since both pool with uniform weights, the advantage in those rows cannot be credited to the position curve. The comparison is consistent with the benefit of estimating effective word-and-slot vectors directly. LTC also shares a base vector across slots, so a difference in its performance may involve the constraint imposed by that sharing as well as the coupled optimization. The paper does not separately vary these mechanisms, and the table only reports LTC for the binary review tasks.

The comparison with the linear perceptron shows how much the choice of input representation can matter even when the comparator is a simple linear decision procedure. With explicit trigrams the perceptron can rank ahead of the SVM on some tasks and behind it on others. SSE-W leads both in the main review comparison. That supports the practical case for the full learned pipeline. A question about any individual ingredient, such as the nonlinearity between phrase projection and pooling, would need a comparison in which that ingredient was changed on its own.

When the position curve helps

Comparing SSE-W with SSE brings the focus to one architectural change. Both construct phrase vectors from slot-specific word contributions and feed pooled vectors to the same kind of classifier. SSE-W inserts a learned dependence on relative position. Because the variants are trained end to end, their final phrase projections can also differ. The comparison therefore measures the value of allowing position weighting during training and prediction. It is not equivalent to taking an already trained SSE classifier and changing its weights at test time.

The authors report significant improvements over uniform SSE for the multiclass review comparisons at p < 0.0001 on Amazon and p < 0.01 on TripAdvisor. By contrast, the paper gives p < 0.4 for the binary Amazon improvement. That threshold supplies little evidence for a reliable improvement, and binary TripAdvisor goes in the opposite direction on the observed test errors. The authors’ interpretation is that detecting broad polarity often depends on the presence of recognizable language, wherever it appears. Distinguishing ratings within the same broad polarity may benefit more from how the evaluation is distributed through the review. The data support a difference between the tested tasks in the benefit of weighting. They do not settle how readers choose a rating or which passages caused them to assign it.

The Reuters comparisons show that the effect also varies within a single prediction domain. The paper reports a significant improvement for C15 from SSE to SSE-W at p < 0.0001. For MCAT, SSE is ahead of SSE-W in each split. For GCAT on the larger split, the reported macro errors tie, and for CCAT on that split the SVM remains ahead. A learned position curve can help with the right category, but the ability to weight document locations does not ensure better prediction. Different categories can reward different allocations of attention to the text.

The paper illustrates the fitted positional function using an SSE-W system trained on the binary Amazon task. It evaluates the curve on an artificial document of 25 words and scales the displayed weights into [0, 1]. The curve gives more prominence to windows near the beginning and end. This is consistent with the authors’ original hypothesis about where a reviewer might place a strong judgment. The illustration shows the preference learned in that setup, while the weak binary classification gain shows that a recognizable learned pattern can have limited effect on aggregate test error.

What individual windows reveal

The authors also examine individual windows in selected TripAdvisor reviews. They use the uniform SSE classifier trained for the task with 4 labels, project each length-5 window by itself, and give it the largest raw class score it can produce. The calculation can be written as follows.

r(γⱼ) = maxᵢ∈{1,…,C} βᵢ · φ(γⱼ)

Here r is the diagnostic response assigned to phrase γⱼ. The maximum is over the class indices i from 1 through C, and βᵢ is the coefficient vector for class i. The function φ produces the latent vector when the phrase is treated as the input by itself. The dot denotes the inner product between that vector and the class coefficients. The score retains the strongest response and discards the identity of the class that produced it.

They display high-scoring windows that do not overlap. In one unfavorable review, the selected fragments include a harsh judgment of the hotel, a remark about barely tolerable food, and an intention to avoid the property. In a review with mixed evidence, selected passages cover helpful staff, noisy air conditioning, and the guest’s decision against returning. The examples show that high-scoring windows can include both praise and criticism in a review. The ranking measures the strongest response over candidate labels. A passage can rank highly even when its favored label differs from the overall rating.

This diagnostic gives a way to inspect what the supervised representation treats as salient. Its restriction to short windows also makes its limits visible. A selected fragment can begin or end in the middle of a thought. A few high-scoring fragments can give a reader a quick indication of what the review discusses without preserving how all the qualifications fit together. The paper presents these as illustrative results rather than measuring how well the selections serve as summaries.

Learning weights from phrase content

A final analysis substitutes a content-based weighting rule for the positional one. It computes a scalar from the same sparse slot input used by the phrase projection.

qⱼ = Ĝ × ê_γⱼ

Here qⱼ is the weight of phrase γⱼ, Ĝ is a learned projection with 1 row and n · |D| columns, and ê_γⱼ is the same concatenation of word selectors used by the phrase projection. The product × returns a single scalar. As with the matrix G, the input dimensions correspond to dictionary entries in specified window slots. This rule depends on the words in the window and their order.

The authors initialize the variant using SSE trained on Amazon binary sentiment and keep the phrase projection G fixed while training the modified system on Amazon. They then rank length-5 windows from the Amazon test split and display selected high-scoring phrases containing the words good and book. The examples range from emphatic endorsement to milder approval, and the authors note that high weights can also occur on negative phrases. They interpret the weight as strength of sentiment, with the phrase vector still able to provide evidence about which polarity it expresses. This is a qualitative observation about the selected examples. The paper does not give an error comparison establishing how the content-based variant performs against positional or uniform pooling.

Limitations

Limits the authors state

The authors restrict their empirical conclusions to document-level text classification. Their primary task is recognizing sentiment in reviews, with the Reuters investigation showing an application to topic categorization. They suggest that an ordered sequence of events described by a finite vocabulary might also be amenable to the same treatment. They name protein sequences and search query logs as possible examples and propose exploring uses of bag-style representations in other modalities, including images. These are directions for future work. The experiments in the paper concern reviews and news articles.

The authors also state that they fixed the learning rate and latent dimension using prior experience, and that earlier sentiment results from their own group used a different split. This limits comparisons in two ways. The paper’s main tables compare systems under its chosen settings and splits. A direct numerical comparison with an earlier paper would need matching data. The phrase-length comparison also does not establish how much SSE could gain from tuning its own window size or the number of components in the position function.

The illustrative labels matter as well. The authors present the selected phrase examples as anecdotal evidence about task-relevant phrase responses. They use the artificial document to show a fitted weighting curve and suggest an interpretation of the Reuters category differences. These analyses can show what the learned functions do on the examples, or motivate an explanation for a test result. They provide no direct annotations of which parts of a review communicate its overall sentiment, or which parts of a news story establish its category.

Limits visible in the experimental design

The two review datasets are different sources, but the experiments train and evaluate within each source. The Amazon and TripAdvisor results establish that the procedure can be trained successfully in both review settings. They leave open whether an embedding trained on one source would be effective on the other, or how it would perform for a different language or a different kind of opinion text. The Reuters experiment broadens the types of labels tested while still using labeled examples from the task being evaluated.

The ratings are proxies for the sentiments expressed in the text. In the binary splits, the test is balanced by polarity and excludes neutral reviews. Fine-grained prediction asks for the exact rating category. The reported error gives equal cost to any incorrect label in the relevant averaging scheme, so the tables do not show whether mistakes largely stay within a polarity group or cross between positive and negative. The experiment with a neutral label is restricted to TripAdvisor. The paper’s results on that task describe the classification of those reviews under a 5-label evaluation, with no matched Amazon comparison.

Representing phrases by word-and-slot vectors also makes a particular tradeoff. It makes the phrase parameter space tractable and permits sharing across many distinct windows. The additive projection before tanh still constrains how evidence from words can combine. A phrase with an interpretation that depends heavily on the entire configuration has to be represented with the available slot contributions and the nonlinearity. The paper provides examples where the representation responds to useful passages. It does not separately test what happens with unusual combinations, unseen expressions, or words outside the dictionary.

The positional curve is likewise a shared function of relative location. It can learn that the beginning or end frequently warrants more weight in its training task. It has no input describing the rhetorical role of a particular passage or how one window changes the interpretation of another. A pooled vector cannot preserve the full arrangement of the windows. The content-based variant demonstrates that alternative weights can be constructed, with its evidential scope limited by the absence of a classification comparison.

Finally, the scaling claim is clearest for the number and structure of phrase parameters. The results give error rates on substantial corpora, and the paper explains the operations saved by removing the coupled lookup and projection of LTC. It does not report timings or memory measurements that would quantify the efficiency advantage over the full baselines. The sentiment comparisons also use baseline dictionaries selected for their association with binary polarity. Because the same selection target is used when the task involves finer rating distinctions, it remains open how much a phrase baseline tuned specifically for those distinctions would change the comparison. The observed errors establish the performance of the particular systems tested.

What came after

Learning Sentiment-Specific Word Embedding for Twitter Sentiment Classification, published in 2014, cites the paper and takes up a related question in a different setting. Its stated goal is to learn word embeddings specific to sentiment for classifying Twitter text. Bespalov and colleagues use learned word contributions at specified slots to construct phrase vectors, then combine those into a document representation. The later work’s title puts the emphasis on word embeddings and names a different target text. The common direction is to shape the representation around sentiment classification. The citation establishes the connection between the works. It does not on its own establish that the later authors adopted sliding-window composition, learned relative-position weights, or any other particular part of SSE.

Cite

Cite as Dmitriy Bespalov, Yanjun Qi, Bing Bai and Ali Shokoufandeh. 2012. Sentiment Classification with Supervised Sequence Embedding. Lecture notes in computer science.

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.1007/978-3-642-33460-3_16

@inproceedings{bespalov2012sentiment,
  title = {{Sentiment Classification with Supervised Sequence Embedding}},
  author = {Dmitriy Bespalov, Yanjun Qi, Bing Bai and Ali Shokoufandeh},
  booktitle = {Lecture notes in computer science},
  year = {2012},
  doi = {10.1007/978-3-642-33460-3\_16},
  url = {https://doi.org/10.1007/978-3-642-33460-3_16}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/bespalov-2012-sentiment-classification-supervised-sequence-embedding/