A fine-tuned RoBERTa model for classifying sentiment about solar energy technologies
More information: https://solarsentiment.org
Model Overview
This model is a RoBERTa-based sentiment classifier fine-tuned on text related to solar energy, rooftop solar adoption, grid benefits, and public attitudes toward solar technologies.
It predicts one of the following classes:
- Positive
- Negative
- Neutral
Load from the Hub
import pandas as pd
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
model_id = "serenakim/solar-sentiment"
# Load tokenizer + model
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)
model.eval()
Example Usage
# Load CSV
df = pd.read_csv("sample_text.csv") # https://huggingface.co/serenakim/solar-sentiment/blob/main/sample_text.csv
texts = df["text"].astype(str).tolist()
all_preds = []
all_probs = []
for txt in texts:
enc = tokenizer(
txt,
return_tensors="pt",
truncation=True,
padding=True,
max_length=256
)
with torch.no_grad():
out = model(**enc)
probs = torch.softmax(out.logits, dim=-1)
pred = probs.argmax(dim=-1).item()
label = model.config.id2label[pred]
all_preds.append(label)
all_probs.append(probs.numpy()[0])
# Add predictions back to DataFrame
df["pred_label"] = all_preds
df["probs"] = all_probs
print(df.head())
Citation
Kim, Serena Y., Crystal Soderman, and Lan Sang. “Sentiment analysis of solar energy in US cities: a 10-year analysis using transformer-based deep learning.” Journal of Computational Social Science, 8(2), 2025. https://link.springer.com/article/10.1007/s42001-025-00365-z
- Downloads last month
- 1
Model tree for serenakim/solar-sentiment
Base model
FacebookAI/roberta-base