Text as Data

W9 · Word Embeddings and Political Language

Yen-Chieh Liao

2026-11-06Fall 2026 (115-1) · National Taiwan University (GIND)
NTLDEV 7191 · Fri. 16:30–18:20 · GIND 204

Example: security in context

The ESS diagram branches the word security into defence, energy, and economy contexts and shows related words for each use.

We see security used in defence, energy and economic contexts.

Which nearby words help us distinguish these uses?

How could we test whether these uses vary across parties or periods?

Example · security in political language.

From topics to language representations

Research task Political question
W8 · Topic models What do actors discuss, and how much?
W9 · Word embeddings How can learned vectors describe and compare political language?

One-hot word rows on the left and a schematic dense space on the right. Red frames first mark the apple and cat rows, then the nearby dog, cat and rabbit points. The classes and positions are schematic.

One-hot gives us one coordinate per word. Different words have cosine zero.

Embeddings let us compare words using coordinates learned from their use.

Dog, cat and rabbit can be close when they appear in similar contexts.

From topics to language representations

Research task Political question
W8 · Topic models What do actors discuss, and how much?
W9 · Word embeddings How can learned vectors describe and compare political language?

One-hot word rows on the left and a schematic dense space on the right. Red frames first mark the apple and cat rows, then the nearby dog, cat and rabbit points. The classes and positions are schematic.

One-hot gives us one coordinate per word. Different words have cosine zero.

Embeddings let us compare words using coordinates learned from their use.

Dog, cat and rabbit can be close when they appear in similar contexts.

From topics to language representations

Research task Political question
W8 · Topic models What do actors discuss, and how much?
W9 · Word embeddings How can learned vectors describe and compare political language?

One-hot word rows on the left and a schematic dense space on the right. Red frames first mark the apple and cat rows, then the nearby dog, cat and rabbit points. The classes and positions are schematic.

One-hot gives us one coordinate per word. Different words have cosine zero.

Embeddings let us compare words using coordinates learned from their use.

Dog, cat and rabbit can be close when they appear in similar contexts.

From topics to language representations

Research task Political question
W8 · Topic models What do actors discuss, and how much?
W9 · Word embeddings How can learned vectors describe and compare political language?

One-hot word rows on the left and a schematic dense space on the right. Red frames first mark the apple and cat rows, then the nearby dog, cat and rabbit points. The classes and positions are schematic.

One-hot gives us one coordinate per word. Different words have cosine zero.

Embeddings let us compare words using coordinates learned from their use.

Dog, cat and rabbit can be close when they appear in similar contexts.

Learn from context and compare vectors

Context windows around cat. The first frame marks c equals 1 and cute/cat/jumps. The second marks c equals 2 and the added The/over. The third returns to c equals 1, marks that window label, and uses arrows from cute and jumps toward cat to illustrate CBOW.

Window · c = 1: We take cute and jumps around cat.

Window · c = 2: We also include The and over.

Learn: CBOW (Continuous Bag of Words) predicts cat from context. Skip-gram predicts context from cat.

Compare: We use cosine to compare the directions of the learned vectors.

Learn from context and compare vectors

Context windows around cat. The first frame marks c equals 1 and cute/cat/jumps. The second marks c equals 2 and the added The/over. The third returns to c equals 1, marks that window label, and uses arrows from cute and jumps toward cat to illustrate CBOW.

Window · c = 1: We take cute and jumps around cat.

Window · c = 2: We also include The and over.

Learn: CBOW (Continuous Bag of Words) predicts cat from context. Skip-gram predicts context from cat.

Compare: We use cosine to compare the directions of the learned vectors.

Learn from context and compare vectors

Context windows around cat. The first frame marks c equals 1 and cute/cat/jumps. The second marks c equals 2 and the added The/over. The third returns to c equals 1, marks that window label, and uses arrows from cute and jumps toward cat to illustrate CBOW.

Window · c = 1: We take cute and jumps around cat.

Window · c = 2: We also include The and over.

Learn: CBOW (Continuous Bag of Words) predicts cat from context. Skip-gram predicts context from cat.

Compare: We use cosine to compare the directions of the learned vectors.

Learn from context and compare vectors

Context windows around cat. The first frame marks c equals 1 and cute/cat/jumps. The second marks c equals 2 and the added The/over. The third returns to c equals 1, marks that window label, and uses arrows from cute and jumps toward cat to illustrate CBOW.

Window · c = 1: We take cute and jumps around cat.

Window · c = 2: We also include The and over.

Learn: CBOW (Continuous Bag of Words) predicts cat from context. Skip-gram predicts context from cat.

Compare: We use cosine to compare the directions of the learned vectors.

Training choices shape the available vectors

Method or interface Learning signal Representation
Word2Vec CBOW: context → word.
Skip-gram: word → context.
Static word vector
GloVe
Global Vectors for Word Representation
Fit corpus-wide word co-occurrence statistics. Static word vector
fastText Predict from context with character n-grams. Static word vector
FlairEmbeddings Character language models use surrounding text. Contextual token vector

Lab choice: We use Flair’s WordEmbeddings("glove") to load static GloVe.

Training choices shape the available vectors

Method or interface Learning signal Representation
Word2Vec CBOW: context → word.
Skip-gram: word → context.
Static word vector
GloVe
Global Vectors for Word Representation
Fit corpus-wide word co-occurrence statistics. Static word vector
fastText Predict from context with character n-grams. Static word vector
FlairEmbeddings Character language models use surrounding text. Contextual token vector

Lab choice: We use Flair’s WordEmbeddings("glove") to load static GloVe.

Training choices shape the available vectors

Method or interface Learning signal Representation
Word2Vec CBOW: context → word.
Skip-gram: word → context.
Static word vector
GloVe
Global Vectors for Word Representation
Fit corpus-wide word co-occurrence statistics. Static word vector
fastText Predict from context with character n-grams. Static word vector
FlairEmbeddings Character language models use surrounding text. Contextual token vector

Lab choice: We use Flair’s WordEmbeddings("glove") to load static GloVe.

Training choices shape the available vectors

Method or interface Learning signal Representation
Word2Vec CBOW: context → word.
Skip-gram: word → context.
Static word vector
GloVe
Global Vectors for Word Representation
Fit corpus-wide word co-occurrence statistics. Static word vector
fastText Predict from context with character n-grams. Static word vector
FlairEmbeddings Character language models use surrounding text. Contextual token vector

Lab choice: We use Flair’s WordEmbeddings("glove") to load static GloVe.

Training choices shape the available vectors

Method or interface Learning signal Representation
Word2Vec CBOW: context → word.
Skip-gram: word → context.
Static word vector
GloVe
Global Vectors for Word Representation
Fit corpus-wide word co-occurrence statistics. Static word vector
fastText Predict from context with character n-grams. Static word vector
FlairEmbeddings Character language models use surrounding text. Contextual token vector

Lab choice: We use Flair’s WordEmbeddings("glove") to load static GloVe.

How four journal articles use embeddings

Case Texts How embeddings are used
Case 1 · Rheault & Cochrane Parliamentary speech Estimate party positions
Case 2 · Rodman News about equality Track a concept across eras
Case 3 · Müller & Proksch European party manifestos Find candidates for a nostalgia dictionary
Case 4 · Rodriguez et al. U.S. Congressional Record Compare party and gender differences in word use

We follow four studies, asking what gets a vector and how each result helps answer the research question.

