danielangelo1/llama-climate-change-stance-ptbr-lora
<div align="center">
Climate Change Stance Classifier — Portuguese (LoRA · Llama 3.1 8B)
Fine-tuned LoRA adapter for stance detection in Brazilian Portuguese climate change discourse
  ![Language: Portuguese]()
[Overview](#overview) · [Label Mapping](#label-mapping) · [Quick Start](#quick-start) · [Dataset](#dataset) · [Training](#training-details) · [Limitations](#limitations) · [Citation](#citation) · [Contact](#contact)
</div>
Overview
This repository provides a LoRA (PEFT) adapter fine-tuned on top of `meta-llama/Llama-3.1-8B` for three-class stance classification in Portuguese climate change social media comments.
The model was developed as part of the research presented in:
A Decade of Climate Polarization on Brazilian YouTube using Language Models Accepted at ASONAM 2026 — to be presented Aug 24–27, 2026, Rabat, Marrocos
Note: This repository contains only the LoRA adapter weights. The base model must be loaded separately from `meta-llama/Llama-3.1-8B`.
Label Mapping
Quick Start
Installation
pip install torch transformers peft accelerateInference
🔑 Access Token Required The base model meta-llama/Llama-3.1-8B is a gated model. You must:
- Request access at meta-llama/Llama-3.1-8B
- Accept Meta's license agreement on Hugging Face
- Generate a token at huggingface.co/settings/tokens and pass it via
token=or runhuggingface-cli loginbefore loading the model
import warnings
import logging
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
from peft import PeftModel
warnings.filterwarnings("ignore")
logging.getLogger("transformers").setLevel(logging.ERROR)
logging.getLogger("peft").setLevel(logging.ERROR)
base_model = "meta-llama/Llama-3.1-8B"
lora_model = "danielangelo1/llama-climate-change-stance-ptbr-lora"
# Access token required - request access at:
# https://huggingface.co/meta-llama/Llama-3.1-8B
HF_TOKEN = "your_token_here"
tokenizer = AutoTokenizer.from_pretrained(base_model, token=HF_TOKEN)
tokenizer.pad_token = tokenizer.eos_token
model = AutoModelForSequenceClassification.from_pretrained(
base_model,
num_labels=3,
torch_dtype=torch.float16,
device_map="auto",
token=HF_TOKEN,
)
model.config.pad_token_id = tokenizer.pad_token_id
model = PeftModel.from_pretrained(model, lora_model, token=HF_TOKEN)
model.eval()
label_map = {0: "Denier", 1: "Believer", 2: "Inconclusive"}
text = "O aquecimento global é uma ameaça real e precisamos agir agora."
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512).to(model.device)
with torch.no_grad():
logits = model(**inputs).logits
predicted_class = logits.argmax(dim=-1).item()
print(f"Predicted class: {predicted_class} -> {label_map[predicted_class]}")Training Details
Citation
If you use this model or adapter in your research, please cite:
@inproceedings{morais2026climate,
author = {Daniel Morais and Diego H. M. Magalhaes and Gabriel H. Silva and Andrea Failla and Valeria de C. Santos and Helen C. S. C. Lima and Carlos H. G. Ferreira},
title = {A Decade of Climate Polarization on Brazilian YouTube using Language Models},
booktitle = {Proceedings of the 18th International Conference on Advances in Social Networks Analysis and Mining-ASONAM 2026},
year = {2026},
month = {Aug},
address = {Rabat, Morocco},
publisher = {Springer Nature},
note = {To appear}
}Contact
Daniel Ângelo Rosa Morais Universidade Federal de Ouro Preto (UFOP), Brazil 📧 daniel.morais@aluno.ufop.edu.br 📧 danielangelo1234@gmail.com
