🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Stance Detection: Identifying Author Position

Natural Language ProcessingStance Detection: Identifying Author PositionđŸŸĸ Free Lesson

Stance Detection: Identifying Author Position

Module: Natural Language Processing | Difficulty: Advanced

What You'll Learn

  • 1Separate stance toward a target from sentiment toward its mention
  • 2Condition a classifier on both the text and an explicit target
  • 3Report macro F1 over the stance labels as the task defines it
  • 4Diagnose cross-target transfer failure with a per target breakdown

Stance detection asks whether an author favors, opposes, or is neutral toward a specified target. The target is supplied from outside the text, so the same tweet can carry opposite labels when the target changes, and this dependency is what separates the task from sentiment analysis. This lesson covers the target conditioning that makes the task well defined, the label imbalance that makes evaluation fragile, and the cross-target gap that dominates real deployments.

Stance Is Not Sentiment

Sentiment attaches to words and their connotations. Stance attaches to a relation between the author and a named entity, policy, or claim. A tweet that praises a politician's family life can still oppose that politician's candidacy, and a tweet that calls a policy chaotic can favor it.

The target enters the model explicitly, either by concatenating a target encoding with the text representation, by cross attention from the text to the target, or by rewriting the input as a natural language question. Without in the input the task collapses to topic sentiment, and reported numbers drop accordingly.

Datasets and the Mention Problem

The SemEval 2016 stance task assembled 4,870 tweet and target pairs across five targets: atheism, climate change, the feminist movement, Hillary Clinton, and abortion legalization. Task A holds 2,914 training and 1,249 test pairs, and Task B, which is single target and cross domain, holds 707. The best reported scores were macro F1 of 67.8 on Task A and 56.3 on Task B.

ResourceExamplesTargetsSignal
SemEval 2016 Task 64,870 tweet target pairs5 fixed targetsmacro F1 over favor and against
P-Stance21,574 tweets3 political targetsbest macro F1 80.53
VAST18,548 examples5,630 topicszero shot, 600 topics held out
Cross target splitsvariableunseen targetstransfer gap as the metric

The hardest structural fact is that the target is often absent from the text. The target string appears in only about 70 percent of Hillary Clinton tweets and about 35 percent of abortion tweets, so a model whose features are anchored on the target window sees:

Coverage below one forces the model to reason from sentiment markers, policy keywords, and shared world knowledge rather than from any token that names the target. This is the main reason naive target dependent templates lose to models that read the whole utterance.

Evaluation Under Imbalance

Stance datasets are skewed and the metric is a macro average, so per class behavior is what moves the score:

The none label is typically excluded from the average, which means a system can improve its headline number by ignoring neutrality while still failing a downstream use that needs to know when an author expressed no position. Reporting both the scored macro F1 and the accuracy over all three labels keeps that visible.

Cross-Target Transfer

A stance model trained on two political figures and deployed on a third is the realistic setting, and it is where accuracy falls hardest. The transfer objective can be written as a minimax over target domains:

The inner maximization finds the target domain that hurts most and the outer minimization trains against it, which is the same adversarial structure used for domain adaptation. Simpler alternatives include training on all available targets jointly and holding out one for evaluation, and generating target paraphrases so that the surface form of does not become a memorized key.

VAST was built for precisely this setting: 18,548 examples spanning 5,630 topics, with a zero shot test set of 600 unique topics never seen in training. Under that split the interesting number is not the in-domain score but the drop when the target itself changes.

Worked Examples

Worked Code

python
def f1(p, r):
    return 2 * p * r / (p + r) if p + r else 0.0

def macro_f1(gold, pred, labels=("favor", "against")):
    scores = []
    for label in labels:
        tp = sum(1 for g, p in zip(gold, pred) if g == label and p == label)
        fp = sum(1 for g, p in zip(gold, pred) if g != label and p == label)
        fn = sum(1 for g, p in zip(gold, pred) if g == label and p != label)
        precision = tp / (tp + fp) if tp + fp else 0.0
        recall = tp / (tp + fn) if tp + fn else 0.0
        scores.append(f1(precision, recall))
    return round(sum(scores) / len(scores), 3)