Case 1 · Party positions in parliament

Case 1 · Party positions

Cambridge Core article page showing the Political Analysis cover, article title, and authors Ludovic Rheault and Christopher Cochrane.

Ludovic Rheault and Christopher Cochrane

Political Analysis, 2020 · Cambridge article page

  • Background Roll-call votes offer one way to locate parties on a political scale.
  • Question Can speeches also reveal party positions and how they change between terms?
  • Texts Parliamentary debates from the United States, Britain and Canada. The model represents each party in each legislative term.

Learn party embeddings with political metadata

Case 1 · Party positions

How embeddings are used

A neural network predicts work from surrounding words and a Labour 2005 indicator. Sequential course annotations identify the prediction target, the party-term input, and its learned parameters. PCA is performed after training, as shown on the next slide.

1. Predict: The model predicts work from context and the party-term label.

2. Represent: Each party in each term receives a vector, here Labour 2005.

3. Project: We use PCA to compare the party-term vectors on PC1, shown next.

Learn party embeddings with political metadata

Case 1 · Party positions

How embeddings are used

A neural network predicts work from surrounding words and a Labour 2005 indicator. Sequential course annotations identify the prediction target, the party-term input, and its learned parameters. PCA is performed after training, as shown on the next slide.

1. Predict: The model predicts work from context and the party-term label.

2. Represent: Each party in each term receives a vector, here Labour 2005.

3. Project: We use PCA to compare the party-term vectors on PC1, shown next.

Learn party embeddings with political metadata

Case 1 · Party positions

How embeddings are used

A neural network predicts work from surrounding words and a Labour 2005 indicator. Sequential course annotations identify the prediction target, the party-term input, and its learned parameters. PCA is performed after training, as shown on the next slide.

1. Predict: The model predicts work from context and the party-term label.

2. Represent: Each party in each term receives a vector, here Labour 2005.

3. Project: We use PCA to compare the party-term vectors on PC1, shown next.

From party vectors to a political dimension

Case 1 · Party positions

First principal component of U.S. House party embeddings from 1873 to 2016. Red brackets mark the gaps between the dashed blue Democratic line and the solid red Republican line near 1920 and 2000.

Read the axes: We compare years horizontally and PC1 vertically. PC1 captures the greatest variation across party-term vectors.

1920 bracket: We see a small gap: Democrats are dashed blue; Republicans solid red.

Answer: By 2000, we see the parties much farther apart on this speech-based scale.

From party vectors to a political dimension

Case 1 · Party positions

First principal component of U.S. House party embeddings from 1873 to 2016. Red brackets mark the gaps between the dashed blue Democratic line and the solid red Republican line near 1920 and 2000.

Read the axes: We compare years horizontally and PC1 vertically. PC1 captures the greatest variation across party-term vectors.

1920 bracket: We see a small gap: Democrats are dashed blue; Republicans solid red.

Answer: By 2000, we see the parties much farther apart on this speech-based scale.

From party vectors to a political dimension

Case 1 · Party positions

First principal component of U.S. House party embeddings from 1873 to 2016. Red brackets mark the gaps between the dashed blue Democratic line and the solid red Republican line near 1920 and 2000.

Read the axes: We compare years horizontally and PC1 vertically. PC1 captures the greatest variation across party-term vectors.

1920 bracket: We see a small gap: Democrats are dashed blue; Republicans solid red.

Answer: By 2000, we see the parties much farther apart on this speech-based scale.

Validate the positions outside the model

Case 1 · Party positions

Table comparing party placement against Voteview roll-call scores, expert surveys and three manifesto-based measures. Red outlines mark the U.S. House column and the two Voteview results, a correlation of 0.918 and pairwise ordering agreement of 85.66 percent.

U.S. House Speech-based PC1 correlates 0.918 with Voteview party averages (1921–2016).

Next row: We read 85.66% agreement on party-term pair orderings.

Answer: We can read PC1 as a left–right scale in this overlapping period. Agreement varies across benchmarks.

Validate the positions outside the model

Case 1 · Party positions

Table comparing party placement against Voteview roll-call scores, expert surveys and three manifesto-based measures. Red outlines mark the U.S. House column and the two Voteview results, a correlation of 0.918 and pairwise ordering agreement of 85.66 percent.

U.S. House Speech-based PC1 correlates 0.918 with Voteview party averages (1921–2016).

Next row: We read 85.66% agreement on party-term pair orderings.

Answer: We can read PC1 as a left–right scale in this overlapping period. Agreement varies across benchmarks.

Validate the positions outside the model

Case 1 · Party positions

Table comparing party placement against Voteview roll-call scores, expert surveys and three manifesto-based measures. Red outlines mark the U.S. House column and the two Voteview results, a correlation of 0.918 and pairwise ordering agreement of 85.66 percent.

U.S. House Speech-based PC1 correlates 0.918 with Voteview party averages (1921–2016).

Next row: We read 85.66% agreement on party-term pair orderings.

Answer: We can read PC1 as a left–right scale in this overlapping period. Agreement varies across benchmarks.

Case 2 · The changing meaning of equality

Case 2 · Semantic change

Cambridge Core article webpage showing the Political Analysis cover, the full title of A Timely Intervention, its online publication date of 25 July 2019, and author Emma Rodman.

Emma Rodman

Political Analysis, 2020 · Cambridge article page

  • Background The word equality persists while debates about it change.
  • Question Which groups and issues are associated with equality in different eras?
  • Texts 3,105 news items from the New York Times Article API with equality in the headline, 1855–2016.

Newspaper contexts become historical evidence

Case 2 · Semantic change

How embeddings are used

Research step What Rodman does
Collect contexts Use headlines, abstracts and first paragraphs when available. Group the items into seven eras.
Estimate embeddings Compare four Word2Vec training schemes. Each produces word vectors by era.
Track associations Compute cosine between equality and selected words within each era. Follow those scores across eras.

Newspaper contexts become historical evidence

Case 2 · Semantic change

How embeddings are used

Research step What Rodman does
Collect contexts Use headlines, abstracts and first paragraphs when available. Group the items into seven eras.
Estimate embeddings Compare four Word2Vec training schemes. Each produces word vectors by era.
Track associations Compute cosine between equality and selected words within each era. Follow those scores across eras.

Newspaper contexts become historical evidence

Case 2 · Semantic change

How embeddings are used

Research step What Rodman does
Collect contexts Use headlines, abstracts and first paragraphs when available. Group the items into seven eras.
Estimate embeddings Compare four Word2Vec training schemes. Each produces word vectors by era.
Track associations Compute cosine between equality and selected words within each era. Follow those scores across eras.

Compare time-sensitive word vectors

Case 2 · Semantic change

Table comparing four time-sensitive Word2Vec models. The outlined chronologically trained model has the smallest deviance and squared deviance and the highest correlation, 0.611, with the study's benchmark.

Read the columns: We look for lower deviations and higher correlation with the benchmark.

Compare the row: The chronological row has the highest correlation (0.611) and lowest deviations.

Choose a model: This model most closely matches five human-coded topic trends. Rodman then traces a new word pair.

Compare time-sensitive word vectors

Case 2 · Semantic change

Table comparing four time-sensitive Word2Vec models. The outlined chronologically trained model has the smallest deviance and squared deviance and the highest correlation, 0.611, with the study's benchmark.

Read the columns: We look for lower deviations and higher correlation with the benchmark.

