BATINARA / SAFETY-CRITICAL NLP

Safety Net Model

IndoBERT-based crisis-risk classification inside BATINARA's hybrid AI architecture.

Safety Net is the predictive guardrail responsible for examining high-risk conversational input before BATINARA allows the generative response path to continue. The module was designed around high sensitivity, recall-oriented evaluation and explicit safety override.

INDOBERTPYTORCHHUGGING FACEBINARY CLASSIFICATION
SAFETY_NET / MODEL_VIEWBATINARA
BATINARA Safety Net model architecture and evaluation
ROLEPredictive Safety Guard
MODELIndoBERT Base Uncased
PRIMARY METRICRecall
DEPLOYMENTReal-Time BATINARA Pipeline
01 / ROLE IN BATINARA

Not a standalone classifier. A safety gate inside the full system.

BATINARA combines predictive and generative components. The Safety Net Model sits before the response generator and acts as a decision layer for crisis-sensitive input.

When the risk score crosses the configured intervention threshold, the system does not rely on free-form generation. Instead, BATINARA switches to a predefined safety response path. This makes the model part of the application's ethical control architecture, not just an isolated machine learning experiment.

DESIGN PRIORITYReduce missed high-risk cases before optimizing for overall accuracy.
02 / DECISION ARCHITECTURE

From user input to controlled intervention.

Safety Net provides a binary risk decision that becomes one of the highest-priority signals inside BATINARA's Dynamic Context Integration Logic.

01

User text

Conversational input enters the safety pipeline before response generation.

→
02

Text preprocessing

Input is normalized and tokenized for the IndoBERT classifier.

→
03

IndoBERT inference

The model estimates the probability of high-risk crisis language.

→
04

Threshold decision

A configurable probability threshold converts the score into a safety decision.

→
05

Safety route

High-risk input triggers the protected BATINARA response path instead of normal generation.

03 / MODEL DESIGN

Training for sensitivity, not just aggregate accuracy.

A

Weighted loss

Class weights are integrated into cross-entropy loss so the training process gives appropriate importance to both classes instead of treating every error as equally costly.

B

Recall-oriented model selection

The training configuration selects the best checkpoint using recall, aligning model selection with the safety objective of minimizing missed risk signals.

C

Stratified evaluation

Train and evaluation partitions preserve label distribution so performance is measured on representative class proportions.

D

Probability thresholding

The deployment layer uses a configurable probability threshold to control intervention sensitivity independently from the default class decision.

04 / TRAINING CONFIGURATION

Fine-tuning setup.

The model was fine-tuned using a recall-centered training configuration with early stopping and class-weighted loss.

BASE MODELindolem/indobert-base-uncased
TASKBinary text classification
MAX LENGTH128 tokens
LEARNING RATE2e-5
EPOCHS5
BATCH SIZE16
WEIGHT DECAY0.01
BEST MODEL METRICRecall
EARLY STOPPINGPatience 2
DEPLOYMENT THRESHOLD0.70
05 / TRAINING WORKFLOW

Five stages from dataset to inference.

STEP 01

Preprocessing & stratified split

Text is cleaned and normalized before the data is divided using stratification to preserve class proportions between training and evaluation sets.

Safety Net preprocessing and stratified split
STEP 02

Class weight calculation

Balanced class weights are computed and prepared for the custom training objective so class imbalance does not dominate the optimization process.

Safety Net class weight calculation
STEP 03

Custom Trainer & weighted loss

The Hugging Face Trainer is extended so PyTorch CrossEntropyLoss receives the calculated class weights directly.

Safety Net custom trainer and weighted loss
STEP 04

Recall-centered training

Model checkpoints are evaluated using recall as the primary selection metric, with early stopping used to reduce overfitting.

Safety Net model training and recall optimization
STEP 05

Real-time inference integration

The final classifier returns a probability score that BATINARA converts into a safety decision using the deployment threshold.

Safety Net real-time inference integration
06 / RESULT

Safety performance in the published BATINARA system.

INDOBERT RECALL0.9977

The published BATINARA evaluation reports very high recall for the crisis-detection module, supporting its role as the system's safety gate.

DECISION ROLESafety Override

High-risk classification can interrupt the normal generative-response pathway.

TRAINING OBJECTIVERecall First

Model selection is aligned with high-sensitivity safety-critical classification.

BATINARA chatbot integration
07 / SYSTEM INTEGRATION

The model only matters when the application can act on it.

Safety Net is connected to BATINARA's chat pipeline. Its prediction is evaluated before the normal LLM response is returned to the user.

This separation between predictive risk control and generative conversation is one of the central design decisions of the BATINARA research system.

Explore the complete BATINARA architecture →
08 / STACK

Technology used.

PYTHONINDOBERTHUGGING FACE TRANSFORMERSPYTORCHSCIKIT-LEARNNLPFASTAPI INTEGRATION
BATINARA / SUBSYSTEM

Safety Net is one layer of a larger hybrid architecture.

Continue to the main BATINARA case study to see how safety, emotion classification, clinical context and the LLM work together.