AgentSkillsCN

wandb-weave

通过 Python 脚本查询并分析 W&B 实验数据与 Weave LLM 追踪日志。适用于以下场景:处理 Weights & Biases 数据,包括(1)查询机器学习实验运行、指标与超参数;(2)分析 LLM 追踪与模型评估;(3)生成 W&B 报告;(4)列出项目与实体。

SKILL.md
--- frontmatter
name: wandb-weave
description: Query and analyze W&B experiment data and Weave LLM traces using Python scripts. Use when working with Weights & Biases data, including (1) querying ML experiment runs, metrics, and hyperparameters, (2) analyzing LLM traces and evaluations, (3) creating W&B reports, (4) listing projects and entities.

W&B & Weave Data Tools

Python scripts to query W&B experiment data and Weave LLM traces.

Prerequisites

bash
pip install wandb weave
export WANDB_API_KEY="your-api-key"

Workflow Decision Tree

code
What do you want to do?
│
├─ Query ML experiments (runs, metrics, sweeps)
│  └─ Run: scripts/query_runs.py
│
├─ Analyze LLM traces
│  ├─ Need trace data? → scripts/query_traces.py
│  └─ Just need count? → scripts/query_traces.py --count-only
│
├─ Create a report
│  └─ Run: scripts/create_report.py
│
└─ List projects
   └─ Run: scripts/list_projects.py

Scripts

query_runs.py

Query W&B experiment runs with filtering and sorting.

bash
# List recent runs
python scripts/query_runs.py <entity> <project> --limit 10

# Filter by state
python scripts/query_runs.py my-team my-project --state finished

# Sort by metric (best first)
python scripts/query_runs.py my-team my-project --sort "-summary_metrics.accuracy"

# Custom filter
python scripts/query_runs.py my-team my-project --filter '{"config.model": "gpt-4"}'
OptionDescription
--limit NMax results (default: 20)
--stateFilter: running, finished, crashed, failed
--sortSort field (prefix - for desc)
--filterJSON filter dict
--outputjson or table

query_traces.py

Query Weave LLM traces with filtering.

bash
# List recent traces
python scripts/query_traces.py <entity> <project> --limit 50

# Filter by status
python scripts/query_traces.py my-team my-project --status success

# Filter by model
python scripts/query_traces.py my-team my-project --model gpt-4o

# Find slow traces
python scripts/query_traces.py my-team my-project --min-latency 5000

# Count only
python scripts/query_traces.py my-team my-project --count-only
OptionDescription
--limit NMax results (default: 50)
--statusFilter: success, error, running
--modelFilter by model name
--min-latencyMin latency in ms
--roots-onlyOnly root traces
--count-onlyReturn count, not data
--filterCustom JSON filter (advanced)

For advanced filter syntax (when --status, --model, --min-latency are not enough), see references/weave_filters.md.

list_projects.py

List entities and projects.

bash
# List all entities and projects
python scripts/list_projects.py

# List projects for specific entity
python scripts/list_projects.py my-team

# List entities only
python scripts/list_projects.py --entities-only

create_report.py

Create W&B reports programmatically.

bash
# Create with inline content
python scripts/create_report.py my-team my-project "Weekly Summary" \
    --content "## Results\n\n- Accuracy: 95%\n- Loss: 0.05"

# Create from markdown file
python scripts/create_report.py my-team my-project "Analysis" --file report.md

# With description
python scripts/create_report.py my-team my-project "Q4 Report" \
    --content "..." --description "Quarterly analysis"

Common Workflows

Analyze Experiment Performance

bash
# 1. Find your project
python scripts/list_projects.py my-team

# 2. Query best runs
python scripts/query_runs.py my-team my-project \
    --state finished \
    --sort "-summary_metrics.accuracy" \
    --limit 10

# 3. Create summary report
python scripts/create_report.py my-team my-project "Best Runs" \
    --content "## Top 10 Runs by Accuracy\n\n..."

Debug LLM Application

bash
# 1. Count errors
python scripts/query_traces.py my-team my-project --status error --count-only

# 2. Get error details
python scripts/query_traces.py my-team my-project --status error --limit 20

# 3. Find slow traces
python scripts/query_traces.py my-team my-project --min-latency 5000

Resources

  • Advanced trace filters: Load references/weave_filters.md when --filter option is needed for complex queries not covered by built-in options