Downloads · 30 days
0
natalrhyme/misinfo_roberta_fine_tune
misinfo_roberta_fine_tune is a machine learning model from natalrhyme. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Fine-tune transformer models (DistilBERT, RoBERTa) for misinformation detection using LoRA.
Downloads · 30 days
0
Access
Public
Updated Nov 17, 2025
Repo size
3 MB
Likes
0
Public
Click a slice to open those files.
.safetensors3 MB · 76%
From the Hugging Face model README
Fine-tune transformer models (DistilBERT, RoBERTa) for misinformation detection using LoRA.
pip install -q transformers datasets accelerate torch tokenizers evaluate scikit-learn huggingface_hub peft
jupyter notebook misinfo_agent/notebooks/misinfo_finetune.ipynb
CSV with columns: title (optional), text, label (0=fake, 1=legit)
title,text,label
"News","Content...",1
"Claim","False...",0
config = {
'model_name': 'distilbert-base-uncased', # or roberta-base
'max_samples': 500,
'num_train_epochs': 1,
'per_device_train_batch_size': 8,
'output_dir': './misinfo_model',
}
Key Settings:
max_samples: Reduce to 250 if out of memoryper_device_train_batch_size: 4-8 (lower if OOM)model_name: distilbert (fast) or roberta (better accuracy)| Step | Cells | Action |
|---|---|---|
| Setup | 1-6 | Install dependencies, config |
| Data | 7-11 | Load, tokenize, prepare |
| Model | 12 | Configure LoRA adapter |
| Train | 13 | Train and save weights |
| Upload | 14 | Push to Hugging Face |
| Test | 15 | Run inference examples |
Saved to ./misinfo_model/:
adapter_model.bin (~5-10 MB)adapter_config.jsonconfig.jsontokenizer.jsonPerformance:
from huggingface_hub import login, HfApi
login()
api = HfApi()
api.upload_folder(folder_path="./misinfo_model", repo_id="username/model-name", repo_type="model")
from peft import PeftModel
from transformers import AutoTokenizer, AutoModelForSequenceClassification
base = AutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased")
model = PeftModel.from_pretrained(base, "username/model-name")
tokenizer = AutoTokenizer.from_pretrained("username/model-name")
inputs = tokenizer("Your claim", return_tensors="pt")
outputs = model(**inputs)
print(outputs.logits.softmax(dim=-1))
| Issue | Solution |
|---|---|
| GPU not detected | import torch; print(torch.cuda.is_available()) |
| Out of memory | Reduce batch_size to 4, max_samples to 250 |
| Weights not saved | trainer.save_model("./misinfo_model"); tokenizer.save_pretrained("./misinfo_model") |
| CUDA missing | pip install torch --index-url https://download.pytorch.org/whl/cu121 |
Last Updated: November 17, 2025