Libraries & Frameworks

Section 51.2

Safety libraries split into guardrails frameworks (which wrap LLM calls with validators), red-team toolkits, and privacy-preserving training libraries. Install with uv (Astral, 10-100x faster than pip and the modern default).

Three families of safety libraries you reach for in 2026.
Figure 51.2.1: Three families of safety libraries you reach for in 2026. Guardrails frameworks (Guardrails AI, NeMo, LLM Guard) sit in the request path. Red-team libraries (Garak, PyRIT) run offline. Privacy-preserving training (Opacus, PySyft, Flower) lives inside the training loop and provides formal (ε, δ) guarantees.

51.2.1 Guardrails frameworks

51.2.2 Red-team libraries

51.2.3 Privacy-preserving training

51.2.4 Comparing the libraries

Table 51.2.1a: 39.2.1 Safety libraries (2026).
Library Role Best for Tradeoff
Guardrails AI Validator chain Python-first apps Latency overhead
NeMo Guardrails Dialog policy Multi-turn agents Colang learning curve
Garak Vulnerability scanner Pre-deploy testing Coverage limited to known probes
PyRIT Red-team orchestration Structured campaigns Heavier setup
Opacus DP-SGD Privacy-preserving fine-tunes Accuracy hit

What's Next?

In the next section, Section 51.3: Datasets & Benchmarks, we build on the material covered here.

Further Reading

Security Libraries

NVIDIA (2024). "NeMo Guardrails." github.com/NVIDIA/NeMo-Guardrails. Reference open-source guardrails framework.
Guardrails AI (2024). "Guardrails Documentation." docs.guardrailsai.com. Reference output-validation library.
Microsoft (2024). "Presidio." microsoft.github.io/presidio. Reference PII-detection library.