Spaces:
Sleeping
A newer version of the Gradio SDK is available: 6.13.0
title: Narrative Stance Analyzer
emoji: 🧠
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 5.49.1
app_file: app.py
pinned: false
Narrative Stance Analyzer
Overview
The Narrative Stance Analyzer is a public, interactive web application built using pretrained Transformer models to classify the narrative stance of text related to climate communication. The model predicts whether a given message reflects a believer, neutral, or denier perspective.
This project is designed to help researchers, communicators, and advocates better understand how narratives are framed in public discourse.
Use Case
Prompt:
“Given a campaign message, news headline, or paragraph, analyze its narrative stance as believer, neutral, or denier using emotion and framing cues.”
Example Input:
"Climate change is the biggest threat to our future. We must act now."
Output:
- Predicted Stance: believer
- Confidence scores from SBERT and DeBERTa
- Final ensemble prediction
Models Used
1. SBERT + MLP Classifier
- Embeddings from:
all-MiniLM-L6-v2(via Sentence-Transformers) - Trained classifier: Logistic Regression with balanced class weights
2. DeBERTa (Base)
- Model:
microsoft/deberta-v3-small - Used for zero-shot classification (no fine-tuning)
- Tokenizer + model loaded from saved checkpoint
3. Ensemble Logic
- Final prediction is a weighted ensemble:
- 60% SBERT + 40% DeBERTa confidence scores
How It Works
- User enters a text message
- The app:
- Generates sentence embedding using SBERT
- Tokenizes and classifies with DeBERTa
- Combines both predictions into a final ensemble score
- Returns the top label and confidence scores
🖥 Interface
Built with Gradio for fast prototyping and deployment on Hugging Face Spaces.
Running the App
Local Installation
git clone https://huggingface.co/spaces/yourusername/narrative-stance-app
cd narrative-stance-app
pip install -r requirements.txt
python app.py