Update README.md
Browse files# Framing Detection with BERT
This repository contains a fine-tuned BERT-based model for detecting **framing elements** in news articles. The model is built on top of `bert-base-uncased` using the Hugging Face Transformers library and trained on a custom-labeled dataset consisting of 3,000 news articles.
## π Framing Theory
Framing is a concept from communication and media studies that refers to the way information is presented to influence audience interpretation. According to **Robert M. Entman (1993)**, framing involves four key elements:
1. **Define problems** β identifying what a causal agent is doing with what costs and benefits.
2. **Diagnose causes** β identifying the forces creating the problem.
3. **Make moral judgments** β evaluating causal agents and their effects.
4. **Suggest remedies** β proposing solutions to the problem and predicting their likely outcomes.
These four elements serve as the foundation for the classification labels used in this model.
## π° Dataset
- **Number of Articles**: 3,000
- **Sources**:
- [nbcnews.com](https://nbcnews.com)
- [cnn.com](https://cnn.com)
- [cnbc.com](https://cnbc.com)
- [apnews.com](https://apnews.com)
- [nytimes.com](https://nytimes.com)
- [washingtonpost.com](https://washingtonpost.com)
Each article was annotated for the presence of one or more of the following framing elements.
## π§ Framing Elements (Multi-label Classification)
The model predicts the presence of the following **framing elements** in a given text:
- **`define_problem`** β Whether the text identifies and outlines a social or political issue.
- **`diagnose_cause`** β Whether the text attributes causes or origins to the issue.
- **`moral_judgment`** β Whether the text makes a normative, moral, or value-based assessment.
- **`suggest_remedy`** β Whether the text proposes solutions or policy recommendations.
### β
Best Hyperparameters (via Optuna)
```json
{
"learning_rate": 4.235958496352736e-05,
"weight_decay": 0.221987649206252,
"num_train_epochs": 3
}
```
---
## π Performance (on Validation Set)
| Metric | Value |
|------------------|---------|
| Accuracy | 0.24 |
| F1 Score (Macro) | 0.635 |
| Precision (Macro) | 0.638 |
| Recall (Macro) | 0.635 |
> **Note**: Since this is a multi-label task, `accuracy` is less informative than `F1`.
---
## π Dataset
The model is trained on a proprietary dataset of manually labeled news articles, with binary labels indicating the presence or absence of each framing element. Each article can exhibit multiple frames simultaneously.
---
## π§ Usage
Install dependencies:
```bash
pip install transformers torch
```
Example inference:
```python
from transformers import BertTokenizer, BertForSequenceClassification
import torch
# Load model and tokenizer
model = BertForSequenceClassification.from_pretrained("nurdyansa/framing-bert-model")
tokenizer = BertTokenizer.from_pretrained("nurdyansa/framing-bert-model")
# Input text
text = "The government must intervene to stop the rising cost of living affecting the poorest."
# Tokenize and run model
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
with torch.no_grad():
logits = model(**inputs).logits
probs = torch.sigmoid(logits)
# Threshold and label mapping
threshold = 0.5
predicted = (probs > threshold).squeeze().tolist()
labels = ["define_problem", "diagnose_cause", "moral_judgment", "suggest_remedy"]
results = dict(zip(labels, predicted))
print(results)
```
### π‘ Output Example
```python
{
"define_problem": True,
"diagnose_cause": True,
"moral_judgment": True,
"suggest_remedy": True
}
```
---
## π Citation
If you use this model, please cite:
```bibtex
@misc
{nurdyansa_2025,
author = { Nurdyansa },
title = { framing-bert-model (Revision f03db73) },
year = 2025,
url = { https://huggingface.co/nurdyansa/framing-bert-model },
doi = { 10.57967/hf/5387 },
publisher = { Hugging Face }
}
```
---
## π License
This model is released under the MIT License. You are free to use, modify, and distribute it with attribution.
---
## π« Contact
For inquiries or collaborations, feel free to reach out via [Hugging Face profile](https://huggingface.co/nurdyansa).