Communitygithub.com

DVC(資料版本控制)

ML 專案的資料版本控制。取代 Git 追蹤大型資料集和模型,建置可重現的 ML 管線,並以指標比較執行實驗。支援任何儲存後端,包括 S3、GCS、Azure 以及本機檔案系統。

DVC(資料版本控制) 是什麼?

DVC(Data Version Control)是一個專為機器學習與資料科學專案設計的開源版本控制系統。它擴展 Git 的功能,讓您能夠有效追蹤大型資料集、模型檔案以及 ML 管線的變更,同時保持與 Git 的相容性。DVC 的核心概念是使用輕量的 `.dvc` 指標檔(pointer files)來指向實際儲存在遠端儲存(如 S3、GCS、Azure、本機檔案系統)的大型資料,進而避免將大型檔案直接放入 Git 儲存庫。 此技能涵蓋 DVC 的完整工作流程:初始化專案、透過 `dvc add` 追蹤資料、設定遠端儲存、以及推拉資料。更重要的是,它支援可重現的 ML 管線:透過 `dvc.yaml` 定義階段(stages)、相依性(dependencies)、輸出(outputs)和參數,然後使用 `dvc repro` 僅重新執行有變更的階段,確保實驗結果的可重現性。 此外,DVC 還提供無分支的實驗追蹤功能,讓使用者能以 `dvc exp run` 搭配參數變更執行多個實驗、使用 `dvc exp show` 和 `dvc exp diff` 比較結果,並透過 `dvc exp apply` 套用最佳實驗成果。它也支援指標與圖表的檢視與比較,以及透過 `dvc get` 和 `dvc import` 直接存取其他 DVC 儲存庫中的資料,無需完整複製整個儲存庫。 此技能在 Claude Code、Cursor 與 Codex 等 AI 代理工具中運作,提供一個完整的範例導向參考,涵蓋安裝、組態、管線建置、實驗管理以及程式化 API 存取。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/TerminalSkills/skills/tree/HEAD/skills/dvc

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

DVC(資料版本控制) 是做什麼的?

安裝

# 安裝 DVC 並支援雲端儲存
pip install dvc[s3]    # 用於 AWS S3
pip install dvc[gs]    # 用於 Google Cloud Storage
pip install dvc[azure] # 用於 Azure Blob Storage
pip install dvc[all]   # 所有遠端儲存

# 在 Git 儲存庫中初始化 DVC
cd my-ml-project
git init
dvc init

追蹤資料檔案

# track_data.sh — 將大型檔案加入 DVC 追蹤,而非 Git
# 加入大型資料集
dvc add data/training_images/
dvc add data/dataset.csv

# DVC 會建立 .dvc 檔案(小型的指標檔)— 將這些檔案提交到 Git
git add data/training_images.dvc data/dataset.csv.dvc .gitignore
git commit -m "使用 DVC 追蹤訓練資料"

設定遠端儲存

# setup_remote.sh — 設定 DVC 存放實際檔案內容的位置
# S3
dvc remote add -d myremote s3://my-bucket/dvc-storage

# Google Cloud Storage
dvc remote add -d myremote gs://my-bucket/dvc-storage

# 本機或網路路徑
dvc remote add -d myremote /mnt/shared/dvc-storage

# 將資料推送到遠端
dvc push

# 從遠端拉取資料(在另一台機器上或複製儲存庫後)
dvc pull

建置可重現的管線

# dvc.yaml — 定義 ML 管線階段,包含相依性與輸出
stages:
  prepare:
    cmd: python src/prepare.py
    deps:
      - src/prepare.py
      - data/raw/
    outs:
      - data/processed/

  train:
    cmd: python src/train.py
    deps:
      - src/train.py
      - data/processed/
    params:
      - train.epochs
      - train.learning_rate
      - train.batch_size
    outs:
      - models/model.pkl
    metrics:
      - metrics/train.json:
          cache: false

  evaluate:
    cmd: python src/evaluate.py
    deps:
      - src/evaluate.py
      - models/model.pkl
      - data/processed/
    metrics:
      - metrics/eval.json:
          cache: false
    plots:
      - metrics/confusion_matrix.csv:
          x: predicted
          y: actual
# params.yaml — 管線參數(由 DVC 追蹤)
train:
  epochs: 50
  learning_rate: 0.001
  batch_size: 32
# 執行整個管線(僅重新執行有變更的階段)
dvc repro

