W9 · Word Embeddings and Political Language
2026-11-06Fall 2026 (115-1) · National Taiwan University (GIND)
NTLDEV 7191 · Fri. 16:30–18:20 · GIND 204
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.
| 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 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.
W8: issue attention · Teaching diagram after Hung-yi Lee · Grimmer, Roberts & Stewart (2022), Text as Data, Ch. 8, p. 78
| 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 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.
W8: issue attention · Teaching diagram after Hung-yi Lee · Grimmer, Roberts & Stewart (2022), Text as Data, Ch. 8, p. 78
| 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 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.
W8: issue attention · Teaching diagram after Hung-yi Lee · Grimmer, Roberts & Stewart (2022), Text as Data, Ch. 8, p. 78
| 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 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.
W8: issue attention · Teaching diagram after Hung-yi Lee · Grimmer, Roberts & Stewart (2022), Text as Data, Ch. 8, p. 78
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.
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.
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.
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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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
Ludovic Rheault and Christopher Cochrane
Political Analysis, 2020 · Cambridge article page
Case 1 · Party positions
How embeddings are used
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.
Case 1 · Party positions
How embeddings are used
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.
Case 1 · Party positions
How embeddings are used
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.
Case 1 · Party positions
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.
Case 1 · Party positions
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.
Case 1 · Party positions
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.
Case 1 · Party positions
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 1 · Party positions
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 1 · Party positions
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 · Semantic change
Emma Rodman
Political Analysis, 2020 · Cambridge article page
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. |
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. |
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. |
Case 2 · Semantic change
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.
Case 2 · Semantic change
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.
Case 2 · Semantic change
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.
Case 2 · Semantic change
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?
Case 2 · Semantic change
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?
Case 2 · Semantic change
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
Stefan Müller and Sven-Oliver Proksch
British Journal of Political Science, 2024 · Cambridge article page
W10 supplementary reading · Müller & Proksch (2024), BJPS 54(3), 993–1005
Case 3 · Nostalgia
How embeddings are used
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.
Case 3 · Nostalgia
How embeddings are used
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.
Case 3 · Nostalgia
How embeddings are used
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.
Case 3 · Nostalgia
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?
Case 3 · Nostalgia
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?
Case 3 · Nostalgia
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.
Case 3 · Nostalgia
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.
Case 3 · Nostalgia
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.
Case 3 · Nostalgia
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.
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.
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.
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.
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 | for this occurrence’s surrounding words. |
| 3 · Calibrate | . A learned linear transformation corrects the context average. |
One use → one vector. Different uses can receive different representations in the same space.
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 | for this occurrence’s surrounding words. |
| 3 · Calibrate | . A learned linear transformation corrects the context average. |
One use → one vector. Different uses can receive different representations in the same space.
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 | for this occurrence’s surrounding words. |
| 3 · Calibrate | . A learned linear transformation corrects the context average. |
One use → one vector. Different uses can receive different representations in the same space.
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 | for this occurrence’s surrounding words. |
| 3 · Calibrate | . A learned linear transformation corrects the context average. |
One use → one vector. Different uses can receive different representations in the same space.
Case 4 · Method intuition · 3/3
Observation: one use of chips. Outcome: its -coordinate context vector.
: US = 0, UK = 1. Both coefficients are -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 · Method intuition · 3/3
Observation: one use of chips. Outcome: its -coordinate context vector.
: US = 0, UK = 1. Both coefficients are -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 · Method intuition · 3/3
Observation: one use of chips. Outcome: its -coordinate context vector.
: US = 0, UK = 1. Both coefficients are -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 · Method intuition · 3/3
Observation: one use of chips. Outcome: its -coordinate context vector.
: US = 0, UK = 1. Both coefficients are -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 · Embedding regression
Pedro L. Rodriguez, Arthur Spirling and Brandon M. Stewart
American Political Science Review, 2023 · Cambridge article page
W9 core reading · Rodriguez, Spirling & Stewart (2023), APSR 117(4), 1255–1274
Case 4 · Embedding regression
conText · Official Quick Start
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. uses give an outcome matrix .
2 · Build the outcome vector. We average context-word vectors, excluding the target, then apply the common ALC transformation.
3 · Regress all coordinates. : Republican; : male.
, , and each have entries.
4 · Read the coefficients. (earlier ) is the Democrat/female reference; compares parties at fixed gender. We plot lengths and combine coefficients for group neighbours.
Case 4 · Embedding regression
conText · Official Quick Start
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. uses give an outcome matrix .
2 · Build the outcome vector. We average context-word vectors, excluding the target, then apply the common ALC transformation.
3 · Regress all coordinates. : Republican; : male.
, , and each have entries.
4 · Read the coefficients. (earlier ) is the Democrat/female reference; compares parties at fixed gender. We plot lengths and combine coefficients for group neighbours.
Case 4 · Embedding regression
conText · Official Quick Start
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. uses give an outcome matrix .
2 · Build the outcome vector. We average context-word vectors, excluding the target, then apply the common ALC transformation.
3 · Regress all coordinates. : Republican; : male.
, , and each have entries.
4 · Read the coefficients. (earlier ) is the Democrat/female reference; compares parties at fixed gender. We plot lengths and combine coefficients for group neighbours.
Case 4 · Embedding regression
conText · Official Quick Start
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. uses give an outcome matrix .
2 · Build the outcome vector. We average context-word vectors, excluding the target, then apply the common ALC transformation.
3 · Regress all coordinates. : Republican; : male.
, , and each have entries.
4 · Read the coefficients. (earlier ) is the Democrat/female reference; compares parties at fixed gender. We plot lengths and combine coefficients for group neighbours.
Case 4 · Embedding regression
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.
Case 4 · Embedding regression
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.
Case 4 · Embedding regression
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.
Case 4 · Embedding regression
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.
Case 4 · Embedding regression
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.
Case 4 · Embedding regression
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.
Case 4 · Embedding regression
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.
Case 4 · Embedding regression
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.
Case 4 · Embedding regression
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.
Case 4 · Multilingual extension
We compare ALC estimates with pretrained vectors within each language.
Case 4 · Further applications
Study notes and DOI links · W10 comparison: supplement
Case 4 · Further applications
Study notes and DOI links · W10 comparison: supplement
Case 4 · Further applications
Study notes and DOI links · W10 comparison: supplement
Case 4 · Further applications
Study notes and DOI links · W10 comparison: supplement
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.
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?
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.
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.
17:40–17:42. We check the R/Python connection and cached model.
| Route | Passing checkpoint |
|---|---|
| R | Import check passed; cached model path |
| Python | Imports OK. Device: CPU.; cached model path |
Ready to load the model. We have checked the connection and file path.
17:42–17:44. We load GloVe in R or Python and check its dimensions.
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))Matrix · 11 × 100. Each row is one token from the displayed word list; each column is a GloVe coordinate.
We use Sentence() to split the input, embed() to attach vectors and tolist() to read their numbers.
17:47–17:52. We compare three occurrences, then explain the result in E06 at 17:50–17:52.
Matrix · 3 × 100. We keep one security vector from each sentence.
| Constructed sentence | Static security vector |
|---|---|
| Social security supports households. | Same 100 coordinates |
| The United Nations Security Council met. | Same 100 coordinates |
| Energy security matters for jobs. | Same 100 coordinates |
Each security-pair cosine is 1.
E06 · 17:50–17:52. Explain both matrix sizes and why the security vectors are identical. If running the code, also note your route and versions.
R Step 3 · Python Step 3 · E06
17:52–17:55. We read the 2D/3D figures now and leave the full computation for after class.
17:55–17:58. We now use conText, starting with its texts, vectors and matching transformation.
| Object | Recorded input |
|---|---|
cr_sample_corpus |
400 speeches with metadata |
cr_glove_subset |
500 words × 300 coordinates |
cr_transform |
Matching 300 × 300 transformation |
Check: Which object contains the text? Which two must be a matched pair?
17:58–18:00. We extract immigration contexts and keep their party and gender labels.
924 contexts · D: 486 · R: 438.
| Pattern | Party | Gender |
|---|---|---|
| immigration | D | F |
| immigration | D | F |
| immigration | D | F |
Check: One row is one use of immigration, carrying its speech metadata.
18:00–18:03. We turn each context into an ALC vector, then average by party.
DEM · 924 × 300. One ALC context vector per row.
Party means · 2 × 300. We average contexts separately for D and R.
Check: We still have 300 coordinates. What does a row represent now?
18:03–18:05. We use nearby words to interpret the party averages.
D · cosine neighbours
immigration (0.848), broken (0.680), comprehensive (0.661)
R · cosine neighbours
immigration (0.875), illegal (0.708), enforcement (0.645)
Check: What difference in emphasis do we see? Next, we check a context.
18:05–18:07. We check that interpretation against the nearby contexts.
Near the D mean · cosine 0.802
end conversation passed immigration bill comprehensive bill clean broken immigration system year
Near the R mean · cosine 0.798
america suggest immigration can good thing illegal immigration legal immigration mean means
Check: We retrieved processed context words from a pool containing both parties.
18:07–18:10. We return to occurrences and compare parties while holding gender fixed.
Core call · full steps are in the Lab.
Coefficients · 3 × 300. Intercept, party_R and gender_M. Unlike the earlier party means, party_R adjusts for gender.
| Coefficient | Debiased squared norm | Permutation p |
|---|---|---|
party_R |
8.668 | 0 |
gender_M |
5.155 | 0 |
0 records 0 exceedances in 100 permutations.
E04 · Check: What does party_R compare at fixed gender? How can we explain the result using a neighbour and a context?
Our design. How might we compare a policy term across parties, periods or legislative settings?
Concepts and demonstrations
Assigned studies
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
Wirsching et al. (2025) · Political Analysis · DOI
Multilanguage Word Embeddings for Social Scientists: Estimation, Inference, and Validation Resources for 157 Languages
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
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
Input One active vocabulary position.
Hidden Learned coordinates .
Output Next-word probabilities; target: attends.
Update Error updates the connection weights.
The plotted positions are a teaching illustration.
Input One active vocabulary position.
Hidden Learned coordinates .
Output Next-word probabilities; target: attends.
Update Error updates the connection weights.
The plotted positions are a teaching illustration.
Input One active vocabulary position.
Hidden Learned coordinates .
Output Next-word probabilities; target: attends.
Update Error updates the connection weights.
The plotted positions are a teaching illustration.
Input One active vocabulary position.
Hidden Learned coordinates .
Output Next-word probabilities; target: attends.
Update Error updates the connection weights.
The plotted positions are a teaching illustration.
The book’s movie review example
We train a classifier on labeled reviews that use great.
A new review uses fantastic. What can we carry over if the two words have related vectors?
We can predict using word similarities learned from the training corpus.
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
| Speech | security | forces | energy |
|---|---|---|---|
| Defence | 1 | 1 | 0 |
| Energy | 1 | 0 | 1 |
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
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.
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
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.
This à la carte procedure gives one 300-dimensional vector for manufacturing per period.
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.
Selected reported neighbours from Grimmer, Roberts & Stewart (2022), Text as Data, §8.2.7, p. 85 and p. 86.
| 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 · Optional comparison
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.
W10 optional comparison reading · Widmann & Wich (2023), Figure 1, pp. 629–632 · Journal article heading
W10 · Optional comparison
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.
| 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. |
| 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.
Question. Are voters closer to expert placements when parties use simpler manifestos?
| 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.