本文由 AI 分析生成
Summary
This is a hands-on lab module from DTU’s MLOps course covering Data Version Control (DVC), a git extension for tracking large datasets and model artifacts. DVC decouples data from code by storing lightweight .dvc metafiles in git while syncing the actual large files to a remote backend (Google Drive, S3, SSH, etc.). The module walks through dvc init, configuring a remote, adding/tagging data versions, pushing and pulling, and managing multi-version datasets.
這是 DTU MLOps 課程的實作模組,介紹如何用 DVC 對大型訓練資料和模型 checkpoint 做版本控制。核心概念是:git 追蹤小型 metafile(.dvc),真實資料存在遠端(Drive/S3/SSH)。透過 dvc add → git commit → dvc push 流程,即可像版本控制程式碼一樣追蹤 dataset 變化。
Key Points
- DVC 的核心機制:
dvc add產生.dvcmetafile,實際資料不進 git - 指令對稱性:
git pull/push管程式碼,dvc pull/push管資料 - 遠端後端支援 Google Drive、S3、SSH 等多種選項(August 2024 Google Drive API 政策變更需額外認證)
- 版本切換流程:
git checkout <tag> && dvc checkout即可回到任一資料版本 - DVC 有多檔案性能問題:大量小檔案建議先打包成 zip 或轉成
.parquet - 可同時用於 dataset 和模型 checkpoint 的版本管理
uv run dvc是課程推薦的執行方式(替代 pip install)
Insights
DVC 的設計哲學與 git-annex 類似,但更專注於 ML workflow 整合。值得注意的是它的 content-addressable storage 設計:dvc push 後資料格式在遠端不可直接識別,這個取捨換來更快的 cache 查找。對於常見的 ML 問題(「這個模型是用哪版資料訓練的?」),DVC 的 metafile + tag 組合提供了可重現的答案。課程也提到 DVC 不只做資料版控,還有 pipeline 和 experiment tracking 功能,後者在課程後續模組涵蓋。
Connections
Raw Excerpt
Essentially,
DVCwill just keep track of a small metafile that will then point to some remote location where your original data is stored. Metafiles essentially work as placeholders for your data files. Your large data files are then stored in some remote location such as Google Drive or anS3bucket from Amazon.