Compare the row: The chronological row has the highest correlation (0.611) and lowest deviations.

Choose a model: This model most closely matches five human-coded topic trends. Rodman then traces a new word pair.

Compare time-sensitive word vectors

Case 2 · Semantic change

Table comparing four time-sensitive Word2Vec models. The outlined chronologically trained model has the smallest deviance and squared deviance and the highest correlation, 0.611, with the study's benchmark.

Read the columns: We look for lower deviations and higher correlation with the benchmark.

Compare the row: The chronological row has the highest correlation (0.611) and lowest deviations.

Choose a model: This model most closely matches five human-coded topic trends. Rodman then traces a new word pair.

Read semantic change with historical evidence

Case 2 · Semantic change

Cosine similarity between equality and social across seven eras with 95 percent confidence intervals. Red circles mark about 0.48 in 1855–1879, the low point of 0.19 in 1955–1979, and the partial rebound to 0.30 in 2005–2016.

Read: We start with a social–equality cosine of .48 in 1855–1879.

Discuss: We see a fall to .19, then a rebound to .30. Does the rebound show the earlier use continues?

Read semantic change with historical evidence

Case 2 · Semantic change

Cosine similarity between equality and social across seven eras with 95 percent confidence intervals. Red circles mark about 0.48 in 1855–1879, the low point of 0.19 in 1955–1979, and the partial rebound to 0.30 in 2005–2016.

Read: We start with a social–equality cosine of .48 in 1855–1879.

Discuss: We see a fall to .19, then a rebound to .30. Does the rebound show the earlier use continues?

Read semantic change with historical evidence

Case 2 · Semantic change

Cosine similarity between equality and social across seven eras with 95 percent confidence intervals. Red circles mark about 0.48 in 1855–1879, the low point of 0.19 in 1955–1979, and the partial rebound to 0.30 in 2005–2016.

Read: We start with a social–equality cosine of .48 in 1855–1879.

Discuss: We see a fall to .19, then a rebound to .30. Does the rebound show the earlier use continues?

Check passages Early uses could oppose interracial intimacy. Later news also connects social equality to social justice and institutional access.

Case 3 · Nostalgia in party manifestos

Case 3 · Nostalgia

Cambridge Core article page showing the British Journal of Political Science cover, the Nostalgia in European Party Politics title, and authors Stefan Müller and Sven-Oliver Proksch. The page records online publication in November 2023.

Stefan Müller and Sven-Oliver Proksch

British Journal of Political Science, 2024 · Cambridge article page

  • Background A reference to the past can express praise, criticism or nostalgia.
  • Question Do culturally conservative parties appeal more to a better past?
  • Texts 1,648 manifestos from 24 European countries, 1946–2018.

From word neighbours to a nostalgia measure

Case 3 · Nostalgia

How embeddings are used

Original Figure 1, panels 1 and 2. Red boxes identify the two sources of embeddings and the expanded dictionary. Human coders screen the nearest terms before adding them to the base dictionary.

1. Find candidates Search for neighbours of seed terms in pretrained GloVe and vectors trained on manifestos.

2. Screen candidates Three coders review the neighbours. Accepted terms form an embeddings-based dictionary.

3. Score manifestos The bottom box combines both dictionaries. Flagged sentences per 1,000 become the outcome for comparing parties.

From word neighbours to a nostalgia measure

Case 3 · Nostalgia

How embeddings are used

Original Figure 1, panels 1 and 2. Red boxes identify the two sources of embeddings and the expanded dictionary. Human coders screen the nearest terms before adding them to the base dictionary.

1. Find candidates Search for neighbours of seed terms in pretrained GloVe and vectors trained on manifestos.

2. Screen candidates Three coders review the neighbours. Accepted terms form an embeddings-based dictionary.

3. Score manifestos The bottom box combines both dictionaries. Flagged sentences per 1,000 become the outcome for comparing parties.

From word neighbours to a nostalgia measure

Case 3 · Nostalgia

How embeddings are used

Original Figure 1, panels 1 and 2. Red boxes identify the two sources of embeddings and the expanded dictionary. Human coders screen the nearest terms before adding them to the base dictionary.

1. Find candidates Search for neighbours of seed terms in pretrained GloVe and vectors trained on manifestos.

2. Screen candidates Three coders review the neighbours. Accepted terms form an embeddings-based dictionary.

3. Score manifestos The bottom box combines both dictionaries. Flagged sentences per 1,000 become the outcome for comparing parties.

Validate the measurement before comparing parties

Case 3 · Nostalgia

Original Figure 2 compares nostalgia measures across 50 manifestos. Boxes mark the two-coder row and its correlations of .61 for the base dictionary, .54 for the expanded dictionary, .87 for SVM and .86 for DistilBERT.

Methods. We compare manifesto scores from dictionaries (M1–M4) and sentence classifiers (M5–M6), using 50 manifestos.

Discuss. We compare base .61 with expanded .54 against two coders. Which agrees more closely?

Validate the measurement before comparing parties

Case 3 · Nostalgia

Original Figure 2 compares nostalgia measures across 50 manifestos. Boxes mark the two-coder row and its correlations of .61 for the base dictionary, .54 for the expanded dictionary, .87 for SVM and .86 for DistilBERT.

Methods. We compare manifesto scores from dictionaries (M1–M4) and sentence classifiers (M5–M6), using 50 manifestos.

Discuss. We compare base .61 with expanded .54 against two coders. Which agrees more closely?

Validate the measurement before comparing parties

Case 3 · Nostalgia

Original Figure 2 compares nostalgia measures across 50 manifestos. Boxes mark the two-coder row and its correlations of .61 for the base dictionary, .54 for the expanded dictionary, .87 for SVM and .86 for DistilBERT.

Methods. We compare manifesto scores from dictionaries (M1–M4) and sentence classifiers (M5–M6), using 50 manifestos.

Discuss. We compare base .61 with expanded .54 against two coders. Which agrees more closely?

Check. We see lower agreement after expansion. SVM: .87; DistilBERT: .86.

Compare parties across six measures

Case 3 · Nostalgia

Original Table 1 compares six models with standardized nostalgia outcomes. The marked M2 and M4 use the expanded dictionary. The boxed cultural conservatism coefficients are positive and range from .07 to .10 across the six models. Each has 1,588 observations.

Columns use six standardized nostalgia scores. M2 uses the expanded dictionary. M4 also requires positive sentiment.

Boxed row. We read .08 in M2 and .07 in M4.

One point higher on cultural conservatism is associated with .07–.10 SD more manifesto nostalgia across the six models, adjusting for other variables.

Compare parties across six measures

Case 3 · Nostalgia

Original Table 1 compares six models with standardized nostalgia outcomes. The marked M2 and M4 use the expanded dictionary. The boxed cultural conservatism coefficients are positive and range from .07 to .10 across the six models. Each has 1,588 observations.

Columns use six standardized nostalgia scores. M2 uses the expanded dictionary. M4 also requires positive sentiment.

Boxed row. We read .08 in M2 and .07 in M4.

One point higher on cultural conservatism is associated with .07–.10 SD more manifesto nostalgia across the six models, adjusting for other variables.

Compare parties across six measures

Case 3 · Nostalgia

Original Table 1 compares six models with standardized nostalgia outcomes. The marked M2 and M4 use the expanded dictionary. The boxed cultural conservatism coefficients are positive and range from .07 to .10 across the six models. Each has 1,588 observations.

