Hostname: page-component-77f85d65b8-g98kq Total loading time: 0 Render date: 2026-03-27T17:49:20.809Z Has data issue: false hasContentIssue false

Stance detection: a practical guide to classifying political beliefs in text

Published online by Cambridge University Press:  19 September 2024

Michael Burnham*
Affiliation:
Department of Political Science, Pennsylvania State University, State College, PA, USA
*
Rights & Permissions [Opens in a new window]

Abstract

Stance detection is identifying expressed beliefs in a document. While researchers widely use sentiment analysis for this, recent research demonstrates that sentiment and stance are distinct. This paper advances text analysis methods by precisely defining stance detection and outlining three approaches: supervised classification, natural language inference, and in-context learning. I discuss how document context and trade-offs between resources and workload should inform your methods. For all three approaches I provide guidance on application and validation techniques, as well as coding tutorials for implementation. Finally, I demonstrate how newer classification approaches can replicate supervised classifiers.

Information

Type
Original Article
Creative Commons
Creative Common License - CCCreative Common License - BY
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted re-use, distribution and reproduction, provided the original article is properly cited.
Copyright
© The Author(s), 2024. Published by Cambridge University Press on behalf of EPS Academic Ltd
Figure 0

Figure 1. The appropriate classification approach depends on the content of your documents and resource constraints.

Figure 1

Table 1. Text samples from the Semeval 2016 test dataset (Mohammad et al., 2016)

Figure 2

Table 2. NLI classifiers are a good starting point for most tasks because they require no training, relatively low compute, and are highly reproducible

Figure 3

Figure 2. MCC on the testing data with bootstrapped 95 percent confidence intervals. Considering what information your documents contain should inform your approach.

Figure 4

Table 3. Performance on detecting support for President Trump in Tweets

Figure 5

Table 4. Entailment classification without supervised training requires a relatively sophisticated language model

Figure 6

Table 5. Logit biasing can improve performance for no additional cost

Figure 7

Listing 1. An example prompt template in the the Python OpenAI package. The system message gives the model an “identity” and the user message explains the task and presents the document to be classified.

Figure 8

Figure 3. Replication results from Block et al. (2022). Supervised represents the original results from a trained Electram model, while the NLI hypothesis sets used a DeBERTaV3 model for zero-shot classification.

Figure 9

Figure 4. The distribution of tweet author ideology among tweets labeled threat-minimizing by the three classifiers.

Supplementary material: File

Burnham supplementary material 1

Burnham supplementary material
Download Burnham supplementary material 1(File)
File 176.9 KB
Supplementary material: File

Burnham supplementary material 2

Burnham supplementary material
Download Burnham supplementary material 2(File)
File 171.5 KB
Supplementary material: File

Burnham supplementary material 3

Burnham supplementary material
Download Burnham supplementary material 3(File)
File 46.9 KB
Supplementary material: File

Burnham supplementary material 4

Burnham supplementary material
Download Burnham supplementary material 4(File)
File 372.1 KB
Supplementary material: File

Burnham supplementary material 5

Burnham supplementary material
Download Burnham supplementary material 5(File)
File 194.4 KB
Supplementary material: Link

Burnham Dataset

Link