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 vaccine-related social media comments.
Note: This repository contains
only the LoRA adapter weights. The base model must be loaded separately from
meta-llama/Llama-3.1-8B.
1import warnings
2import logging
3import torch
4from transformers import AutoTokenizer, AutoModelForSequenceClassification
5from peft import PeftModel
6
7warnings.filterwarnings("ignore")
8logging.getLogger("transformers").setLevel(logging.ERROR)
9logging.getLogger("peft").setLevel(logging.ERROR)
10
11base_model = "meta-llama/Llama-3.1-8B"
12lora_model = "gseovana/llama-vaccine-stance-ptbr-lora"
13
14# Access token required - request access at:
15# https://huggingface.co/meta-llama/Llama-3.1-8B
16HF_TOKEN = "your_huggingface_token_here"
17
18tokenizer = AutoTokenizer.from_pretrained(base_model, token=HF_TOKEN)
19tokenizer.pad_token = tokenizer.eos_token
20
21model = AutoModelForSequenceClassification.from_pretrained(
22 base_model,
23 num_labels=3,
24 dtype=torch.float16,
25 device_map="auto",
26 token=HF_TOKEN,
27)
28model.config.pad_token_id = tokenizer.pad_token_id
29model = PeftModel.from_pretrained(model, lora_model, token=HF_TOKEN)
30model.eval()
31
32label_map = {0: "Against", 1: "Favorable", 2: "Inconclusive"}
33
34text = "Vacinas são fundamentais para a saúde pública e salvam vidas."
35inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512).to(model.device)
36
37with torch.no_grad():
38 logits = model(**inputs).logits
39 predicted_class = logits.argmax(dim=-1).item()
40
41print(f"Predicted class: {predicted_class} -> {label_map[predicted_class]}")
42# Predicted class: 1 -> Favorable
For details on data collection, preprocessing, annotation protocol, and semi-supervised enrichment strategy, refer to the paper.
This model was trained exclusively on Brazilian Portuguese YouTube comments about vaccines and may not generalize well to other domains, languages, or vaccine-unrelated health topics.
1@inproceedings{oliveira2026vaccine,
2 author = {Geovana S. de Oliveira and Ana P. C. Silva and Fabricio Murai and Carlos H. G. Ferreira},
3 title = {Who Shapes Brazil's Vaccine Debate? Semi-Supervised Modeling of Stance and Polarization in YouTube's Media Ecosystem},
4 booktitle = {Proceedings of the 18th ACM Web Science Conference (WebSci '26)},
5 year = {2026},
6 month = {May},
7 address = {Braunschweig, Germany},
8 publisher = {ACM},
9 doi = {10.1145/3795766.3799768}
10}
Geovana Silva de Oliveira
Universidade Federal de Ouro Preto (UFOP), Brazil
📧
geovana.so@aluno.ufop.edu.br
📧
gseovana.contato@gmail.com