Columns use six standardized nostalgia scores. M2 uses the expanded dictionary. M4 also requires positive sentiment.

Boxed row. We read .08 in M2 and .07 in M4.

One point higher on cultural conservatism is associated with .07–.10 SD more manifesto nostalgia across the six models, adjusting for other variables.

Same word, different contexts

Case 4 · Method intuition · 1/3

The same word Contextual clues and interpretation
chips · UK use Ketchup, knife and fork suggest hot fries.
chips · US use A bag suggests potato crisps.

Meaning here: we compare patterns of use. These are constructed examples.

Same word, different contexts

Case 4 · Method intuition · 1/3

The same word Contextual clues and interpretation
chips · UK use Ketchup, knife and fork suggest hot fries.
chips · US use A bag suggests potato crisps.

Meaning here: we compare patterns of use. These are constructed examples.

Same word, different contexts

Case 4 · Method intuition · 1/3

The same word Contextual clues and interpretation
chips · UK use Ketchup, knife and fork suggest hot fries.
chips · US use A bag suggests potato crisps.

Meaning here: we compare patterns of use. These are constructed examples.

A context becomes an ALC vector

Case 4 · Method intuition · 2/3

Step What the model uses
1 · Look up context words We use their vectors from one pretrained space.
2 · Average 𝐮i=1|Ci|∑w∈Ci𝐯w\mathbf u_i=\frac{1}{|C_i|}\sum_{w\in C_i}\mathbf v_w for this occurrence’s surrounding words.
3 · Calibrate 𝐲i=A𝐮i\mathbf y_i=A\mathbf u_i. A learned linear transformation corrects the context average.

One use → one vector. Different uses can receive different representations in the same space.

A context becomes an ALC vector

Case 4 · Method intuition · 2/3

Step What the model uses
1 · Look up context words We use their vectors from one pretrained space.
2 · Average 𝐮i=1|Ci|∑w∈Ci𝐯w\mathbf u_i=\frac{1}{|C_i|}\sum_{w\in C_i}\mathbf v_w for this occurrence’s surrounding words.
3 · Calibrate 𝐲i=A𝐮i\mathbf y_i=A\mathbf u_i. A learned linear transformation corrects the context average.

One use → one vector. Different uses can receive different representations in the same space.

A context becomes an ALC vector

Case 4 · Method intuition · 2/3

Step What the model uses
1 · Look up context words We use their vectors from one pretrained space.
2 · Average 𝐮i=1|Ci|∑w∈Ci𝐯w\mathbf u_i=\frac{1}{|C_i|}\sum_{w\in C_i}\mathbf v_w for this occurrence’s surrounding words.
3 · Calibrate 𝐲i=A𝐮i\mathbf y_i=A\mathbf u_i. A learned linear transformation corrects the context average.

One use → one vector. Different uses can receive different representations in the same space.

A context becomes an ALC vector

Case 4 · Method intuition · 2/3

Step What the model uses
1 · Look up context words We use their vectors from one pretrained space.
2 · Average 𝐮i=1|Ci|∑w∈Ci𝐯w\mathbf u_i=\frac{1}{|C_i|}\sum_{w\in C_i}\mathbf v_w for this occurrence’s surrounding words.
3 · Calibrate 𝐲i=A𝐮i\mathbf y_i=A\mathbf u_i. A learned linear transformation corrects the context average.

One use → one vector. Different uses can receive different representations in the same space.

The context vector is the regression outcome

Case 4 · Method intuition · 3/3

Observation: one use of chips. Outcome: its DD-coordinate context vector.

𝐲i=𝛃0+UKi𝛃UK+𝛜i.\mathbf y_i=\boldsymbol\beta_0+UK_i\boldsymbol\beta_{UK}+\boldsymbol\epsilon_i.

UKiUK_i: US = 0, UK = 1. Both coefficients are DD-coordinate vectors.

Read the result: we use coefficient length for the size of the difference, then neighbours and passages to interpret it. Permutations assess uncertainty.

Next: we replace English variety with party labels and study immigration.

The context vector is the regression outcome

Case 4 · Method intuition · 3/3

Observation: one use of chips. Outcome: its DD-coordinate context vector.

𝐲i=𝛃0+UKi𝛃UK+𝛜i.\mathbf y_i=\boldsymbol\beta_0+UK_i\boldsymbol\beta_{UK}+\boldsymbol\epsilon_i.

UKiUK_i: US = 0, UK = 1. Both coefficients are DD-coordinate vectors.

Read the result: we use coefficient length for the size of the difference, then neighbours and passages to interpret it. Permutations assess uncertainty.

Next: we replace English variety with party labels and study immigration.

The context vector is the regression outcome

Case 4 · Method intuition · 3/3

Observation: one use of chips. Outcome: its DD-coordinate context vector.

𝐲i=𝛃0+UKi𝛃UK+𝛜i.\mathbf y_i=\boldsymbol\beta_0+UK_i\boldsymbol\beta_{UK}+\boldsymbol\epsilon_i.

UKiUK_i: US = 0, UK = 1. Both coefficients are DD-coordinate vectors.

Read the result: we use coefficient length for the size of the difference, then neighbours and passages to interpret it. Permutations assess uncertainty.

Next: we replace English variety with party labels and study immigration.

The context vector is the regression outcome

Case 4 · Method intuition · 3/3

Observation: one use of chips. Outcome: its DD-coordinate context vector.

𝐲i=𝛃0+UKi𝛃UK+𝛜i.\mathbf y_i=\boldsymbol\beta_0+UK_i\boldsymbol\beta_{UK}+\boldsymbol\epsilon_i.

UKiUK_i: US = 0, UK = 1. Both coefficients are DD-coordinate vectors.

Read the result: we use coefficient length for the size of the difference, then neighbours and passages to interpret it. Permutations assess uncertainty.

Next: we replace English variety with party labels and study immigration.

Case 4 · How parties use immigration

Case 4 · Embedding regression

Cambridge Core article page showing the American Political Science Review cover, the Embedding Regression title, and authors Pedro L. Rodriguez, Arthur Spirling and Brandon M. Stewart.

Pedro L. Rodriguez, Arthur Spirling and Brandon M. Stewart

American Political Science Review, 2023 · Cambridge article page

  • Background Parties can mention immigration equally often while using it in different contexts.
  • Question How does the use of the same word vary by party and gender?
  • Texts U.S. Congressional Record, 111th–114th Congresses.

conText: from contexts to regression

Case 4 · Embedding regression

conText · Official Quick Start

Official conText Quick Start introduction and R call for immigration regressed on party and gender. The package's current numerical output is excluded from this screenshot.

fit <- conText::conText(
  immigration ~ party + gender,
  data = toks, pre_trained = E,
  transform = TRUE,
  transform_matrix = A)

toks: text + metadata. E and A: a matched pair.

1 · One occurrence, one row. We keep context, party and gender. nn uses give an n×Dn\times D outcome matrix YY.

2 · Build the outcome vector. We average context-word vectors, excluding the target, then apply the common ALC transformation.

𝐮i=meanw∈Ci𝐯w,𝐲i=A𝐮i.\mathbf u_i=\operatorname{mean}_{w\in C_i}\mathbf v_w,\qquad \mathbf y_i=A\mathbf u_i.

3 · Regress all coordinates. RR: Republican; MM: male.

