Master Assignment π
Collection
Models trained for master coursework assignment
β’
8 items
β’
Updated
β’
1
This model fine-tunes BERT (bert-large-uncased) to perform sentiment analysis on climate change-related tweets. It classifies tweets into four sentiment categories: anti-climate (negative), neutral, pro-climate (positive), and news.
This model was trained on the Twitter Climate Change Sentiment Dataset, which contains tweets related to climate change labeled with sentiment categories:
The dataset was used with raw text without special preprocessing to evaluate performance on natural language tweets.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("google/bert-large-uncased")
model = AutoModelForSequenceClassification.from_pretrained("keanteng/bert-large-raw-climate-sentiment-wqf7007")
# Prepare text
text = "Climate change is real and we need to act now!"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
# Make prediction
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.argmax(outputs.logits, dim=1)
# Map prediction to sentiment
sentiment_map = {-1: "anti", 0: "neutral", 1: "pro", 2: "news"}
predicted_sentiment = sentiment_map[predictions.item()]
print("Predicted sentiment: " + predicted_sentiment)
This model should be used responsibly for analyzing climate sentiment and should not be deployed in ways that might:
Base model
google-bert/bert-large-uncased