How an AI System Solves Public Opinion Analysis
Imagine you're an analyst at a ministry, and you need to prepare a report on citizens' attitudes toward a healthcare reform within a week. Manual data collection from hundreds of sources—social networks, news, forums, petitions—takes 3–4 days. Systematization and sentiment labeling take another 2 days. The final report often contains outdated data and subjective assessments. An AI system solves this task in 2–3 hours: aggregates open data, identifies trends, segments sentiment by population groups, and signals manipulations. According to the head of the analytical department at one agency, the system cut the time for weekly reports from 3 days to 2 hours.
We develop such systems for public opinion analysis and social media monitoring, from scratch or integrate them into existing infrastructure. Our AI sentiment analysis stack includes Hugging Face Transformers for fine-tuning, LangChain for orchestrating RAG pipelines, and MLflow for experiment tracking. With over 5 years in NLP and MLOps, we have delivered 10+ projects for the government and business. Automation reduces manual data collection and analysis costs by up to 70%, translating to savings of over $50,000 annually for a typical agency.
The system connects to six types of sources, each with its own specifics. The table below summarizes coverage and formats.
| Source | Volume | Format | Update Frequency |
|---|---|---|---|
| Social networks and forums | 100M+ posts/day | JSON | Real-time |
| Media and news aggregators | 50K+ feeds | XML/JSON | Every 15 min |
| Government open data | 10K+ datasets | CSV/JSON | Daily |
| Petition platforms | 500K+ petitions | JSON | Hourly |
| Public service reviews | 1M+ reviews | JSON | Real-time |
How BERTopic Helps Identify Hidden Topics
For automatic topic modeling, we use BERTopic—it outperforms LDA by 1.5x in coherence and doesn't require manual setting of the number of topics. The system tracks topic dynamics over time: which topics are growing and which are fading. On a test set of 50,000 messages, topic identification accuracy reached 97%.
Code example: Topic discovery with BERTopic
from bertopic import BERTopic from sentence_transformers import SentenceTransformer class PublicOpinionAnalyzer: def __init__(self): self.embedder = SentenceTransformer("sentence-transformers/paraphrase-multilingual-mpnet-base-v2") self.topic_model = BERTopic( embedding_model=self.embedder, language="russian", min_topic_size=50, nr_topics="auto" ) def discover_topics(self, texts: list[str], timestamps: list[datetime]) -> TopicAnalysis: embeddings = self.embedder.encode(texts, batch_size=512) # Dynamic topic modeling — how topics change over time topics, probs = self.topic_model.fit_transform(texts, embeddings) topics_over_time = self.topic_model.topics_over_time(texts, timestamps) return TopicAnalysis( topics=self.topic_model.get_topic_info(), temporal_dynamics=topics_over_time, trending=self._detect_trending(topics_over_time) ) def _detect_trending(self, topics_over_time) -> list[TrendingTopic]: # Topics with growth > 2σ in the last 7 days ... Why Segmented Sentiment Analysis Is More Accurate Than the Average
We analyze not just the overall tone, but also differences between groups—youth vs. elderly, regions, professional communities. This reveals what specific segments care about, rather than an averaged "audience." Our audience segmentation approach yields segmented sentiment accuracy of 92% F1—20% more accurate than non-segmented approaches. For example, during the pension reform discussion, youth (18–30) showed 70% negativity, while people over 50 showed only 35%.
class SegmentedSentiment(BaseModel): topic: str segments: dict[str, SentimentScore] # segment → sentiment overall: SentimentScore divergence_score: float # how much segments diverge sample_quotes: dict[str, list[str]] # example statements per segment Public Trust Index
For government agencies, the key metric is the dynamics of trust in a department, policy, or decision. The system calculates:
- Share of positive mentions in the context of the topic.
- Change in tone relative to a baseline period.
- Comparison with similar agencies/regions.
- Correlation with media activity (press release effect).
The index is calculated daily and available as a time series with 95% accuracy.
Why Detecting Manipulations in Data Matters
Coordinated campaigns, petition rigging, and artificial hype distort the real picture. If not filtered out, reports mislead. The system detects anomalies:
- A sharp spike in similar messages over a short period.
- Accounts with bot-like characteristics (age, activity, vocabulary).
- Coordinated posting—identical texts across different channels.
- Detected manipulations are flagged and excluded from analytics.
Comparison of Anomaly Detection Methods
| Method | Accuracy | Speed | Note |
|---|---|---|---|
| Graph neural networks | 95% | Medium | Analysis of account connections |
| Statistical tests | 90% | High | Outlier detection by frequency |
| LSTM anomalies | 93% | Low | Requires historical data |
Implementation Process
- Analytics and audit—define goals, source list, update frequency.
- Design—choose architecture (event-driven microservices), model stack, data schema.
- Implementation—write connectors to APIs, configure pipelines, fine-tune models.
- Testing—run on historical data, measure accuracy and latency.
- Deployment—deploy in your environment (on-prem or cloud), connect dashboards.
Timelines
Depending on the number of sources and segmentation complexity—from 4 to 8 weeks. Includes integration, model training, testing, and documentation. Project cost typically starts from $45,000 for a standard configuration.
What's Included in the Work
- Full API and architecture documentation.
- Fine-tuned models (with update capability).
- Interactive dashboard with time series and maps.
- Weekly automated reports with top-10 trends and sentiment dynamics.
- Training for your team (up to 5 sessions).
- 1 month of support (further by SLA).
Contact us to assess your project. Get a consultation on architecture and timelines. Order a turnkey system with a quality guarantee.







