CoolFace
Modelpublic

danielangelo1/llama-climate-change-stance-ptbr-lora

sourceHugging Facemitupdated 1mo agoView on Hugging Face
0likes26downloads
Model Card

<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

![Model on HuggingFace](https://huggingface.co/danielangelo1/llama-climate-changes-stance-ptbr-lora/) ![License: MIT](https://opensource.org/licenses/MIT) ![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

LabelClassDescription
0DenierExplicitly expresses skepticism toward climate change; denies its occurrence; downplays its impacts; rejects anthropogenic responsibility; claims global warming is a "hoax," a "lie," a natural cycle, or a conspiracy; or articulates generalized denial of climate science.
1BelieverExplicitly acknowledges climate change; agrees with the scientific consensus; expresses environmental concern; defends scientific evidence; or criticizes harmful practices such as deforestation or wildfires.
2InconclusiveDoes not clearly belong to either of the above categories; contains ambiguous statements; expresses generic agreement or disagreement without clear stance; lacks sufficient information to infer position; or is irrelevant to the climate change debate.

Quick Start

Installation

bash
pip install torch transformers peft accelerate

Inference

🔑 Access Token Required The base model meta-llama/Llama-3.1-8B is a gated model. You must:

  1. 1.Request access at meta-llama/Llama-3.1-8B
  2. 2.Accept Meta's license agreement on Hugging Face
  3. 3.Generate a token at huggingface.co/settings/tokens and pass it via token= or run huggingface-cli login before loading the model
python
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

HyperparameterValue
MethodQLoRA (Quantized LoRA — PEFT)
Base Modelmeta-llama/Llama-3.1-8B
Quantization4-bit NF4 with bfloat16 computation
LoRA rank (r)64
LoRA alpha16
LoRA dropout— (not applied)
Target modulesq_proj, k_proj, v_proj
Max sequence length192 tokens
EpochsUp to 20 (early stopping, patience = 3)
Batch size128
Learning rate2 × 10⁻⁴
Loss functionWeighted cross-entropy (inverse class frequency)
Validation metricMacro F1
Cross-validationStratified 5-fold
PrecisionMixed (FP16)
Hardware1× NVIDIA A40 48GB · Intel Xeon Gold 6442Y 2.6GHz · 512GB RAM

Citation

If you use this model or adapter in your research, please cite:

bibtex
@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