The Cognitive Coordinator (CoCo) is the AI-native trust orchestrator at the heart of the SAFE-6G architecture. It interprets user trust intents expressed in natural language and translates them into actionable system configurations, dynamically computing a Level of Trustworthiness (LoT) that aligns with both semantic intent and real-world resource constraints.
- Fine-tuned BERT regressor with five output heads, one per Trust Function (TF)
- Fully interpretable scoring pipeline with semantic weighting
- Calibrated trust scoring based on available system resources
- FastAPI-based HTTP interface for input submission and LoT computation
- Dockerized deployment for seamless integration into SAFE-6G testbed environments
- Plug-and-play design with message broker, monitoring, and orchestrator compatibility
Let
Given BERT-predicted scores
Each TF has a maximum enforceable capacity
This BERT-based regression model estimates trustworthiness scores
- Base encoder:
bert-base-uncasedfrom HuggingFace Transformers. - Output heads: Five parallel
nn.Linearregressors (one per trust class). - Input: Natural language expressions + class label.
- Output: Continuous trustworthiness score per expression.
- Dataset: Expert-annotated expressions with associated trust scores.
- Loss function: Mean Squared Error (MSE).
- Training schedule: 500 epochs with early stopping.
- Data split: 70% training / 15% validation / 15% test (same indices used as in baseline).
Epoch-wise Losses
Training and validation losses decreased consistently over time, indicating stable convergence without overfitting.
Rยฒ Score Evolution
Validation Rยฒ improves steadily, reaching >0.9, confirming good predictive capability on unseen data.
Error Metrics (MAE & RMSE)
Both MAE and RMSE show a decreasing trend, reflecting error reduction during training.
Best Validation Metrics
| Metric | Value |
|---|---|
| MSE/Val Loss | 0.004798 |
| MAE | 0.0476 |
| RMSE | 0.069267 |
| Rยฒ Score | 0.922622 |
| Epoch | 12 |
These were recorded at the epoch with lowest validation loss.
Final Test Set Performance
| Metric | Value |
|---|---|
| MAE | 0.048383 |
| RMSE | 0.062127 |
| Rยฒ Score | 0.935158 |
Test results confirm generalization to unseen data and validate the trustworthiness of BERT-based quantification.
We use rye for Python environment management.
Ensure rye is installed:
curl -sSf https://rye-up.com/get | bash
source ~/.bashrc # or ~/.zshrcrye sync # installs from pyproject.tomlRun end-to-end experiments using one of the following scripts:
src/coco/experiments/train_baseline.py
OR
src/coco/experiments/train_bert.py
Alternatively, check the worflow on the notebook: notebooks/ML_Models.ipynb. This process described in the following sections:
from coco.config.config import REGISTRY_DIRThis path (REGISTRY_DIR) controls where model weights and metrics are stored (e.g., model_registry/bert_model.pth, metrics.json).
from coco.experiments.train_baseline import run as run_baseline
run_baseline()- Model: TF-IDF + Gradient Boosting Regression
- Usage: Establishes a simple ML benchmark
from coco.experiments.train_bert import run as run_bert
run_bert()- Model:
bert-base-uncased+ 5 regression heads - Trainer: Early stopping, augmentation, evaluation logging
After training, models and logs are stored in:
model_registry/
โโโ best_model.pth # Saved BERT checkpoint
โโโ metrics.json # All training/validation/test metrics
You can run inference from the notebook or script:
from coco.inference.bert_inference import InferenceHandler
inf_h = InferenceHandler(model_weights_path=os.path.join(REGISTRY_DIR, "best_model.pth"))
inf_h.inference("Respect user data", "Privacy")Launch the CoCo API and its core services via Docker:
docker compose up --buildSubmit input sentences with labeled trust categories (e.g., "Privacy", "Security"):
curl -X POST http://localhost:8000/data/submit \
-H "Content-Type: application/json" \
-d '{
"data": [
{ "label": "Privacy", "text": "Users should control access to their data." },
{ "label": "Security", "text": "All communications must be encrypted." },
{ "label": "Reliability", "text": "Service uptime must exceed 99.999%." }
]
}'Trigger the trustworthiness computation once data has been submitted:
curl -X POST http://localhost:8000/lotw/calculateThe response will include:
nLoTW: Non-calibrated score based on intentcLoTW: Calibrated score constrained by system resources- Per-TF breakdown: weights, predicted scores, and applied caps
- NLP + Regression: BERT-based sentence encoder with 5 specialized regression heads
- Reasoning Engine: Applies resource-awareness to compute feasible trust levels
- Orchestrator Integration: Uses a broker-based publish/subscribe system for TF control
- Monitoring & Feedback: Supports closed-loop adjustments
| Trust Function | Sample Input |
|---|---|
| Privacy | "Users should control access to their data." |
| Security | "All communications must be encrypted." |
| Reliability | "System uptime must exceed 99.999%." |
| Resilience | "System must continue operating under attack." |
| Safety | "The system must protect against user harm." |



