Downloads · 30 days
30
12% of all-time downloads
vzani/portuguese-fake-news-classifier-bilstm-combined
portuguese-fake-news-classifier-bilstm-combined is a text classification model from vzani. Use it when you need a label for a piece of text. It is set up for keras. The card lists the license as apache-2.0.
This repository contains a trained BiLSTM model for fake news detection in Portuguese. The model was trained and evaluated on corpora derived from Brazilian Portuguese datasets Fake.br and FakeTrue.Br.
Downloads · 30 days
30
12% of all-time downloads
All-time downloads
256
Public
Repo size
222 MB
Likes
0
Public
Click a slice to open those files.
.parquet136 MB · 61%
From the Hugging Face model README
This repository contains a trained BiLSTM model for fake news detection in Portuguese. The model was trained and evaluated on corpora derived from Brazilian Portuguese datasets Fake.br and FakeTrue.Br.
pt)bilstm-combined Fine-tuned using the combined dataset from Fake.br and FakeTrue.Br.
bilstm-fake-br Fine-tuned using the Fake.br dataset from Fake.br.
bilstm-faketrue-br Fine-tuned using the FakeTrue.Br dataset from FakeTrue.Br.
Each variant has its own confusion matrix, classification report, and predictions stored as artifacts.
{
"ngram_upper": 2,
"units": 120,
"dropout": 0.3374510345164157,
"recurrent_dropout": 0.1588638491073387,
"max_tokens": 96000,
"embed_dim": 71,
"embed_max_seq_len": 51,
"learning_rate": 0.00011662663429277272,
"batch_size": 16,
"epochs": 8,
}
Evaluation metrics are stored in the repo as:
confusion_matrix.pngfinal_classification_report.parquetfinal_predictions.parquetThese files provide per-class performance and prediction logs for reproducibility.
This model is a Keras model stored as final_bilstm_model.keras.
import keras
import tensorflow as tf
from huggingface_hub import hf_hub_download
repo_id = "vzani/portuguese-fake-news-classifier-bilstm-combined" # or fake-br / faketrue-br
filename = "final_bilstm_model.keras"
model_path = hf_hub_download(repo_id=repo_id, filename=filename)
model = keras.models.load_model(model_path)
def predict(text: str) -> tuple[bool, float]:
input_data = tf.convert_to_tensor([[text]], dtype=tf.string)
probs = model.predict(input_data) # type: ignore
prob = float(probs.flatten()[0]) # type: ignore
pred = prob >= 0.5
# Convert the probability in case of Fake
prob = prob if pred else 1 - prob
return pred, prob
if __name__ == "__main__":
text = "BOMBA! A Dilma vai taxar ainda mais os pobres!"
print(predict(text))
The expected output is a Tuple where the first entry represents the classification (True for true news and False for fake news) and the second the probability assigned to the predicted class (ranging from 0 to 1.0).
(False, 0.997499808203429)
You can find the source code that produced this model in the repository below:
The source contains all the steps from data collection, evaluation, hyperparameter fine tuning, final model tuning and publishing to HuggingFace. If you use it, please remember to credit the author and/or cite the work.
@misc{zani2025portuguesefakenews,
author = {ZANI, Vinícius Augusto Tagliatti},
title = {Avaliação comparativa de técnicas de processamento de linguagem natural para a detecção de notícias falsas em Português},
year = {2025},
pages = {61},
address = {São Carlos},
school = {Instituto de Ciências Matemáticas e de Computação, Universidade de São Paulo},
type = {Trabalho de Conclusão de Curso (MBA em Inteligência Artificial e Big Data)},
note = {Orientador: Prof. Dr. Ivandre Paraboni}
}