| name | reliable-responsible-foundation-comprehensive |
| description | Audit and harden AI/ML systems for reliability and responsibility using an 8-dimension framework
covering bias, security, privacy, hallucination, uncertainty, explainability, distribution shift,
alignment, and AIGC detection. Use this skill when users say things like:
- "Audit my LLM application for safety and fairness"
- "Add responsible AI checks to my ML pipeline"
- "How do I detect hallucinations in my model output?"
- "Harden my AI system against adversarial attacks"
- "Add bias detection to my NLP pipeline"
- "Implement watermarking for AI-generated content"
|
Reliable & Responsible Foundation Model Auditing
This skill enables Claude to systematically audit, evaluate, and harden AI/ML systems across the eight critical dimensions identified in the comprehensive reliability/responsibility taxonomy: bias & fairness, security, privacy, uncertainty, explainability, distribution shift, hallucination, and AIGC detection. Rather than applying ad-hoc checks, this skill provides a structured framework that evaluates cross-cutting concerns (e.g., bias amplifying security risks, uncertainty relating to hallucination) to produce actionable hardening recommendations with concrete code.
When to Use
- When the user asks to audit an LLM-based application, RAG pipeline, or generative AI service for safety, fairness, or trustworthiness
- When building a CI/CD gate that validates model outputs against responsible AI criteria before deployment
- When the user needs to add hallucination detection, bias measurement, or uncertainty quantification to an existing ML system
- When implementing adversarial robustness testing (prompt injection defense, jailbreak detection) for a production LLM service
- When the user asks to add AI-generated content detection or watermarking to a content pipeline
- When designing privacy-preserving inference (differential privacy, data anonymization) around a foundation model
- When the user wants to implement distribution shift detection for monitoring model performance degradation in production
Key Technique: 8-Dimension Reliability/Responsibility Framework
The core insight from this survey is that reliability and responsibility are not independent axes but an interconnected graph. Bias amplifies security vulnerabilities (targeted attacks exploit social stereotypes). Hallucination correlates with high uncertainty and distribution shift. Privacy leaks are a security concern that also affects fairness. Treating these in isolation produces blind spots.
The framework defines reliability as the model's capacity to perform accurately, consistently, and robustly under challenging conditions, and responsibility as alignment of model behavior with ethical principles including fairness, privacy, security, and transparency. Each dimension has specific evaluation metrics, detection methods, and mitigation strategies that map directly to code-level implementations.
The actionable methodology is a structured audit that evaluates each dimension, identifies cross-cutting risks, and produces prioritized hardening tasks. For each dimension the audit uses specific benchmarks: distribution metrics and classification metrics for bias, membership inference tests for privacy, consistency checking for hallucination, calibration metrics for uncertainty, feature attribution for explainability, OOD detection for distribution shift, and statistical/watermark-based detectors for AIGC.
Step-by-Step Workflow
-
Inventory the system: Identify every foundation model in the pipeline (LLM, MLLM, image generator, video generator), its role (classification, generation, retrieval), and its exposure surface (user-facing API, internal tool, batch pipeline).
-
Select applicable dimensions: Not all 8 dimensions apply equally. A text classifier needs bias/fairness and uncertainty but not AIGC detection. A content generation API needs all 8. Map each model to its relevant dimensions using this matrix:
| Dimension | User-facing gen | Internal classifier | RAG pipeline | Image gen |
|---|
| Bias & Fairness | Yes | Yes | Yes | Yes |
| Security | Yes | Low | Yes | Yes |
| Privacy | Yes | Yes | Yes | Low |
| Uncertainty | Yes | Yes | Yes | Low |
| Explainability | Medium | Yes | Yes | Low |
| Distribution Shift | Yes | Yes | Yes | Medium |
| Hallucination | Yes | Low | Yes | Yes |
| AIGC Detection | Yes | No | No | Yes |
-
Implement bias evaluation: For text outputs, run demographic substitution tests (swap gender/race terms and measure output divergence). Use toxicity classifiers (Perspective API) and regard classifiers on outputs. For embeddings, implement WEAT/SEAT association tests. For generative models, measure demographic representation in outputs.
-
Add security hardening: Implement input validation layers that detect prompt injection patterns, adversarial perturbations, and jailbreak attempts. Add output filtering for sensitive content. For multimodal systems, validate visual inputs against adversarial perturbation detectors.
-
Build uncertainty quantification: Add calibration measurement (Expected Calibration Error) to model outputs. Implement verbalized uncertainty where the model expresses confidence levels. Add abstention thresholds so low-confidence predictions are flagged rather than served.
-
Concrete Examples
Example 1: Auditing a customer-facing RAG chatbot
User: "Audit my RAG chatbot for responsible AI. It uses GPT-4 with a vector store of company docs."
Approach:
- Identify system: LLM (GPT-4) + retrieval pipeline, user-facing, text generation
- Applicable dimensions: All except AIGC detection (unless content attribution matters)
- Implement evaluation suite
Output — a Python evaluation module:
import numpy as np
from dataclasses import dataclass, field
@dataclass
class AuditResult:
dimension: str
score: float
findings: list[str] = field(default_factory=list)
recommendations: list[str] = field(default_factory=list)
class RAGAuditor:
def __init__(self, query_fn, retriever_fn):
"""
query_fn: callable(prompt: str) -> str (the RAG pipeline end-to-end)
retriever_fn: callable(prompt: str) -> list[str] (retriever only)
"""
self.query = query_fn
self.retrieve = retriever_fn
def audit_bias(self, test_prompts: dict[str, list[str]]) -> AuditResult:
"""Run demographic substitution tests.
test_prompts: {"template": ["group_a_term", "group_b_term", ...]}
"""
findings = []
divergences = []
for template, terms in test_prompts.items():
outputs = {t: self.query(template.replace("{GROUP}", t)) for t in terms}
for i, t1 in (terms):
t2 terms[i+:]:
overlap = ._token_overlap(outputs[t1], outputs[t2])
divergences.append( - overlap)
overlap < :
findings.append(
)
avg = - (np.mean(divergences) divergences )
AuditResult(, avg, findings,
[] avg < [])
() -> AuditResult:
findings = []
consistency_scores = []
q factual_queries:
responses = [.query(q) _ (n_samples)]
score = ._pairwise_consistency(responses)
consistency_scores.append(score)
score < :
findings.append()
avg = np.mean(consistency_scores) consistency_scores
AuditResult(, avg, findings,
[] avg < [])
() -> AuditResult:
findings = []
grounding_scores = []
q queries:
passages = .retrieve(q)
response = .query(q)
claims = ._extract_claims(response)
grounded = ( c claims ._is_grounded(c, passages))
score = grounded / ((claims), )
grounding_scores.append(score)
score < :
findings.append()
avg = np.mean(grounding_scores) grounding_scores
AuditResult(, avg, findings,
[] avg < [])
() -> AuditResult:
findings = []
blocked =
payload injection_payloads:
response = .query(payload)
._detects_injection_compliance(response, payload):
findings.append()
:
blocked +=
score = blocked / ((injection_payloads), )
AuditResult(, score, findings,
[, ] score < [])
() -> [AuditResult]:
results = [
.audit_bias(bias_prompts),
.audit_hallucination(factual_queries),
.audit_source_attribution(factual_queries),
.audit_prompt_injection(injection_payloads),
]
results
() -> :
ta, tb = (a.lower().split()), (b.lower().split())
(ta & tb) / ((ta | tb), )
() -> :
scores = []
i ((responses)):
j (i + , (responses)):
scores.append(._token_overlap(responses[i], responses[j]))
np.mean(scores) scores
() -> []:
[s.strip() s text.split() (s.strip()) > ]
() -> :
(._token_overlap(claim, p) > p passages)
() -> :
indicators = [, , ]
(ind response.lower() ind indicators)
Example 2: Adding uncertainty-aware abstention to a classifier
User: "My model sometimes gives wrong answers confidently. Add uncertainty-based abstention."
Approach:
- Wrap the model's predict method with calibration and abstention logic
- Compute Expected Calibration Error on a validation set
- Set an abstention threshold based on calibrated confidence
Output:
import numpy as np
class UncertaintyGate:
"""Wraps a model to abstain on low-confidence predictions."""
def __init__(self, model, abstention_threshold: float = 0.7):
self.model = model
self.threshold = abstention_threshold
self._calibration_offset = 0.0
def calibrate(self, val_inputs, val_labels, n_bins: int = 10):
"""Compute ECE and learn a calibration offset."""
probs = np.array([self.model.predict_proba(x) for x in val_inputs])
confidences = probs.max(axis=1)
predictions = probs.argmax(axis=1)
correct = (predictions == np.array(val_labels)).astype(float)
bin_boundaries = np.linspace(0, 1, n_bins + 1)
ece = 0.0
offsets = []
for i in range(n_bins):
mask = (confidences > bin_boundaries[i]) & (confidences <= bin_boundaries[i + 1])
if mask.sum() == 0:
continue
bin_conf = confidences[mask].mean()
bin_acc = correct[mask].mean()
ece += mask.sum() * abs(bin_acc - bin_conf)
offsets.append(bin_acc - bin_conf)
ece /= (val_labels)
._calibration_offset = np.mean(offsets) offsets
{: ece, : ._calibration_offset}
() -> :
probs = .model.predict_proba(x)
confidence = (probs.()) + ._calibration_offset
confidence = np.clip(confidence, , )
prediction = (probs.argmax())
confidence < .threshold:
{
: ,
: confidence,
: ,
: ,
}
{: prediction, : confidence, : }
Example 3: Distribution shift monitoring in production
User: "Set up monitoring to detect when my model's input distribution drifts."
Approach:
- Capture a reference distribution from validation data
- Compute Population Stability Index (PSI) on incoming batches
- Alert when PSI exceeds threshold
Output:
import numpy as np
from collections import deque
import logging
logger = logging.getLogger(__name__)
class DriftMonitor:
"""Monitor input feature distributions for shift detection."""
def __init__(self, reference_features: np.ndarray, window_size: int = 1000,
psi_threshold: float = 0.2, n_bins: int = 20):
self.n_bins = n_bins
self.psi_threshold = psi_threshold
self.window = deque(maxlen=window_size)
self.n_features = reference_features.shape[1]
self.ref_hists = []
self.bin_edges = []
for i in range(self.n_features):
counts, edges = np.histogram(reference_features[:, i], bins=n_bins)
self.ref_hists.append(counts / counts.sum())
self.bin_edges.append(edges)
def observe(self, feature_vector: np.ndarray):
self.window.append(feature_vector)
def check_drift(self) -> dict:
if len(.window) < :
{: , : }
current = np.array((.window))
psi_scores = []
drifted_features = []
i (.n_features):
counts, _ = np.histogram(current[:, i], bins=.bin_edges[i])
current_hist = counts / (counts.(), )
ref = np.clip(.ref_hists[i], , )
cur = np.clip(current_hist, , )
psi = (np.((cur - ref) * np.log(cur / ref)))
psi_scores.append(psi)
psi > .psi_threshold:
drifted_features.append({: i, : psi})
max_psi = (psi_scores)
{
: max_psi > .psi_threshold,
: max_psi,
: (np.mean(psi_scores)),
: drifted_features,
}
Best Practices
- Do: Evaluate cross-cutting risks. Bias in training data can simultaneously increase hallucination rates for underrepresented groups and create exploitable security patterns. Always check dimension intersections.
- Do: Use demographic substitution tests with domain-appropriate templates rather than generic benchmarks. A medical chatbot needs different bias probes than a coding assistant.
- Do: Implement abstention over confident wrong answers. A system that says "I'm not sure" is more trustworthy than one that fabricates authoritative responses.
- Do: Layer defenses. Combine input validation (security), output filtering (bias/safety), and monitoring (drift/uncertainty) rather than relying on any single gate.
- Avoid: Treating responsible AI as a one-time audit. Distribution shift, evolving attack patterns, and changing social norms require continuous monitoring.
- Avoid: Using only automated metrics for bias evaluation. Automated toxicity classifiers have their own biases. Supplement with human evaluation and domain-specific review.
Error Handling
- Audit returns no findings: This does not mean the system is safe. Expand test coverage — add more demographic groups, more injection patterns, more edge-case queries. Absence of evidence is not evidence of absence.
- Inconsistent hallucination scores: Self-consistency can vary with temperature and sampling settings. Pin generation parameters during evaluation. Run multiple audit passes and report confidence intervals.
- Drift monitor false positives: Seasonal or expected input changes trigger alerts. Maintain multiple reference distributions (e.g., per time period) and allow updating the baseline with approved data.
- Bias tests show divergence but cause is unclear: Use explainability tools (feature attribution, attention analysis) to trace which input features drive the divergent behavior before applying mitigations.
Limitations
- This framework provides structure and detection but cannot guarantee safety. Adversaries adapt, and no static audit catches all future attack vectors.
- Automated bias metrics (token overlap, toxicity scores) are proxies. They miss subtle forms of bias like omission, framing effects, or context-dependent stereotyping.
- Uncertainty quantification for black-box API models (e.g., GPT-4 via API) is limited to output-level heuristics since logits and embeddings may not be accessible.
- AIGC detection and watermarking are in an arms race with paraphrasing and editing tools. Watermarks are not robust against determined adversaries.
- This skill focuses on evaluation and monitoring scaffolding. Fixing fundamental model behaviors (e.g., deeply embedded bias) requires retraining or fine-tuning, which is outside the scope of an audit wrapper.
Reference
Paper: Yang, Han, Bommasani, Luo, Qu. Reliable and Responsible Foundation Models: A Comprehensive Survey. arXiv:2602.08145v1 (2026). https://arxiv.org/abs/2602.08145v1
Look for: The 8-dimension taxonomy (Section structure), cross-cutting intersection analysis (connecting bias to security, uncertainty to hallucination), and the specific benchmarks/metrics listed per dimension (WEAT, ECE, PSI, CrowS-Pairs, self-consistency).