# 執行特定階段
dvc repro train

實驗追蹤

# experiments.sh — 執行與比較 ML 實驗
# 使用修改後的參數執行實驗
dvc exp run --set-param train.learning_rate=0.01

# 平行執行多個實驗
dvc exp run --set-param train.learning_rate=0.001 --queue
dvc exp run --set-param train.learning_rate=0.01 --queue
dvc exp run --set-param train.learning_rate=0.1 --queue
dvc queue start --jobs 3

# 比較實驗
dvc exp show
dvc exp diff

# 將成功的實驗套用到工作空間
dvc exp apply exp-abc123

# 將實驗推送到 Git 分支
dvc exp push origin exp-abc123

指標與圖表

# train.py — 訓練腳本,輸出由 DVC 追蹤的指標
import json
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, f1_score
import yaml
import pickle

# 載入參數
with open("params.yaml") as f:
    params = yaml.safe_load(f)["train"]

X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

model = RandomForestClassifier(n_estimators=params["epochs"])
model.fit(X_train, y_train)

preds = model.predict(X_test)
metrics = {
    "accuracy": accuracy_score(y_test, preds),
    "f1_score": f1_score(y_test, preds, average="weighted"),
}

with open("metrics/train.json", "w") as f:
    json.dump(metrics, f, indent=2)

with open("models/model.pkl", "wb") as f:
    pickle.dump(model, f)
# 檢視跨實驗的指標
dvc metrics show
dvc metrics diff

# 產生圖表
dvc plots show metrics/confusion_matrix.csv
dvc plots diff  # 比較不同實驗的圖表

無須複製即可存取資料

# 從任何 DVC 儲存庫存取受追蹤的檔案,無須完整複製
dvc get https://github.com/org/ml-repo data/processed/dataset.csv
dvc import https://github.com/org/ml-repo models/model.pkl
# dvc_api.py — 以程式化方式存取 DVC 追蹤的檔案
import dvc.api

# 從 DVC 儲存庫讀取檔案
with dvc.api.open("data/dataset.csv", repo="https://github.com/org/ml-repo") as f:
    import pandas as pd
    df = pd.read_csv(f)

# 取得受追蹤檔案的 URL
url = dvc.api.get_url("models/model.pkl", repo="https://github.com/org/ml-repo")

關鍵概念

  • .dvc 檔案:提交到 Git 的小型指標檔,用於參照遠端儲存中的大型資料
  • dvc repro:重現管線 — 僅重新執行相依性有變更的階段
  • 實驗:無分支的實驗追蹤 — 執行、比較並套用結果
  • 參數:由 DVC 追蹤的 YAML 參數檔,用於可重現的組態設定
  • 指標:JSON/YAML 格式的指標檔,內建比較工具
  • 遠端儲存:S3、GCS、Azure、SSH、HDFS — 資料存放在您想要的位置

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

TerminalSkills/skills

>- Run GitHub Actions locally with act. Use when a user asks to test GitHub Actions workflows locally, debug CI pipelines without pushing, or run workflows offline.

TerminalSkills/skills

>- You are an expert in AG2 (formerly AutoGen), the open-source multi-agent conversation framework. You help developers build systems where multiple AI agents collaborate through structured conversations — with tool use, human-in-the-loop, code execution, group chat orchestration, and nested conversations — for complex tasks like software development, research, and data analysis.

TerminalSkills/skills

>- Generate short-form videos with AI — script writing, text-to-speech narration, stock footage selection, subtitle generation, and video assembly. Use when: creating TikTok/YouTube Shorts/Reels content, automating video production, building content pipelines.

TerminalSkills/skills

>- Animate 3D objects and characters in Blender with Python. Use when the user wants to keyframe properties, create armatures and rigs, set up IK/FK chains, animate shape keys for facial animation, edit F-Curves, use the NLA editor to blend actions, add drivers for expression-based animation, or script any animation workflow in Blender.

TerminalSkills/skills

>- Automate motion capture and tracking workflows in Blender with Python. Use when the user wants to import BVH or FBX mocap data, retarget motion to armatures, track camera or object motion from video, solve camera motion, clean up motion capture data, or script any tracking pipeline in Blender.

TerminalSkills/skills

>- You are an expert in Bolt.new by StackBlitz, the AI-powered full-stack development environment that runs entirely in the browser. You help developers go from idea to deployed app in minutes using natural language prompts — Bolt generates complete applications with frontend, backend, database, and deployment, all running in a WebContainer without local setup.

