界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
开发与工程 · SKILL.md

msfm_batch_coupling

msfm_batch_coupling

【开发与工程】Construct uniform and exact small-batch BatchOT couplings for Multisample Flow Matching recovery and tests.

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: msfm_batch_coupling description: Construct uniform and exact small-batch BatchOT couplings for Multisample Flow Matching recovery and tests.

MSFM Batch Coupling

Use this skill when a workflow needs the Multisample Flow Matching pairing step: two equal-size minibatches are converted into either a uniform/independent CondOT baseline or an exact small-batch BatchOT assignment.

Do not use this skill for large production batches unless the exhaustive batch_ot implementation is replaced by a scalable assignment or Sinkhorn solver.

Inputs

  • Source batch: JSON list of numeric vectors.
  • Target batch: JSON list of numeric vectors with the same length and dimension.
  • Method: uniform or batch_ot.

Outputs

  • Pair indices.
  • Mean squared transport cost.
  • Coupling matrix and row/column marginal checks.

Workflow

  1. Validate non-empty equal-size source and target batches.
  2. Compute pairwise squared Euclidean costs.
  3. For uniform, report the independent expected cost and a uniform doubly stochastic matrix.
  4. For batch_ot, solve the exact minimum-cost permutation for small batches.
  5. Use row and column sums to confirm marginal preservation.

Validation

Run:

python scripts/coupling.py --self-test
python tests/test_coupling.py

Limitations

  • batch_ot is exhaustive and intended for bounded recovery/tests.
  • The script implements square couplings only.
  • It preserves the paper mechanism but is not a full high-dimensional training implementation.
我的收藏