Downloads · 30 days
4
5% of all-time downloads
npedrazzini/HistoroBERTa-SuicideIncidentClassifier
HistoroBERTa-SuicideIncidentClassifier is a text classification model from npedrazzini. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as mit.
A binary classifier based on the RoBERTa-base architecture, fine-tuned on historical British newspaper articles to discern whether news reports discuss (confirmed or speculated) suicide cases, investigations, or court…
Downloads · 30 days
4
5% of all-time downloads
All-time downloads
87
Public
Repo size
1.5 GB
Likes
0
Public
Click a slice to open those files.
.h5499 MB · 50%
From the Hugging Face model README
A binary classifier based on the RoBERTa-base architecture, fine-tuned on historical British newspaper articles to discern whether news reports discuss (confirmed or speculated) suicide cases, investigations, or court cases related to suicides. It attempts to differentiate between texts where suicide(s); or suicidal is used in the context of actual incidents and those where these terms appear figuratively or in broader, non-specific discussions (e.g., mention of the number of suicides in the context of vital statistics; philosophical discussions around the morality of suicide at an abstract level; etc.).
A str-type input.
The predicted label (Incident or Not Incident), with the confidence score for each labels.
Input:
On Wednesday evening an inquest was held at the Stag and Pheasant before Major Taylor, coroner, and a jury, of whom Mr. Joel Casson was foreman, on the body of John William Birks, grocer, of 23, Huddersfield Road, who cut his throat on Tuesday evening.
Output:
{
'Incident': 0.974,
'Not Incident': 0.026
}
Input:
The death-rate by accidents among colliers is, at least, from six to seven times as great as the death-rate from violence among the whole population, including suicides homicides, and the dangerous occupations.
Output:
{
'Not Incident': 0.577,
'Incident': 0.423
}
The classifier can be used, for instance, to obtain larger datasets reporting on cases of suicide in historical digitized newspapers, to then carry out larger-scale analyses on the language used in the reports.
The classifier was trained on digitized newspaper data containing many OCR errors and, while text segmentation was meant to capture individual news articles, each labeled item in the training dataset very often spans multiple articles. This will necessarily have introduced bias in the model because of the extra content unrelated to reporting on suicide.
⚠ NB: We did not carry out a systematic evaluation of the effect of bad news article segmentation on the quality of the classifier.
This model was released upon comparison with other runs, and its selection was based on its accuracy on the evaluation set. Models based on RoBERTa were also compared to those based on bert_1760_1900, which achieved a slightly lower performance despite hyperparameter tuning.
In the following report, the model in this repository corresponds to the one labeled roberta-7, specifically the output of epoch 4, which returned the highest accuracy (>0.96).
https://huggingface.co/datasets/npedrazzini/hist_suicide_incident
Nilo Pedrazzini
Use the code below to get started with the model.
Import and load the model:
from transformers import AutoModelForSequenceClassification, AutoTokenizer
model_name = "npedrazzini/HistoroBERTa-SuicideIncidentClassifier"
model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
Generate prediction:
input_text = "The death-rate by accidents among colliers is, at least, from six to seven times as great as the death-rate from violence among the whole population, including suicides homicides, and the dangerous occupations.."
inputs = tokenizer(input_text, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits
probabilities = logits.softmax(dim=-1)
Print predicted label:
predicted_label_id = probabilities.argmax().item()
predicted_label = model.config.id2label[predicted_label_id]
print(predicted_label)
Output:
NotIncident
Print probability of each label:
label_probabilities = {label: prob for label, prob in zip(model.config.id2label.values(), probabilities.squeeze().tolist())}
label_probabilities_sorted = dict(sorted(label_probabilities.items(), key=lambda item: item[1], reverse=True))
print(label_probabilities_sorted)
Output:
{'NotIncident': 0.5880260467529297, 'Incident': 0.4119739532470703}