gold = ["favor"] * 65 + ["against"] * 69 + ["none"] * 40
pred = (["favor"] * 48 + ["against"] * 9 + ["none"] * 8
        + ["favor"] * 11 + ["against"] * 46 + ["none"] * 12
        + ["favor"] * 6 + ["against"] * 5 + ["none"] * 29)
print("macro F1:", macro_f1(gold, pred))
print("accuracy:", round(sum(g == p for g, p in zip(gold, pred)) / len(gold), 3))
python
tweets = {
    "Hillary Clinton": [
        "Hillary Clinton voted for the war and regretted it",
        "Hillary Clinton won the primary easily",
        "I will never support her, ever",
    ],
    "Abortion": [
        "banning abortion harms poor women",
        "the ruling was correct and narrow",
        "protests continued downtown",
    ],
}

def mentions(text, target):
    return target.lower() in text.lower()

for target, items in tweets.items():
    hits = sum(mentions(t, target) for t in items)
    print(f"{target:16} coverage {hits} of {len(items)} -> {hits / len(items):.3f}")

for target, items in tweets.items():
    missing = [t for t in items if not mentions(t, target)]
    print(f"{target:16} needs context: {len(missing)}")

Real-World Applications

  • Brand and reputation monitoring - Mentions are scored for stance toward the brand rather than for sentiment alone, because criticism of a competitor is favorable coverage.
  • Political analysis - Stance toward a candidate across thousands of posts gives a position map that topic modeling cannot produce.
  • Misinformation triage - Stance toward a claim identifies amplification even when the claim itself is never restated in full.
  • Customer feedback routing - Opposing feedback on a specific feature routes to a different queue than general dissatisfaction.

💡Evaluate on a held out target

Random splits leak the target into both sides, so the model can memorize target specific phrasing. Hold out an entire target and report that number next to the in-domain score, because deployment almost always means a target the model has not seen.

Common Mistakes

Reporting accuracy instead of macro F1

Fix: Stance labels are imbalanced and the task defines macro F1 over favor and against, so accuracy overstates performance.

Treating the target as part of the input text

Fix: Supply the target as a separate field, otherwise the model learns to key on whatever target was most frequent in training.

Ignoring the none class

Fix: Neutrality is excluded from the headline metric but not from the product, so report its recall separately.

Best Practices

  • Split by target, not by tweet, when the goal is generalization
  • Report per target macro F1 alongside the aggregate so one target cannot hide a collapse
  • Combine target conditioned features with full context, since the target is often unmentioned

Key Takeaways

  • Stance is a relation between an author and an externally supplied target, not a property of the text alone
  • SemEval 2016 holds 4,870 tweet target pairs with a best Task A macro F1 of 67.8
  • The target string appears in only about 35 percent of abortion tweets, capping span based features
  • Macro F1 over favor and against is the headline metric, and held out target evaluation is the honest one

Frequently Asked Questions

Why not just run sentiment analysis?

Sentiment scores the words, stance scores the relation. A favorable sentence about a candidate's family can accompany opposition to the candidacy, and only the target conditioned formulation captures that split.

What does cross target transfer failure look like?

The model performs well on targets seen in training and drops sharply on a new one, because it learned target specific keywords rather than a general notion of support or opposition. The signature is a large gap between random split and held out target scores.

How should the none label be handled?

Score the task the way the benchmark defines it, then report none recall as an extra column. Systems that ignore neutrality can win a leaderboard while producing an unusable output for any application that needs to know when nothing was expressed.

Interview Questions

Q1: You report 0.85 accuracy on stance detection. What are you missing?

The macro F1 over favor and against, and the per target breakdown. On an imbalanced set a majority predictor posts respectable accuracy while getting the minority stance entirely wrong.

Q2: How do you build a stance system for a target you have no labeled data for?

Train jointly on all available targets, hold one out to measure the true gap, and add target paraphrases so the model cannot memorize the surface form. Then calibrate the threshold on a small labeled sample from the new target.

CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-07

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Related Tutorials

Content with similar topics across other courses

Need Expert NLP Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement