Downloads · 30 days
8
11% of all-time downloads
damian-shivihs/yllia-safety-classifier
yllia-safety-classifier is a text classification model from damian-shivihs. 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.
Yllia Safety Classifier is a Polish-language encoder model for first-line safety classification and message routing in mental-health conversational systems.
Downloads · 30 days
8
11% of all-time downloads
All-time downloads
72
Public
Parameters
443M
3.5 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors1.8 GB · 100%
From the Hugging Face model README
Yllia Safety Classifier is a Polish-language encoder model for first-line safety classification and message routing in mental-health conversational systems.
It classifies a single user message into one of five categories:
ATTACKCRISISMEDICAL_SENSITIVEOFFTOPICOKThe model is based on PKOBP/polish-roberta-8k and was fine-tuned as a five-class sequence classifier.
This release is a research checkpoint and an early step toward a broader safety architecture for Polish-language AI systems.
The model is intended to support the first stage of message triage.
Its role is to help determine whether an incoming message:
The model is designed as an additional safety layer, not as a standalone clinical system.
It should be combined with:
| ID | Label | Description |
|---|---|---|
| 0 | ATTACK | Prompt injection, jailbreak attempts, instruction manipulation, abusive language, and spam |
| 1 | CRISIS | Suicidal thoughts or plans, self-harm, acute psychosis, command hallucinations, and violence |
| 2 | MEDICAL_SENSITIVE | Medication dosing, adverse effects, interactions, requests for diagnosis, and interpretation of medical results |
| 3 | OFFTOPIC | Topics unrelated to the psychiatric or psychological practice |
| 4 | OK | Routine logistics, appointments, pricing, address, services, treatment inquiries, and other ordinary intake messages |
The checkpoint performs flat single-label classification.
Any routing hierarchy, for example prioritizing CRISIS over MEDICAL_SENSITIVE, must be implemented at the application level.
The project is based on 1,369 original questions written by people.
The examples were designed to reflect messages that may realistically be sent to a psychiatric or psychological practice.
They include:
All original examples were reviewed and assigned labels by people involved in the project.
Synthetic variants were created only after the original examples had been prepared and labelled.
The augmentation process included:
Synthetic data was used to expand linguistic diversity, but evaluation on original human-written examples is reported separately.
The dataset split was performed using the original source question as the grouping key. Synthetic variants derived from the same source question were kept within the same split.
The primary evaluation subset contains 206 original questions and does not include synthetic variants.
| Category | Precision | Recall | F1 | Support |
|---|---|---|---|---|
ATTACK | 0.8462 | 0.5789 | 0.6875 | 19 |
CRISIS | 0.6562 | 0.7241 | 0.6885 | 29 |
MEDICAL_SENSITIVE | 0.6719 | 0.7679 | 0.7167 | 56 |
OFFTOPIC | 0.8125 | 0.4333 | 0.5652 | 30 |
OK | 0.7160 | 0.8056 | 0.7582 | 72 |
| Macro average | 0.7406 | 0.6620 | 0.6832 | 206 |
| Weighted average | 0.7217 | 0.7087 | 0.7025 | 206 |
Accuracy: 0.7087
Macro-F1: 0.6832
MCC: 0.6099
The most operationally relevant recall values are:
CRISIS: 0.7241MEDICAL_SENSITIVE: 0.7679OK: 0.8056These results show that the model can serve as a useful first classification layer, while still requiring additional safeguards for high-risk cases.
The full test set contains 637 examples:
Accuracy: 0.8038
Macro-F1: 0.8079
MCC: 0.7507
Performance on synthetic variants is higher than on original human-written questions. For this reason, the independent original-only test subset should be treated as the primary estimate of real-world generalization.
Confusion matrix for the independent original-only test subset.
Rows represent true labels and columns represent predicted labels.
| True \ Predicted | ATTACK | CRISIS | MEDICAL_SENSITIVE | OFFTOPIC | OK |
|---|---|---|---|---|---|
| ATTACK | 11 | 2 | 1 | 1 | 4 |
| CRISIS | 0 | 21 | 5 | 0 | 3 |
| MEDICAL_SENSITIVE | 0 | 5 | 43 | 0 | 8 |
| OFFTOPIC | 2 | 3 | 4 | 13 | 8 |
| OK | 0 | 1 | 11 | 2 | 58 |
| Parameter | Value |
|---|---|
| Base model | PKOBP/polish-roberta-8k |
| Architecture | RobertaForSequenceClassification |
| Number of labels | 5 |
| Training method | Full fine-tuning |
| Learning rate | 3e-6 |
| Batch size | 32 |
| Maximum sequence length | 256 |
| Hidden dropout | 0.25 |
| Attention dropout | 0.25 |
| Classifier dropout | 0.25 |
| Configured epochs | 12 |
| Optimizer epsilon | 1e-8 |
| Precision | FP32 |
Training run:
polish_roberta_8k_bs32_len256_do0p25_lr3e_06
The training history suggests the beginning of overfitting in later epochs. Raw softmax probabilities should therefore not be interpreted as calibrated confidence estimates.
Calibration methods such as temperature scaling are recommended before using probability thresholds in a production system.
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
MODEL_ID = "damian-shivihs/yllia-safety-classifier"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForSequenceClassification.from_pretrained(MODEL_ID)
model.eval()
def classify(text: str) -> dict:
inputs = tokenizer(
text,
return_tensors="pt",
truncation=True,
max_length=256,
)
with torch.inference_mode():
logits = model(**inputs).logits
probabilities = torch.softmax(logits, dim=-1)[0]
predicted_id = int(probabilities.argmax())
return {
"label": model.config.id2label[predicted_id],
"score": float(probabilities[predicted_id]),
}
print(classify("Czy mogę umówić wizytę u psychiatry?"))
You can also use the Transformers pipeline:
from transformers import pipeline
classifier = pipeline(
"text-classification",
model="damian-shivihs/yllia-safety-classifier",
top_k=None,
)
print(classifier("Czy mogę umówić wizytę u psychiatry?"))
The returned scores are raw softmax values and are not calibrated.
The model may be useful for:
CRISIS recall on the independent original-only test set is 0.7241.
This means that some crisis-related messages are still assigned to other categories.
The model must not be used as the only crisis-detection mechanism.
OFFTOPIC remains the weakest class, with recall of 0.4333 on the original-only test subset.
ATTACK combines several different types of content:
Future versions may benefit from separating these behaviors into more precise categories.
The distinction between a routine service question and a request for medical information can be subtle.
Small wording changes may change the correct label.
The model was trained on short Polish-language messages intended for a psychiatric or psychological practice.
Its behavior on long documents, social-media content, medical records, or unrelated domains has not been established.
The confidence scores returned by the model are not calibrated and may be overconfident.
The model is not intended for:
This is not a clinical product and has not undergone regulatory or prospective clinical validation.
The dataset was prepared and evaluated in cooperation with the AI4BUSINESS Student Research Group.
The following people contributed to the creation, collection, evaluation, organization, and description of the dataset:
Academic support and acknowledgement:
Wroclaw University of Economics and Business.
Damian Siwicki
Psychiatrist and computer science engineer based in Wrocław, Poland.
This release is only the beginning.
Planned directions include:
CRISIS recall,This release should be considered a research and development checkpoint.
The model is public so that it can be tested, reviewed, criticized, and improved.
https://huggingface.co/damian-shivihs/yllia-safety-classifier
@misc{siwicki2026yllia,
title = {Yllia Safety Classifier: Polish Encoder-Based Safety and Triage Model},
author = {Siwicki, Damian},
year = {2026},
howpublished = {\url{https://huggingface.co/damian-shivihs/yllia-safety-classifier}}
}