Skip to content
Home
Winner of the SaxFDM Open Data Award 2026 Featured · Agentic AI Safety

BlackWall

Protect an AI from going rogue via an AI

BlackWall is a domain-aware, interpretable safety barrier that sits between the user and an LLM. Every prompt is classified before it reaches the model, and every response is classified again before it reaches the user, so a jailbroken or drifting agent cannot pass harmful content to the person on the other side.

Global accuracy
87%
Stratified 3-fold cross-validation
Weighted F1-score
0.87
Across all three risk classes
Critical-risk recall
0.81
Urgent cases correctly flagged
PAC bound (95%)
0.9367
Minimal generalisation gap

Purpose

Why BlackWall

Conversational AI now talks to millions of people, including people in crisis. Model alignment lowers the risk of a harmful answer but does not remove it, and a single bad reply to a vulnerable user is one too many. BlackWall is the independent safety layer that sits outside the model and has the final say on what gets through.

  • Models can be pushed off course

    Jailbreaks, prompt manipulation and plain drift can make an aligned LLM produce content it was trained to refuse.

  • The stakes are human

    Self-harm, suicidal ideation and depression call for a careful response. A misleading or harmful reply can do real damage.

  • Keyword filters are not enough

    Distress is often expressed without obvious keywords, and metaphors trigger false alarms. Moderation needs context and must be explainable.

What BlackWall does about it

BlackWall screens both directions of every conversation with a fine-tuned, domain-robust classifier, releases only what is explicitly safe, and returns a label with a confidence score so every decision can be audited.

Abstract

In short

The increasing integration of social media and conversational AI into daily life has intensified concerns around the spread of harmful, illegal and psychologically sensitive content, including suicidal ideation, self-harm, depression and other forms of negative influence. Recent cases of emotional attachment to chatbots, and instances where AI systems have unintentionally misled users on mental-health issues, highlight the urgency of reliable safety mechanisms. BlackWall is a domain-aware and interpretable framework designed to identify, assess and rank high-risk content. By operating across heterogeneous data sources and providing transparent risk explanations, it supports early intervention, responsible moderation and safer human–AI interaction.

System architecture

BlackWall wraps the LLM brain on both sides. The brain (Gemma 3 1B on Ollama) and the classifier each run in their own container, deployable with Docker Compose or as Kubernetes deployments.

  1. User Guest prompt
  2. BlackWall Ingress Classify prompt
  3. Gemma 3 1B Ollama container
  4. BlackWall Egress Classify response
  5. User Released answer

✕ ingress block: brain is never contacted

✕ egress block: model output is withheld

⏻ barrier offline: request fails closed

Docker

blackwall-ai (FastAPI classifier, :8000) and ollama/ollama serving gemma3:1b (:11434), both bound to localhost only.

Kubernetes

Separate deployments with HPA for the barrier, a persistent model volume for the brain, and a NetworkPolicy so nothing but the gateway can reach Gemma.

Method · Rogue agent containment

  1. 01

    Ingress screening

    A fine-tuned classifier labels each prompt as safe, violence or critical (self-harm, suicidal ideation). Anything but safe is stopped before the LLM sees it.

  2. 02

    Egress screening

    The model is treated as untrusted. Its output passes through the same barrier, so a manipulated or hallucinating agent can't deliver harmful content even when the prompt looked benign.

  3. 03

    Fail-closed by design

    If the barrier is unreachable or returns an invalid verdict, nothing is released. Each verdict carries a label and confidence score for transparent, auditable moderation.

  4. 04

    Domain-robust training

    Trained on a Twitter-derived dataset (not suicide / potential suicide) and a Reddit SuicideWatch dataset with 0–5 severity. Domain Adversarial Training encourages domain-invariant representations across the two sources.

  5. 05

    PAC-oriented evaluation

    A PAC-style evaluation and conditioning strategy checks whether learned decision rules generalise consistently as data scale and domains vary.

