使用 PoliBERTweet(基于 8300 万条政治推文预训练的 RoBERTa 模型)进行政治情感分析,识别支持、反对以及对政治议题的立场。
Political sentiment analysis skill powered by PoliBERTweet - a transformer model trained on 83 million political tweets (Georgetown University, LREC 2022).
This skill provides political sentiment analysis capabilities using a specialized NLP model trained on political content. It can analyze sentiment toward political candidates, issues, and events from various data sources including Reddit, local files, or direct text input.
Use this skill when you need to:
kornosk/polibertweet-political-twitter-roberta-mlmbash
# Python 3.9 or higher
python --version
# Install core dependencies
pip install transformers>=4.18.0 torch>=1.10.2
# Optional: Reddit data fetching
pip install praw>=7.8.1
On first execution, the model will be automatically downloaded from HuggingFace Hub (~500MB):
bash
python polibert_sentiment.py --text "Test"
SourceMethodCostData QualityUse CaseReddit--redditFreeHighReal-time political discussionsLocal File--file-User-dependentBatch analysis of collected dataStdin--stdin-User-dependentPipeline integrationDirect Text--text-User-dependentQuick testing and single analysis
Default Subreddits: r/politics, r/Conservative, r/democrats, r/Republican, r/PoliticalDiscussion
Note: Reddit data fetching uses read-only mode (no API credentials required). Rate limits apply.
bash
python polibert_sentiment.py --text "J.D. Vance is the future of the Republican party"
Output:
text
Text: J.D. Vance is the future of the Republican party
Sentiment: SUPPORT (78.3% confidence)
bash
# Analyze J.D. Vance sentiment from Reddit
python polibert_sentiment.py --candidate "J.D. Vance" --reddit --limit 50
# Analyze specific query
python polibert_sentiment.py --query "2028 election" --reddit --limit 100
# Custom subreddits
python polibert_sentiment.py --query "climate policy" --reddit --subreddits politics,environment
bash
# File with one text per line
python polibert_sentiment.py --candidate "Trump" --file tweets.txt
bash
python polibert_sentiment.py --candidate "Biden" --reddit --json
Output:
json
{
"candidate": "Biden",
"total_analyzed": 47,
"sentiment_breakdown": {
"support": {"count": 15, "percentage": 31.9},
"oppose": {"count": 22, "percentage": 46.8},
"neutral": {"count": 10, "percentage": 21.3}
},
"net_sentiment": -14.9,
"average_confidence": 72.4
}
text
Polymarket (market odds) → PoliBERT (social sentiment) → Prediction synthesis
18.6% (Vance) 35% Support Combined signal
Use PoliBERT sentiment as an input factor in the BRACE forecasting framework:
bash
# 1. Get market data
python polymarket.py search "presidential election winner 2028" --json
# 2. Get social sentiment
python polibert_sentiment.py --candidate "J.D. Vance" --reddit --limit 100 --json
# 3. Synthesize in prediction framework
# (Use prediction skill to combine signals)
text
📊 Sentiment Analysis: J.D. Vance
Source: Reddit | Total analyzed: 47
Support: 31.9% (15)
Oppose: 46.8% (22)
Neutral: 21.3% (10)
Net Sentiment: -14.9%
Avg Confidence: 72.4%
json
{
"candidate": "string",
"total_analyzed": "integer",
"sentiment_breakdown": {
"support": {"count": "integer", "percentage": "float"},
"oppose": {"count": "integer", "percentage": "float"},
"neutral": {"count": "integer", "percentage": "float"}
},
"average_confidence": "float",
"net_sentiment": "float",
"sample_results": [
{"text": "string", "sentiment": "string", "confidence": "float"}
]
}
If you use this skill or PoliBERTweet model in research, please cite:
bibtex
@inproceedings{kawintiranon2022polibertweet,
title={{P}oli{BERT}weet: A Pre-trained Language Model for Analyzing Political Content on {T}witter},
author={Kawintiranon, Kornraphop and Singh, Lisa},
booktitle={Proceedings of the Language Resources and Evaluation Conference (LREC)},
year={2022},
pages={7360--7367},
publisher={European Language Resources Association}
}
polymarket-unified - Prediction market data for political forecastingprediction - BRACE framework for calibrated forecastingai-model-team - Multi-model prediction system for financial marketsv1.0.0 (2026-04-17): Initial release