𝐲i=𝛂+Ri𝛃R+Mi𝛃M+𝛜i.\mathbf y_i=\boldsymbol\alpha+R_i\boldsymbol\beta_R+M_i\boldsymbol\beta_M+\boldsymbol\epsilon_i.

𝐲i\mathbf y_i, 𝛂\boldsymbol\alpha, 𝛃R\boldsymbol\beta_R and 𝛃M\boldsymbol\beta_M each have DD entries.

4 · Read the coefficients. 𝛂\boldsymbol\alpha (earlier 𝛃0\boldsymbol\beta_0) is the Democrat/female reference; 𝛃R\boldsymbol\beta_R compares parties at fixed gender. We plot lengths and combine coefficients for group neighbours.

conText: from contexts to regression

Case 4 · Embedding regression

conText · Official Quick Start

Official conText Quick Start introduction and R call for immigration regressed on party and gender. The package's current numerical output is excluded from this screenshot.

fit <- conText::conText(
  immigration ~ party + gender,
  data = toks, pre_trained = E,
  transform = TRUE,
  transform_matrix = A)

toks: text + metadata. E and A: a matched pair.

1 · One occurrence, one row. We keep context, party and gender. nn uses give an n×Dn\times D outcome matrix YY.

2 · Build the outcome vector. We average context-word vectors, excluding the target, then apply the common ALC transformation.

𝐮i=meanw∈Ci𝐯w,𝐲i=A𝐮i.\mathbf u_i=\operatorname{mean}_{w\in C_i}\mathbf v_w,\qquad \mathbf y_i=A\mathbf u_i.

3 · Regress all coordinates. RR: Republican; MM: male.

𝐲i=𝛂+Ri𝛃R+Mi𝛃M+𝛜i.\mathbf y_i=\boldsymbol\alpha+R_i\boldsymbol\beta_R+M_i\boldsymbol\beta_M+\boldsymbol\epsilon_i.

𝐲i\mathbf y_i, 𝛂\boldsymbol\alpha, 𝛃R\boldsymbol\beta_R and 𝛃M\boldsymbol\beta_M each have DD entries.

4 · Read the coefficients. 𝛂\boldsymbol\alpha (earlier 𝛃0\boldsymbol\beta_0) is the Democrat/female reference; 𝛃R\boldsymbol\beta_R compares parties at fixed gender. We plot lengths and combine coefficients for group neighbours.

conText: from contexts to regression

Case 4 · Embedding regression

conText · Official Quick Start

Official conText Quick Start introduction and R call for immigration regressed on party and gender. The package's current numerical output is excluded from this screenshot.

fit <- conText::conText(
  immigration ~ party + gender,
  data = toks, pre_trained = E,
  transform = TRUE,
  transform_matrix = A)

toks: text + metadata. E and A: a matched pair.

1 · One occurrence, one row. We keep context, party and gender. nn uses give an n×Dn\times D outcome matrix YY.

2 · Build the outcome vector. We average context-word vectors, excluding the target, then apply the common ALC transformation.

𝐮i=meanw∈Ci𝐯w,𝐲i=A𝐮i.\mathbf u_i=\operatorname{mean}_{w\in C_i}\mathbf v_w,\qquad \mathbf y_i=A\mathbf u_i.

3 · Regress all coordinates. RR: Republican; MM: male.

𝐲i=𝛂+Ri𝛃R+Mi𝛃M+𝛜i.\mathbf y_i=\boldsymbol\alpha+R_i\boldsymbol\beta_R+M_i\boldsymbol\beta_M+\boldsymbol\epsilon_i.

𝐲i\mathbf y_i, 𝛂\boldsymbol\alpha, 𝛃R\boldsymbol\beta_R and 𝛃M\boldsymbol\beta_M each have DD entries.

4 · Read the coefficients. 𝛂\boldsymbol\alpha (earlier 𝛃0\boldsymbol\beta_0) is the Democrat/female reference; 𝛃R\boldsymbol\beta_R compares parties at fixed gender. We plot lengths and combine coefficients for group neighbours.

conText: from contexts to regression

Case 4 · Embedding regression

conText · Official Quick Start

Official conText Quick Start introduction and R call for immigration regressed on party and gender. The package's current numerical output is excluded from this screenshot.

fit <- conText::conText(
  immigration ~ party + gender,
  data = toks, pre_trained = E,
  transform = TRUE,
  transform_matrix = A)

toks: text + metadata. E and A: a matched pair.

1 · One occurrence, one row. We keep context, party and gender. nn uses give an n×Dn\times D outcome matrix YY.

2 · Build the outcome vector. We average context-word vectors, excluding the target, then apply the common ALC transformation.

𝐮i=meanw∈Ci𝐯w,𝐲i=A𝐮i.\mathbf u_i=\operatorname{mean}_{w\in C_i}\mathbf v_w,\qquad \mathbf y_i=A\mathbf u_i.

3 · Regress all coordinates. RR: Republican; MM: male.

𝐲i=𝛂+Ri𝛃R+Mi𝛃M+𝛜i.\mathbf y_i=\boldsymbol\alpha+R_i\boldsymbol\beta_R+M_i\boldsymbol\beta_M+\boldsymbol\epsilon_i.

𝐲i\mathbf y_i, 𝛂\boldsymbol\alpha, 𝛃R\boldsymbol\beta_R and 𝛃M\boldsymbol\beta_M each have DD entries.

4 · Read the coefficients. 𝛂\boldsymbol\alpha (earlier 𝛃0\boldsymbol\beta_0) is the Democrat/female reference; 𝛃R\boldsymbol\beta_R compares parties at fixed gender. We plot lengths and combine coefficients for group neighbours.

Compare party and gender differences

Case 4 · Embedding regression

Original Figure 5. Triangles show party contrasts and dots show gender contrasts. The marked immigration estimates are .175 for party and .087 for gender. Party estimates are larger for each of the three political targets.

Height. The adjusted difference vector’s length: 0 = no vector difference. Larger = greater difference. Bars: 95% bootstrap intervals.

Compare. For immigration, we read party .175 at fixed gender and gender .087 at fixed party. Both are vector lengths.

Answer. We see larger estimated usage gaps by party for all three political terms.

Compare party and gender differences

Case 4 · Embedding regression

Original Figure 5. Triangles show party contrasts and dots show gender contrasts. The marked immigration estimates are .175 for party and .087 for gender. Party estimates are larger for each of the three political targets.

Height. The adjusted difference vector’s length: 0 = no vector difference. Larger = greater difference. Bars: 95% bootstrap intervals.

Compare. For immigration, we read party .175 at fixed gender and gender .087 at fixed party. Both are vector lengths.

Answer. We see larger estimated usage gaps by party for all three political terms.

Compare party and gender differences

Case 4 · Embedding regression

Original Figure 5. Triangles show party contrasts and dots show gender contrasts. The marked immigration estimates are .175 for party and .087 for gender. Party estimates are larger for each of the three political targets.

Height. The adjusted difference vector’s length: 0 = no vector difference. Larger = greater difference. Bars: 95% bootstrap intervals.

Compare. For immigration, we read party .175 at fixed gender and gender .087 at fixed party. Both are vector lengths.

Answer. We see larger estimated usage gaps by party for all three political terms.

What do group differences contain?

Case 4 · Embedding regression

Original Table 4 ranks ten neighbours of the immigration vector for each party. The boxes mark overhauling and reform for Democrats, and enforce and laws for Republicans. Both lists contain enact and legislation.

