ONE is preparing: 01 / INITIALIZING MODEL ROUTER. Evaluating routing across providers.
Current state
01 / INITIALIZING MODEL ROUTER.

Evaluating routing across providers.

Start learning
← Hạ tầng & Vận hành

AI Builder

Giám sát AI — Canh gác mô hình 24/7

Vietnamese onlyThe learning content is available in Vietnamese only. The surrounding interface follows your language.

Theo dõi hiệu suất, phát hiện data drift và cảnh báo khi mô hình AI trong sản phẩm bắt đầu suy giảm chất lượng.

lesson120 minHạ tầng & Vận hànhAI Engineer

Dự đoán

Model gợi ý sản phẩm của Shopee cho accuracy 95% khi deploy tháng 1. Đến tháng 6, không ai thay đổi code gì cả, nhưng user phàn nàn gợi ý ngày càng tệ. Chuyện gì xảy ra?

Chính xác! Model AI 'lão hoá' theo thời gian dù code không đổi. Mùa hè khác mùa đông, trend thời trang thay đổi, sản phẩm mới xuất hiện. Monitoring phát hiện sớm để retrain kịp thời — giống bảo dưỡng xe định kỳ!

Khoảnh khắc Aha

Model AI không phải "deploy xong là xong" — chúng lão hoá theo thời gian! Dữ liệu thực tế thay đổi liên tục (mùa vụ, trend, hành vi user), nhưng model vẫn "nhớ" patterns cũ. Monitoring giống bác sĩ khám định kỳ — phát hiện "bệnh" sớm trước khi model "sụp đổ".

Thử thách

Model phân loại email spam. Accuracy trên test set = 98%. Sau 3 tháng deploy, user báo nhiều email quan trọng bị đánh spam. Ground-truth accuracy thật sự? Không biết — vì user không report email spam lọt qua. Đây gọi là gì?

Feedback loop bias! User chỉ report khi email tốt bị spam (false positive), nhưng email spam lọt qua thì không biết (false negative). Monitoring cần measure cả hai chiều — dùng sampling strategy hoặc human review random emails.

Hai loại drift

AI Monitoring là quá trình liên tục theo dõi model đã deploy để phát hiện sớm vấn đề về hiệu suất, chất lượng, và hành vi bất thường.

Hai loại drift chính:

1. Data Drift — phân phối đầu vào thay đổi:

Pproduction(X)≠Ptraining(X)P_{\text{production}}(X) \neq P_{\text{training}}(X)

Phát hiện bằng: KL Divergence, PSI (Population Stability Index), KS Test.

PSI=∑i=1N(pinew−piold)ln⁡pinewpiold\text{PSI} = \sum_{i=1}^{N} (p_i^{\text{new}} - p_i^{\text{old}}) \ln \frac{p_i^{\text{new}}}{p_i^{\text{old}}}

2. Concept Drift — quan hệ input-output thay đổi:

Pproduction(Y∣X)≠Ptraining(Y∣X)P_{\text{production}}(Y|X) \neq P_{\text{training}}(Y|X)

Khó phát hiện hơn vì cần ground-truth labels (thường delayed).

4 tầng monitoring

4 tầng monitoring:

  • Infrastructure: GPU utilization, latency, memory, error rate
  • Data Quality: Missing values, schema violations, distribution shift
  • Model Performance: Accuracy, precision, recall, prediction distribution — với LLM còn cần đo ảo giác (hallucination) và vi phạm guardrails
  • Business Metrics: Conversion rate, user satisfaction, revenue impact

Monitoring với Evidently AI

from evidently import ColumnMapping
from evidently.report import Report
from evidently.metric_preset import (
    DataDriftPreset,
    TargetDriftPreset,
    DataQualityPreset,
)

# So sánh data production vs training
report = Report(metrics=[
    DataDriftPreset(),       # Phát hiện data drift
    TargetDriftPreset(),     # Phát hiện prediction drift
    DataQualityPreset(),     # Check data quality
])

report.run(
    reference_data=train_df,     # Data gốc khi training
    current_data=production_df,  # Data production tuần này
    column_mapping=ColumnMapping(
        target="prediction",
        prediction="prediction",
    ),
)

# Lấy drift score
drift_result = report.as_dict()
drift_detected = drift_result["metrics"][0]["result"]["dataset_drift"]
# True → ALERT: cần retrain!
print(f"Drift detected: {drift_detected}")

Tóm tắt

  • Model AI 'lão hoá' dù code không đổi — data drift và concept drift làm giảm chất lượng dần.
  • Data drift: P(X) thay đổi. Concept drift: P(Y|X) thay đổi. Phát hiện bằng PSI, KL divergence.
  • 4 tầng monitoring: Infrastructure → Data Quality → Model Performance → Business Metrics.
  • Silent failure nguy hiểm nhất: accuracy giảm từ từ mà không ai biết cho đến khi quá muộn.
  • Monitoring + alerting + auto-retrain = vòng lặp MLOps hoàn chỉnh, model luôn khoẻ mạnh.

Continue the module

Lesson 5 of 9