Downloads · 30 days
6
6% of all-time downloads
Namadgi/DeBERTav3-finetuned-threat-scorer
DeBERTav3-finetuned-threat-scorer is a text classification model from Namadgi. Use it when you need a label for a piece of text. The card lists the license as mit.
Fine-tuned version of microsoft/deberta-v3-base for binary threat scoring on harmful speech data.
Downloads · 30 days
6
6% of all-time downloads
All-time downloads
98
Public
Parameters
184M
1.5 GB on disk
Likes
0
Public
Click a slice to open those files.
.pt735 MB · 50%
From the Hugging Face model README
Fine-tuned version of microsoft/deberta-v3-base for binary threat scoring on harmful speech data.
The model outputs a continuous threat score in [0, 1] — interpretable as a probability that the input text contains threatening content.
| Class | Precision | Recall | F1 | Support |
|---|---|---|---|---|
| SAFE | 0.96 | 0.96 | 0.96 | 414 |
| THREAT | 0.89 | 0.89 | 0.89 | 149 |
| Accuracy | 0.94 | 563 | ||
| Macro avg | 0.93 | 0.92 | 0.92 | 563 |
| Metric | Value |
|---|---|
| ROC-AUC | 0.9815 |
| PR-AUC | 0.9643 |
| F1 | 0.9123 |
| Precision | 0.9155 |
| Recall | 0.9091 |
DeBERTa v3-base (183M params)
→ [CLS] token embedding
→ Dropout(0.1)
→ Linear(768, 1)
→ Sigmoid
→ threat score ∈ [0, 1]
import torch
import torch.nn as nn
from transformers import AutoTokenizer, AutoModel
from safetensors.torch import load_file
from huggingface_hub import hf_hub_download
class ThreatRegressor(nn.Module):
def __init__(self, model_name: str = "microsoft/deberta-v3-base", dropout: float = 0.1):
super().__init__()
self.encoder = AutoModel.from_pretrained(model_name)
hidden_size = self.encoder.config.hidden_size
self.dropout = nn.Dropout(dropout)
self.head = nn.Linear(hidden_size, 1)
def forward(self, input_ids, attention_mask):
out = self.encoder(input_ids=input_ids, attention_mask=attention_mask)
cls = out.last_hidden_state[:, 0, :]
cls = self.dropout(cls)
logit = self.head(cls).squeeze(-1)
return logit
@torch.no_grad()
def predict_score(self, input_ids, attention_mask) -> torch.Tensor:
return torch.sigmoid(self.forward(input_ids, attention_mask))
# Load model
model = ThreatRegressor("microsoft/deberta-v3-base", dropout=0.1)
weights_path = hf_hub_download("Namadgi/DeBERTav3-finetuned-threat-scorer", "model.safetensors")
state_dict = load_file(weights_path)
model.load_state_dict(state_dict)
model.eval()
# Tokenize and predict
tokenizer = AutoTokenizer.from_pretrained("Namadgi/DeBERTav3-finetuned-threat-scorer")
text = "I'm going to find you and hurt you"
enc = tokenizer(text, max_length=128, padding="max_length", truncation=True, return_tensors="pt")
score = model.predict_score(enc["input_ids"], enc["attention_mask"])
print(f"Threat score: {score.item():.4f}") # e.g. 0.93 → 93% threat
| File | Description |
|---|---|
model.safetensors | Full model weights (safetensors format) |
best.pt | Raw PyTorch checkpoint (includes epoch, metrics) |
config.json | DeBERTa v3 config |
tokenizer.json | Tokenizer |
model_card.json | Structured metrics and training config |
Part of the Namadgi research group.