Read each row. Each row lists the ten words closest by cosine to that party’s estimated immigration vector.

Interpret the boxes. We see changing the system near Democrats and enforcing existing law near Republicans.

We also see enact and legislation in both rows. Next, we check the passages.

What do group differences contain?

Case 4 · Embedding regression

Original Table 4 ranks ten neighbours of the immigration vector for each party. The boxes mark overhauling and reform for Democrats, and enforce and laws for Republicans. Both lists contain enact and legislation.

Read each row. Each row lists the ten words closest by cosine to that party’s estimated immigration vector.

Interpret the boxes. We see changing the system near Democrats and enforcing existing law near Republicans.

We also see enact and legislation in both rows. Next, we check the passages.

What do group differences contain?

Case 4 · Embedding regression

Original Table 4 ranks ten neighbours of the immigration vector for each party. The boxes mark overhauling and reform for Democrats, and enforce and laws for Republicans. Both lists contain enact and legislation.

Read each row. Each row lists the ten words closest by cosine to that party’s estimated immigration vector.

Interpret the boxes. We see changing the system near Democrats and enforcing existing law near Republicans.

We also see enact and legislation in both rows. Next, we check the passages.

Return to the original contexts

Case 4 · Embedding regression

Original Table 5 shows two contexts per party near the party's estimated immigration vector. The boxed Democratic excerpt calls for comprehensive immigration reform. The boxed Republican excerpt discusses enforcement of immigration laws.

Read the party labels. We read passages close to each party’s estimated vector.

Answer. We see reform in the Democratic passage and enforcement in the Republican passage.

Scope. These passages illustrate the contrast. To estimate frequency, we need a broader sample.

Return to the original contexts

Case 4 · Embedding regression

Original Table 5 shows two contexts per party near the party's estimated immigration vector. The boxed Democratic excerpt calls for comprehensive immigration reform. The boxed Republican excerpt discusses enforcement of immigration laws.

Read the party labels. We read passages close to each party’s estimated vector.

Answer. We see reform in the Democratic passage and enforcement in the Republican passage.

Scope. These passages illustrate the contrast. To estimate frequency, we need a broader sample.

Return to the original contexts

Case 4 · Embedding regression

Original Table 5 shows two contexts per party near the party's estimated immigration vector. The boxed Democratic excerpt calls for comprehensive immigration reform. The boxed Republican excerpt discusses enforcement of immigration laws.

Read the party labels. We read passages close to each party’s estimated vector.

Answer. We see reform in the Democratic passage and enforcement in the Republican passage.

Scope. These passages illustrate the contrast. To estimate frequency, we need a broader sample.

Embedding regression beyond English

Case 4 · Multilingual extension

Cambridge Core journal article title and authors for Wirsching and colleagues' multilingual ALC resources in Political Analysis.

Original Figure 1 checks ALC reconstruction against pretrained vectors within each language. The horizontal axis separates fastText and GloVe architectures; the vertical axis is cosine similarity between an ALC estimate and its corresponding pretrained word vector. Coloured circles show 100 sampled terms per language, and diamonds mark language means. Colours identify languages. This is within-language, within-architecture reconstruction, not evidence that different languages share an aligned vector space.

We compare ALC estimates with pretrained vectors within each language.

Four studies using embedding regression

Case 4 · Further applications

Wiley article heading for Gonthier's 2025 Swiss Political Science Review study of the Yellow Vests and the meaning of peuple.

Gonthier (2025) · SPSR
French peuple across ideological groups.

Sage article heading for Karell and Sachs's 2023 Socius study of symbolic signals around Trump's return to Twitter.

Karell & Sachs (2023) · Socius
Minority-group language before/after a signal.

Wiley Policy Studies Journal article heading for Van Matre, Krakoff and Fullerton's climate-framing study, published online in 2025 and in the 2026 volume.

Van Matre et al. (2026) · PSJ
Climate frames by party and congressional term.

Journal of Online Trust and Safety article heading for Kim and Kesari's 2021 study of anti-Asian hate speech during COVID-19.

Kim & Kesari (2021) · JOTS
“Chinese virus”: hate/counterhate and time.

Study notes and DOI links · W10 comparison: supplement

Four studies using embedding regression

Case 4 · Further applications

Wiley article heading for Gonthier's 2025 Swiss Political Science Review study of the Yellow Vests and the meaning of peuple.

Gonthier (2025) · SPSR
French peuple across ideological groups.

Sage article heading for Karell and Sachs's 2023 Socius study of symbolic signals around Trump's return to Twitter.

Karell & Sachs (2023) · Socius
Minority-group language before/after a signal.

Wiley Policy Studies Journal article heading for Van Matre, Krakoff and Fullerton's climate-framing study, published online in 2025 and in the 2026 volume.

Van Matre et al. (2026) · PSJ
Climate frames by party and congressional term.

Journal of Online Trust and Safety article heading for Kim and Kesari's 2021 study of anti-Asian hate speech during COVID-19.

Kim & Kesari (2021) · JOTS
“Chinese virus”: hate/counterhate and time.

Study notes and DOI links · W10 comparison: supplement

Four studies using embedding regression

Case 4 · Further applications

Wiley article heading for Gonthier's 2025 Swiss Political Science Review study of the Yellow Vests and the meaning of peuple.

Gonthier (2025) · SPSR
French peuple across ideological groups.

Sage article heading for Karell and Sachs's 2023 Socius study of symbolic signals around Trump's return to Twitter.

Karell & Sachs (2023) · Socius
Minority-group language before/after a signal.

Wiley Policy Studies Journal article heading for Van Matre, Krakoff and Fullerton's climate-framing study, published online in 2025 and in the 2026 volume.

Van Matre et al. (2026) · PSJ
Climate frames by party and congressional term.

Journal of Online Trust and Safety article heading for Kim and Kesari's 2021 study of anti-Asian hate speech during COVID-19.

Kim & Kesari (2021) · JOTS
“Chinese virus”: hate/counterhate and time.

Study notes and DOI links · W10 comparison: supplement

Four studies using embedding regression

Case 4 · Further applications

Wiley article heading for Gonthier's 2025 Swiss Political Science Review study of the Yellow Vests and the meaning of peuple.

Gonthier (2025) · SPSR
French peuple across ideological groups.

Sage article heading for Karell and Sachs's 2023 Socius study of symbolic signals around Trump's return to Twitter.

Karell & Sachs (2023) · Socius
Minority-group language before/after a signal.

Wiley Policy Studies Journal article heading for Van Matre, Krakoff and Fullerton's climate-framing study, published online in 2025 and in the 2026 volume.

Van Matre et al. (2026) · PSJ
Climate frames by party and congressional term.

Journal of Online Trust and Safety article heading for Kim and Kesari's 2021 study of anti-Asian hate speech during COVID-19.

Kim & Kesari (2021) · JOTS
“Chinese virus”: hate/counterhate and time.

Study notes and DOI links · W10 comparison: supplement

Lab guide · Know the workflow before the break

Guide 1/3 · Goal and plan · 17:31–17:32

Goal: We learn what a vector represents, how to compare it and how to check our interpretation.

Classroom block What the vector represents Short Check
17:40–17:55 · Our 2024 Lab A static vector for each word type; then a PCA projection. E06: matrix units and identical security vectors. PCA Check: what the map leaves out.
17:55–18:10 · conText A vector for each occurrence’s context; then a conditional group comparison. E04: unit → word/context evidence → party coefficient.

