nurdyansa commited on
Commit
f048f37
Β·
verified Β·
1 Parent(s): f03db73

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).

Files changed (1) hide show
  1. README.md +2 -1
README.md CHANGED
@@ -17,4 +17,5 @@ tags:
17
  - optuna
18
  - classification
19
  - social-science
20
- ---
 
 
17
  - optuna
18
  - classification
19
  - social-science
20
+ ---
21
+