Inside the classifier

  • Data
  • Model / compute
  • Processing
  • Control step
  • Output / guard
1 Model pipeline · Risk Thermometer How a message becomes a risk label with a confidence score.
  1. 1 Risk lexicon Terms + danger levels
  2. 2 Preprocess Tokenise · denoise
  3. 3 Hybrid encoding Longformer + TF-IDF + danger score
  4. 4 Classifier head ReLU · Tanh · GELU
  5. 5 Softmax rank Safe · General · Critical
2 Training · domain-adversarial A gradient reversal layer forces features that work on Twitter and Reddit alike.
  1. 1 Two sources Tweets + Reddit SuicideWatch
  2. 2 Class collapsing 5 levels → 3 classes
  3. 3 Feature extractor Longformer backbone
  4. 4 Gradient reversal −λ to domain head
  5. 5 Stratified 3-fold CV PAC bound check

Results

How well it works

Evaluated with stratified 3-fold cross-validation on 2,957 samples, so every sample is tested once on a model that never saw it.

Per-class performance

Class Precision Recall F1
Safe 0.90 0.90 0.90
General risk 0.85 0.85 0.85
Critical risk 0.78 0.81 0.80
Overall 0.87 0.87 0.87

Confusion matrix · aggregated over 3 folds

Safe General Critical Safe 1,331 90% 131 9% 16 1% General 125 11% 982 85% 55 5% Critical 16 5% 43 14% 258 81%

Rows: true label · Columns: predicted label · % of each true class

Generalisation check · PAC, 95% confidence

  • Empirical reliability0.9061
  • Complexity term0.0306
  • PAC bound0.9367

A small complexity term means the gap between training performance and real-world performance is minimal.

Key findings

  • Collapsing the subjective 5-level severity scale into 3 classes raised peak F1 from 0.845 to 0.872 and removed the confusion between adjacent risk levels.
  • SVM, XGBoost and logistic-regression baselines reached acceptable overall accuracy but almost never caught the rare high-risk class. The fine-tuned Longformer with Domain Adversarial Training did.
  • Errors lean towards caution: misclassifications mostly raise lower-risk content to a higher level rather than miss genuine threats.

Models & Documentation

Use the model

The model weights, checkpoints, training datasets, and usage documentation are hosted entirely on Hugging Face and GitHub rather than stored on this host. You can pull the trained classifier weights directly from the Hugging Face Hub, read the documentation on GitHub, or inspect the open-source pipeline code.

Guest sandbox · Live demo

Test BlackWall live

Talk to Gemma 3 1B through the real BlackWall barrier and watch every gate decide, with labels, confidence and latency for each message.

  • No login
  • 6 requests / minute
  • Gemma 3 1B
  • Answers in seconds

Acknowledgements

Developed at TU Bergakademie Freiberg. Thanks to the open-source community for the Suicidal Tweets and Reddit SuicideWatch Severity datasets and the pre-trained models that made this work possible. BlackWall received the SaxFDM Open Data Award 2026; its data and code are archived openly on Zenodo. The live sandbox runs Google's Gemma 3 through Ollama.

BibTeX

@misc{blackwall2026,
  author       = {Besharat, Parsa},
  title        = {{BlackWall}: Protect an AI from Going Rogue via an AI},
  year         = {2026},
  institution  = {TU Bergakademie Freiberg},
  note         = {Winner of the SaxFDM Open Data Award 2026},
  doi          = {10.5281/zenodo.21924128},
  url          = {https://doi.org/10.5281/zenodo.21924128}
}

BlackWall live sandbox

Gemma 3 1B guarded by BlackWall · ingress + egress screening

Send any message. BlackWall screens it before Gemma sees it, then screens Gemma's answer before you see it. Try a harmless question, then one BlackWall should contain.

released contained fails closed if offline

Ready · Enter to send · Shift + Enter for new line 0 / 1000 · 6 messages per minute · answers in seconds

Media Preview

↑ ↓ to move · Enter to open