We read a short Code example, examine its Output and answer a Check. The Lab includes the full runnable steps.

Lab guide · Know the workflow before the break

Guide 2/3 · Our 2024 Flair/PCA workflow · 17:32–17:33:30

Step Read the input and output What it tells us
1 · Load R/Python environment + cached GloVe → 100 coordinates. We load a trained model.
2 · Get vectors Eleven listed words → 11 × 100 matrix. One row per token in the word list.
3 · Compare security Three sentences → 3 × 100 security matrix; cosine 1. Static lookup returns the same word-type vector.
4 · Read PCA The same eleven vectors → table + 2D + 3D; PC1/2 retain 38.24%. We distinguish this projection from full-space cosine.

E06: explain the two matrix sizes and cosine 1. PCA Check: does proximity on the map guarantee full-space similarity?

Lab guide · Know the workflow before the break

Guide 3/3 · conText workflow · 17:33:30–17:35

Step Read the input and output
C00 · Inputs 400 texts + E: 500 × 300 word vectors + matched A: 300 × 300.
C01 · Contexts Each immigration occurrence and its metadata → 924 context rows.
C02 · ALC Surrounding words + E/A → 924 × 300 context vectors → 2 × 300 party means.
C03–04 · Interpret We check our reading of nearby words against retrieved context words.
C05 · Regression We return to occurrences and compare R with D, holding gender fixed.

E04: How do we connect an observation, its word/context evidence and the party coefficient? Regression adds adjustment for gender.

Next: we take five minutes and begin Flair at 17:40.

Five-minute break

We return at 17:40 for Flair preparation, with the Lab handout beside the slides.

30-minute Lab: Our 2024 Flair exercise and plots (15 min) → conText Quick Start (15 min).

We read each core call, examine its output and answer a short Check.

After class: full PCA computation and advanced extensions.

Lab · Prepare Flair

17:40–17:42. We check the R/Python connection and cached model.

Before class, we prepare Python, packages and GloVe with Lab F00. From the course root:

source("W9/lab/flair/flair_prepare.R")

If R is unavailable, we use the Python route. Installation and downloads happen before class.

Lab · Flair 1: Load the model

17:42–17:44. We load GloVe in R or Python and check its dimensions.

We stay in the same session. glove_path points to the cached model file.

embedding <- WordEmbeddings(glove_path)
print(embedding$embedding_length)

Lab · Flair 2: Get word vectors

17:44–17:47. We create a Sentence, attach embeddings and read the coordinates. Python follows the same steps.

word_list <- paste("King Queen man woman Paris London",
  "apple orange Taiwan Dublin Bamberg")
word_sentence <- Sentence(word_list)
embedding$embed(word_sentence)
word_vectors <- do.call(rbind, lapply(word_sentence$tokens,
  function(token) as.numeric(token$embedding$tolist())))
print(dim(word_vectors))

Lab · Flair 3: Compare security

17:47–17:52. We compare three occurrences, then explain the result in E06 at 17:50–17:52.

We use the three sentences from the Lab. This call attaches vectors to their tokens.

embedding$embed(sentences)

Lab · PCA: Read the 2024 word-vector map

17:52–17:55. We read the 2D/3D figures now and leave the full computation for after class.

Core call · full steps are in the Lab.

pca_result <- prcomp(word_vectors,
  center = TRUE, scale. = TRUE)
round(pca_result$x[1:3, 1:2], 2)

Lab · C00: Text, vectors and a matched transformation

17:55–17:58. We now use conText, starting with its texts, vectors and matching transformation.

Core call · full steps are in the Lab.

print(c(documents = ndoc(cr_sample_corpus)))
print(rbind(E = dim(cr_glove_subset),
  A = dim(cr_transform)))

Lab · C01: Keep one occurrence per row

17:58–18:00. We extract immigration contexts and keep their party and gender labels.

Core call · full steps are in the Lab.

immig_toks <- tokens_context(toks_nostop_feats,
  pattern = "immigration", window = 6L, valuetype = "fixed",
  rm_keyword = TRUE)

Lab · C02: Turn contexts into ALC vectors

18:00–18:03. We turn each context into an ALC vector, then average by party.

Core call · full steps are in the Lab.

immig_dfm <- dfm(immig_toks)
immig_dem <- dem(immig_dfm, pre_trained = cr_glove_subset,
  transform = TRUE, transform_matrix = cr_transform,
  verbose = FALSE)
immig_wv_party <- dem_group(immig_dem,
  groups = immig_dem@docvars$party)

Lab · C03: Read the nearby words

18:03–18:05. We use nearby words to interpret the party averages.

Core call · full steps are in the Lab.

immig_nns <- nns(immig_wv_party,
  pre_trained = cr_glove_subset, N = 3,
  candidates = immig_wv_party@features, as_list = FALSE)

Lab · C04: Read the nearby contexts

18:05–18:07. We check that interpretation against the nearby contexts.

Core call · full steps are in the Lab.

immig_ncs <- ncs(immig_wv_party, contexts_dem = immig_dem,
  contexts = immig_toks, N = 1, as_list = FALSE)

Lab · C05: Introduce embedding regression

18:07–18:10. We return to occurrences and compare parties while holding gender fixed.

Core call · full steps are in the Lab.

set.seed(2021L)
fit <- conText(immigration ~ party + gender,
  data = toks_nostop_feats, pre_trained = cr_glove_subset,
  transform = TRUE, transform_matrix = cr_transform,
  jackknife = FALSE, permute = TRUE,
  num_permutations = 100, window = 6L,
  valuetype = "fixed", verbose = FALSE)

Design an embedding study in one paragraph

  1. We start with a political question and the unit that receives a vector.
  2. We choose the corpus, representation and comparison for that question.
  3. We identify evidence that could change our interpretation.

Our design. How might we compare a policy term across parties, periods or legislative settings?

Readings and classroom materials

Concepts and demonstrations

  • Grimmer, Roberts & Stewart (2022), Text as Data, Ch. 8. Ch. 7 covers similarity and TF–IDF.
  • Schoonvelde (2026), ESS Day 3, Comparing Representations.

Assigned studies

  • Bischof & Senninger (2018), campaign language and political knowledge.
  • Rodriguez & Spirling (2022), evaluating word embeddings.
  • Rodriguez, Spirling & Stewart (2023), embedding regression.

References

W9 assigned readings

Bischof & Senninger (2018) · EJPR · DOI
Simple Politics for the People? Complexity in Campaign Messages and Political Knowledge

Rodriguez & Spirling (2022) · JOP · DOI
Word Embeddings: What Works, What Doesn’t, and How to Tell the Difference for Applied Research

Rodriguez, Spirling & Stewart (2023) · APSR · Case 4 · DOI
Embedding Regression: Models for Context-Specific Description and Inference

W9 optional reading

Wirsching et al. (2025) · Political Analysis · DOI
Multilanguage Word Embeddings for Social Scientists: Estimation, Inference, and Validation Resources for 157 Languages

Additional W9 cases

Rheault & Cochrane (2020) · Political Analysis · Case 1 · DOI
Word Embeddings for the Analysis of Ideological Placement in Parliamentary Corpora

Rodman (2020) · Political Analysis · Case 2 · DOI
A Timely Intervention: Tracking the Changing Meanings of Political Concepts with Word Vectors

