AI Audit
AI Audit
An activity that independently verifies an AI system's regulatory compliance.
AI Audit
An activity that independently verifies an AI system's regulatory compliance.
AI Audit is an activity in which an independent third party systematically verifies whether an AI system complies with relevant laws, standards, and ethical principles. The EU AI Act requires regular audits of high-risk AI systems, and this is a key mechanism for ensuring the system's transparency, fairness, and safety.
The core areas of AI Audit are divided into algorithm audit (verification of bias and fairness), data audit (training data quality, personal data processing), process audit (development procedures, documentation), and performance audit (accuracy, reliability). In particular, for high-risk AI, it is essential as part of the Conformity Assessment.
The scope of application is high-risk AI systems specified in Annex III of the EU AI Act (medical devices, recruitment systems, credit scoring, etc.), and providers must undergo either a self-conformity assessment or a third-party audit before placing the system on the market. Audit results must be included in the technical documentation and retained for at least 10 years.
For practical compliance, it is necessary to establish an internal AI audit framework, implement a logging system to ensure audit traceability (Audit Trail), and set up a cooperation framework with accredited third-party audit bodies. In Korea as well, the Financial Services Commission's AI guidelines recommend AI audits.
# AI 감사 추적 시스템 구현 예제
import logging
import hashlib
from datetime import datetime
from dataclasses import dataclass
from typing import Dict, Any, List
@dataclass
class AuditRecord:
"""AI 의사결정 감사 기록"""
timestamp: datetime
model_id: str
model_version: str
input_hash: str
output_hash: str
decision: Any
confidence: float
processing_time_ms: float
user_id: str
class AIAuditLogger:
"""EU AI Act 준수를 위한 감사 로거"""
def __init__(self, system_name: str, risk_level: str = "high"):
self.system_name = system_name
self.risk_level = risk_level
self.logger = logging.getLogger(f"ai_audit_{system_name}")
self._setup_secure_logging()
def _setup_secure_logging(self):
"""변조 방지 로깅 설정"""
handler = logging.FileHandler(
f"audit_logs/{self.system_name}_{datetime.now().strftime('%Y%m')}.log",
encoding='utf-8'
)
formatter = logging.Formatter(
'%(asctime)s|%(levelname)s|%(message)s|%(checksum)s'
)
handler.setFormatter(formatter)
self.logger.addHandler(handler)
def log_decision(self, model_id: str, model_version: str,
inputs: Dict, outputs: Dict,
confidence: float, user_id: str) -> AuditRecord:
"""AI 의사결정 기록 - 감사 추적성 확보"""
record = AuditRecord(
timestamp=datetime.utcnow(),
model_id=model_id,
model_version=model_version,
input_hash=self._hash_data(inputs),
output_hash=self._hash_data(outputs),
decision=outputs.get('decision'),
confidence=confidence,
processing_time_ms=outputs.get('processing_time', 0),
user_id=user_id
)
# 무결성 체크섬 포함 로깅
log_entry = self._serialize_record(record)
self.logger.info(log_entry, extra={'checksum': self._compute_checksum(log_entry)})
return record
def _hash_data(self, data: Dict) -> str:
"""입출력 데이터 해시화 (개인정보 보호)"""
return hashlib.sha256(str(data).encode()).hexdigest()[:16]
def _compute_checksum(self, data: str) -> str:
"""로그 무결성 검증용 체크섬"""
return hashlib.sha256(data.encode()).hexdigest()[:8]
def generate_audit_report(self, start_date: datetime,
end_date: datetime) -> Dict[str, Any]:
"""감사 보고서 생성 - 규제 당국 제출용"""
return {
"system_name": self.system_name,
"risk_level": self.risk_level,
"report_period": {"start": start_date, "end": end_date},
"total_decisions": self._count_decisions(start_date, end_date),
"accuracy_metrics": self._calculate_accuracy(),
"fairness_metrics": self._calculate_fairness(),
"incident_summary": self._get_incidents(start_date, end_date),
"compliance_status": "COMPLIANT",
"generated_at": datetime.utcnow().isoformat()
}
# 사용 예시
audit_logger = AIAuditLogger("credit_scoring_ai", risk_level="high")
# 신용 평가 결정 로깅
audit_logger.log_decision(
model_id="credit_model_v2",
model_version="2.1.0",
inputs={"applicant_id": "HASH_12345", "income": "bracket_3"},
outputs={"decision": "APPROVED", "credit_limit": 50000},
confidence=0.92,
user_id="analyst_001"
)
Legal team: "To enter the EU market, we need to put a high-risk AI audit framework in place first. We have to select a third-party audit body before high-risk AI becomes mandatory in August next year."
Development team: "To ensure audit traceability, I've modified the system to log a timestamp and the model version for every AI decision. I set the log retention period to 10 years."
Interviewer: "Do you have experience with AI audits? What items did you check?"
Candidate: "I conducted an algorithmic fairness audit. I analyzed outcome disparities across protected attributes such as race and gender, and built a monitoring framework to keep the Disparate Impact Ratio at 0.8 or above."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
Compliance: "This inference function has no audit log. If it's classified as high-risk AI, traceable logs for every decision are mandatory."
Developer: "I'll add an AuditLogger decorator. I'll make it record the input hash, the output, and even the confidence score."