Views
No views yet
| Frame | Description (Card et al., 2015 / Boydstun et al., 2014) |
|---|---|
| Economic | The costs, benefits, or other financial implications of the issue. |
| Capacity and Resources | The availability of physical, human, or financial resources, and the capacity of current systems. |
| Morality | Any perspective or policy objective/action compelled by religious doctrine, ethics, or social responsibility. |
| Fairness and Equality | The balance or distribution of rights, responsibilities, and resources; equality or inequality in the application of laws. |
| Legality, Constitutionality and Jurisprudence | The rights, freedoms, and authority of individuals, corporations, and government (focuses on the constraints/freedoms granted via the Constitution or laws). |
| Policy Prescription and Evaluation | Discussion of specific policies aimed at addressing problems, and the evaluation of whether certain policies will work or are working. |
| Crime and Punishment | The effectiveness and implications of laws and their enforcement (includes breaking laws, loopholes, sentencing, and punishment). |
| Security and Defense | Threats to the welfare of the individual, community, or nation (includes protection from not-yet-manifested threats). |
| Health and Safety | Health care access/effectiveness, sanitation, disease, mental health, and public safety (e.g., infrastructure safety). |
| Quality of Life | Threats and opportunities for the individual's wealth, happiness, and well-being (effects on mobility, ease of routine, community life). |
| Cultural Identity | The traditions, customs, or values of a social group in relation to a specific policy issue. |
| Public Opinion | Attitudes and opinions of the general public, including polling and demographics. |
| Political | Considerations related to politics and politicians, including lobbying, elections, and attempts to sway voters (explicit mentions of partisan maneuvering). |
| External Regulation and Reputation | The international reputation or foreign policy of the U.S. (relations with other nations, trade agreements). |
| Other | Any coherent group of frames not covered by the above categories. |
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4# Load model and tokenizer
5model_name = "ry-rousseau/media-framing-longformer"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForSequenceClassification.from_pretrained(model_name)
8
9# Prepare input with topic injection (highly recommended)
10topic = "immigration" # or use topic classifier
11text = "Your article text here..."
12input_text = f"TOPIC:{topic}\n{text}"
13
14# Tokenize and predict
15inputs = tokenizer(input_text, return_tensors="pt", truncation=True, max_length=2048)
16outputs = model(**inputs)
17
18# Get predictions (apply optimized thresholds per class)
19probs = torch.sigmoid(outputs.logits)
20predictions = (probs > 0.5).int() # Use class-specific thresholds for better performance
21
22# Frame labels
23frames = [
24"Economic", "Capacity and Resources", "Morality", "Fairness and Equality",
25"Legality, Constitutionality and Jurisprudence", "Policy Prescription and Evaluation",
26"Crime and Punishment", "Security and Defense", "Health and Safety",
27"Quality of Life", "Cultural Identity", "Public Opinion", "Political",
28"External Regulation and Reputation", "Other"
29]
30
31detected_frames = [frames[i] for i, pred in enumerate(predictions[0]) if pred == 1]
32print("Detected frames:", detected_frames)copenlu/mm-framing datasetallenai/longformer-base-4096| Metric | Score |
|---|---|
| Weighted F1 | 0.686 |
| Micro F1 | 0.685 |
| Macro F1 | 0.645 |
| Frame | Precision | Recall | F1 | Support |
|---|---|---|---|---|
| Economic | 0.78 | 0.70 | 0.74 | 87 |
| Capacity & Resources | 0.44 | 0.48 | 0.46 | 25 |
| Morality | 0.53 | 0.64 | 0.58 | 61 |
| Fairness & Equality | 0.60 | 0.52 | 0.56 | 63 |
| Legality | 0.83 | 0.79 | 0.81 | 164 |
| Policy Prescription | 0.58 | 0.85 | 0.69 | 110 |
| Crime & Punishment | 0.63 | 0.86 | 0.73 | 87 |
| Security & Defense | 0.49 | 0.72 | 0.58 | 29 |
| Health & Safety | 0.61 | 0.77 | 0.68 | 69 |
| Quality of Life | 0.57 | 0.74 | 0.64 | 96 |
| Cultural Identity | 0.46 | 0.74 | 0.57 | 72 |
| Public Opinion | 0.51 | 0.77 | 0.61 | 81 |
| Political | 0.70 | 0.94 | 0.81 | 134 |
| External Regulation | 0.92 | 0.41 | 0.57 | 29 |