W10 optional readings used in W9

Müller & Proksch (2024) · BJPS · Case 3 · DOI
Nostalgia in European Party Politics: A Text-Based Measurement Approach

Widmann & Wich (2023) · Political Analysis · W10 comparison · DOI
Creating and Comparing Dictionary, Word Embedding, and Transformer-Based Models to Measure Discrete Emotions in German Political Text

Learn coordinates by predicting words

Schematic next-word network. Four stages mark the one-hot input, hidden coordinates Z1 and Z2, next-word probability output and the target attends, then feedback to connection weights. The nearby Trump and Biden points are illustrative word-use positions.

Input One active vocabulary position.

Hidden Learned coordinates z1,z2z_1,z_2.

Output Next-word probabilities; target: attends.

Update Error updates the connection weights.

The plotted positions are a teaching illustration.

Learn coordinates by predicting words

Schematic next-word network. Four stages mark the one-hot input, hidden coordinates Z1 and Z2, next-word probability output and the target attends, then feedback to connection weights. The nearby Trump and Biden points are illustrative word-use positions.

Input One active vocabulary position.

Hidden Learned coordinates z1,z2z_1,z_2.

Output Next-word probabilities; target: attends.

Update Error updates the connection weights.

The plotted positions are a teaching illustration.

Learn coordinates by predicting words

Schematic next-word network. Four stages mark the one-hot input, hidden coordinates Z1 and Z2, next-word probability output and the target attends, then feedback to connection weights. The nearby Trump and Biden points are illustrative word-use positions.

Input One active vocabulary position.

Hidden Learned coordinates z1,z2z_1,z_2.

Output Next-word probabilities; target: attends.

Update Error updates the connection weights.

The plotted positions are a teaching illustration.

Learn coordinates by predicting words

Schematic next-word network. Four stages mark the one-hot input, hidden coordinates Z1 and Z2, next-word probability output and the target attends, then feedback to connection weights. The nearby Trump and Biden points are illustrative word-use positions.

Input One active vocabulary position.

Hidden Learned coordinates z1,z2z_1,z_2.

Output Next-word probabilities; target: attends.

Update Error updates the connection weights.

The plotted positions are a teaching illustration.

What does each row represent?

The two ESS panels show a sparse document-by-feature matrix and a dense word-by-dimension embedding matrix.

Document counts give each speech a row of feature counts.

Static word embeddings give each word type a row of learned coordinates.

Which rows do we compare for two speeches? For two words?

Schoonvelde (2026), Comparing Representations, ESS Day 3, original p. 6, document and word panels. ESS materials and page map

Compute cosine for two speeches

Speech security forces energy
Defence 1 1 0
Energy 1 0 1

cos(𝐚,𝐛)=𝐚⋅𝐛∥𝐚∥∥𝐛∥=122=0.50\cos(\mathbf{a},\mathbf{b})=\frac{\mathbf{a}\cdot\mathbf{b}}{\lVert\mathbf{a}\rVert\lVert\mathbf{b}\rVert}=\frac{1}{\sqrt{2}\sqrt{2}}=0.50

Both speeches contain security. Each also contains a different feature.

Schoonvelde (2026), ESS Day 3, numerical example from original p. 10. ESS materials and page map

Average word vectors to represent a document

We average the available token vectors one coordinate at a time.

Token Coordinate 1 Coordinate 2
first token 1 0
second token 0 2
document mean 0.5 1.0

Repeated tokens contribute repeatedly to the simple average. The resulting vector summarizes the document.

Grimmer, Roberts & Stewart (2022), §8.3, pp. 86–87. Two-coordinate arithmetic constructed for W9.

The PCA map changes the nearest words

Zoomed PCA plot around security. Discussed is visibly closer to security than resolution in the two plotted dimensions.

On the two-dimensional map, discussed is closest to security.

Across all 30 dimensions, resolution has the highest cosine with security (0.661).

PC1 and PC2 retain 9.54% of the variance in this model’s unit vectors.

W9 teaching GloVe vectors · ESS Day 3, p. 19 · R05 PCA check · Plot source

How did presidents talk about manufacturing?

U.S. State of the Union addresses

The book compares 1900–1959 with 1960–2016. It finds 53 mentions of manufacturing across the two periods.

  1. Collect the words around each mention.
  2. Represent those words with pretrained embeddings.
  3. Average the context word vectors within each period and apply a learned linear transform to each average.

This à la carte procedure gives one 300-dimensional vector for manufacturing per period.

The neighbours of manufacturing change over time

Cosine distance ranks other words by their proximity to each period’s manufacturing vector.

1900–1959 1960–2016
exportation retooling
oil-related jobs
energy-intensive offshoring

The selected neighbours associate the term with trade and energy in the earlier period and restructuring and employment in the later one.

Validate the representation for its use

Evaluation Question
Intrinsic Do vector relationships agree with an external judgment about words?
Extrinsic Do the vectors help on a downstream task, such as predicting labels?
Substantive Does the comparison support the interpretation required by the research question?

For manufacturing, which passages could we read to check the period contrast?

W10 comparison: emotion measurement

W10 · Optional comparison

Widmann and Wich Figure 1: trained word embeddings support an expanded emotion dictionary and a neural-network classifier; ELECTRA is a separate transformer route.

Question Which models distinguish eight emotional appeals in German political text?

Data 9,898 annotated sentences from parliamentary speeches and party Facebook posts.

Routes Neighbours expand ed8; word2vec sentence averages feed a neural network. ELECTRA is fine-tuned on annotated sentences.

Test predictions against human coding

W10 · Optional comparison

Original Table 1 gives precision, recall, and F1 for eight emotions. Anger F1 is .59 for ed8, .79 for word embeddings with a neural network, and .84 for ELECTRA. Fear F1 is .52, .55, and .64.

F1 in the held-out sentences

Model Anger Fear
ed8 .59 .52
word2vec + NN .79 .55
ELECTRA .84 .64

The authors also tested a new random sample of sentences.

Four ways embeddings support an answer

Research goal What gets a vector How the study answers
1 · Locate parties A party in a legislative term PC1 gives a speech scale. Voteview helps interpret it.
2 · Track meaning A word in a historical period Cosine tracks associations. News passages show what changed.
3 · Measure nostalgia A seed term or candidate term Neighbours expand the dictionary. Its scores enter a regression.
4 · Compare word use One use of a target word Regression estimates the gap. Neighbours and passages explain it.

Evaluate embeddings for the task

Use of the vectors What to check
Features for prediction Performance on held-out texts or a new corpus
Measures of political language Human judgments, original passages and appropriate benchmarks
Comparisons across corpora Domain, vocabulary coverage and stability across model settings
Social associations Target and attribute sets, source-corpus composition and sensitivity of the comparison

Rodriguez and Spirling compare window sizes, dimensions, training runs and human judgments of word associations.

Campaign language and political knowledge

Question. Are voters closer to expert placements when parties use simpler manifestos?

  • Bischof and Senninger compare German and Austrian manifestos using LIX.
  • They compare voters’ left–right placements of parties with expert placements.
  • Simpler manifestos are associated with smaller placement gaps.

LIX and Flesch score text in opposite directions

Measure What it uses Higher score
LIX Mean words per sentence + percentage of long words More complex
Flesch Reading Ease Words per sentence and syllables per word Easier to read

A sentence split can change both scores while the policy proposal stays the same.