Downloads · 30 days
14
1% of all-time downloads
VerificadoProfesional/SaBERT-Spanish-Fake-News
SaBERT-Spanish-Fake-News is a text classification model from VerificadoProfesional. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as apache-2.0.
This BERT-based text classifier was developed as a thesis project for the Computer Engineering degree at Universidad de Buenos Aires (UBA). The model is designed to detect fake news in Spanish and was fine-tuned on th…
Downloads · 30 days
14
1% of all-time downloads
All-time downloads
2.6K
Public
Parameters
110M
439 MB on disk
Likes
13
Public
Click a slice to open those files.
.safetensors439 MB · 100%
From the Hugging Face model README
This BERT-based text classifier was developed as a thesis project for the Computer Engineering degree at Universidad de Buenos Aires (UBA). The model is designed to detect fake news in Spanish and was fine-tuned on the dccuchile/bert-base-spanish-wwm-uncased model using a specific set of hyperparameters. It was trained on a dataset containing 125,000 Spanish news articles collected from various regions, both true and false.
Base Mode: dccuchile/bert-base-spanish-wwm-uncased
Hyperparameters:
Dataset: 125,000 Spanish news articles (True and False)
The model's performance was evaluated using the following metrics:
You can install the required dependencies using pip:
pip install transformers torch
from transformers import BertForSequenceClassification, BertTokenizer
model = BertForSequenceClassification.from_pretrained("VerificadoProfesional/SaBERT-Spanish-Fake-News")
tokenizer = BertTokenizer.from_pretrained("VerificadoProfesional/SaBERT-Spanish-Fake-News")
def predict(model,tokenizer,text,threshold = 0.5):
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=512)
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
probabilities = torch.softmax(logits, dim=1).squeeze().tolist()
predicted_class = torch.argmax(logits, dim=1).item()
if probabilities[predicted_class] <= threshold and predicted_class == 1:
predicted_class = 0
return bool(predicted_class), probabilities
text = "Your Spanish news text here"
predicted_label,probabilities = predict(model,tokenizer,text)
print(f"Text: {text}")
print(f"Predicted Class: {predicted_label}")
print(f"Probabilities: {probabilities}")
Apache License 2.0
Special thanks to DCC UChile for the base Spanish BERT model and to all contributors to the dataset used for training.