TerminalSkills/skills

>- Assists with using Bun as an all-in-one JavaScript/TypeScript runtime, package manager, bundler, and test runner. Use when building HTTP servers, managing packages, running tests, or migrating from Node.js. Trigger words: bun, bun serve, bun install, bun test, bun build, javascript runtime, bun runtime.

TerminalSkills/skills

>- Self-host customer support with Chatwoot. Use when a user asks to set up open-source customer support, add live chat without SaaS costs, build a multi-channel inbox, or deploy a free Intercom alternative.

TerminalSkills/skills

>- You are an expert in Chi, the lightweight, idiomatic Go HTTP router built on `net/http`. You help developers build composable HTTP services using Chi's middleware stack, route groups, URL parameters, sub-routers, and context-based request scoping — providing Express-like ergonomics while staying 100% compatible with Go's standard library.

TerminalSkills/skills

When the user wants to edit, review, or improve existing marketing copy. Also use when the user mentions 'edit this copy,' 'review my copy,' 'copy feedback,' 'proofread,' 'polish this,' 'make this better,' or 'copy sweep.' This skill provides a systematic approach to editing marketing copy through multiple focused passes.

TerminalSkills/skills

>- Add live chat and customer support with Crisp. Use when a user asks to add a chat widget, implement live customer support, set up a help desk, create a knowledge base, or add a chatbot to a website.

TerminalSkills/skills

>- Assists with building custom interactive data visualizations using D3.js. Use when creating charts, graphs, maps, force layouts, or hierarchical diagrams that require fine-grained control beyond what charting libraries provide. Trigger words: d3, data visualization, chart, svg, scales, force graph, treemap, choropleth.

TerminalSkills/skills

dbt (data build tool) transforms data in your warehouse using SQL SELECT statements. Learn project setup, models, tests, documentation, incremental materializations, and integration with data warehouses like PostgreSQL, BigQuery, and Snowflake.

TerminalSkills/skills

>- You are an expert in dlt, the open-source Python library for building data pipelines. You help developers load data from any API, file, or database into warehouses and lakes using simple Python decorators — with automatic schema inference, incremental loading, and built-in data contracts. dlt is the "requests library for data pipelines.

TerminalSkills/skills

>- You are an expert in E2B, the cloud platform for running AI-generated code in secure sandboxes. You help developers give AI agents the ability to execute code, install packages, read/write files, and run long processes in isolated cloud environments — each sandbox is a lightweight VM that boots in ~150ms with full Linux, filesystem, and networking.

TerminalSkills/skills

>- Transcode, convert, edit, and process audio and video with FFmpeg. Use when a user asks to convert video formats (webm to mp4, mkv to mp4), extract audio from video, compress video files, trim or cut clips, concatenate videos, add subtitles, create thumbnails, apply filters, change resolution or bitrate, re-encode media, create GIFs from video, add watermarks, normalize audio, stream media, or build automated media processing pipelines.

TerminalSkills/skills

>- Create advanced animations with GSAP. Use when building complex timelines, scroll-driven animations, SVG morphing, text animations, or high-performance web animations beyond CSS capabilities.

TerminalSkills/skills

>- Generate deterministic MP4 videos from HTML, CSS, media, and seekable animations using HeyGen's HyperFrames framework. Use when someone asks to "render HTML to video", "make a video with HyperFrames", "create a programmatic video", "turn an animation into MP4", "build a launch/product video from HTML", "render GSAP/Lottie/Three.js to video", or set up an agent-driven video pipeline. Covers init/preview/render/add/lint/inspect commands, data-* timing attributes, animation adapters, and the component catalog.

TerminalSkills/skills

When the user wants to perform load testing, stress testing, or performance testing of APIs and websites using k6. Also use when the user mentions "k6," "load test," "performance test," "stress test," "spike test," "soak test," "thresholds," "virtual users," or "VUs." For browser-based testing, see selenium.

TerminalSkills/skills

>- Lovable (formerly GPT Engineer) is a browser-based AI app builder that turns a natural-language description into a working full-stack web app with a built-in backend, authentication, database and one-click publishing. Use when the user wants to prototype or ship a web app with Lovable, write effective Lovable prompts, connect Supabase or GitHub, review generated security rules, or move a Lovable project into their own editor.

相關技能