Instructions to use danielangelo1/llama-climate-change-stance-ptbr-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use danielangelo1/llama-climate-change-stance-ptbr-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForSequenceClassification base_model = AutoModelForSequenceClassification.from_pretrained("meta-llama/Meta-Llama-3.1-8B") model = PeftModel.from_pretrained(base_model, "danielangelo1/llama-climate-change-stance-ptbr-lora") - Notebooks
- Google Colab
- Kaggle
Climate Change Stance Classifier — Portuguese (LoRA · Llama 3.1 8B)
Fine-tuned LoRA adapter for stance detection in Brazilian Portuguese climate change discourse
Overview · Label Mapping · Quick Start · Dataset · Training · Limitations · Citation · Contact
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
| Label | Class | Description |
|---|---|---|
| 0 | Denier | Explicitly 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. |
| 1 | Believer | Explicitly acknowledges climate change; agrees with the scientific consensus; expresses environmental concern; defends scientific evidence; or criticizes harmful practices such as deforestation or wildfires. |
| 2 | Inconclusive | Does 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
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:
- 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
| Hyperparameter | Value |
|---|---|
| Method | QLoRA (Quantized LoRA — PEFT) |
| Base Model | meta-llama/Llama-3.1-8B |
| Quantization | 4-bit NF4 with bfloat16 computation |
| LoRA rank (r) | 64 |
| LoRA alpha | 16 |
| LoRA dropout | — (not applied) |
| Target modules | q_proj, k_proj, v_proj |
| Max sequence length | 192 tokens |
| Epochs | Up to 20 (early stopping, patience = 3) |
| Batch size | 128 |
| Learning rate | 2 × 10⁻⁴ |
| Loss function | Weighted cross-entropy (inverse class frequency) |
| Validation metric | Macro F1 |
| Cross-validation | Stratified 5-fold |
| Precision | Mixed (FP16) |
| Hardware | 1× NVIDIA A40 48GB · Intel Xeon Gold 6442Y 2.6GHz · 512GB RAM |
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
- Downloads last month
- 21
Model tree for danielangelo1/llama-climate-change-stance-ptbr-lora
Base model
meta-llama/Llama-3.1-8BEvaluation results
- Precision on denierself-reported0.780
- Recall on denierself-reported0.840
- F1 on denierself-reported0.810
- Precision on believerself-reported0.760
- Recall on believerself-reported0.700
- F1 on believerself-reported0.730
- Precision on inconclusiveself-reported0.840
- Recall on inconclusiveself-reported0.820