Dataset Lineage and Provenance › Mixing and Manifest Commitments

Michael BrenndoerferNovember 26, 20262 min read
Language AI HandbookAll chapters
Part 21 of 67Data Governance, Provenance, and Synthetic Ecosystems
Chapter 149Dataset Lineage and Provenance › Mixing and Manifest Commitments
Reading section 9 of 17 · Mixing and Manifest Commitments · 2 minSection 9 of 17 · 2 min

Section 9 of 17 · 2 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

A mixture plan records intended token shares, a token budget, and any sampling policy or repetition targets. Changing the mixture the learner consumes can change the trained model. Store both the plan and the consumed-input records so you can investigate whether the planned change reached training.

For this token budget, divide each domain's weight among its retained documents and normalize the row weights. These normalized weights are target token shares, even though the fixture field is named sampling_weight. Multiplying by the token budget and rounding gives each row's target. If you instead sample whole documents by these weights, the expected token shares also depend on document lengths.

PythonIn [18]
CollapseExpand
TOTAL_TOKENS = 10_000
SEQ_LEN = 8
domain_weights = {"news": 0.40, "science": 0.30, "code": 0.20, "public": 0.10}

doc_tokens = {doc["doc_id"]: tokenize(doc["text"]) for doc in kept}
domain_counts = Counter(doc["domain"] for doc in kept)

mixture_rows = []
for doc in kept:
    raw_weight = domain_weights[doc["domain"]] / domain_counts[doc["domain"]]
    mixture_rows.append(
        {
            "doc_id": doc["doc_id"],
            "source_id": doc["source_id"],
            "domain": doc["domain"],
            "doc_token_count": len(doc_tokens[doc["doc_id"]]),
            "raw_weight": raw_weight,
            "content_hash": doc["content_hash"],
        }
    )

weight_sum = sum(row["raw_weight"] for row in mixture_rows)
for row in mixture_rows:
    row["sampling_weight"] = row["raw_weight"] / weight_sum
    row["expected_tokens"] = round(row["sampling_weight"] * TOTAL_TOKENS)
    row["epochs"] = row["expected_tokens"] / max(1, row["doc_token_count"])

mix_config = {
    "domain_weights": domain_weights,
    "total_token_budget": TOTAL_TOKENS,
    "sequence_length": SEQ_LEN,
}
config_hash = sha256_text(canonical_json(mix_config))
manifest_root = merkle_root(
    [row["content_hash"] for row in mixture_rows] + [config_hash]
)

for row in mixture_rows:
    log_event(
        row["doc_id"],
        "mixture",
        "weighted_sampling_manifest",
        "include",
        row["content_hash"],
        row["content_hash"],
        sampling_weight=round(row["sampling_weight"], 4),
        expected_tokens=row["expected_tokens"],
        manifest_root=manifest_root,
    )

mixture_df = pd.DataFrame(mixture_rows)[
    [
        "doc_id",
        "domain",
        "doc_token_count",
        "sampling_weight",
        "expected_tokens",
        "epochs",
    ]
]
Out[19]:
doc_id domain doc_token_count sampling_weight expected_tokens epochs
0 doc-6bd4bf650451 news 24 0.40 4000 166.67
1 doc-dd10f119f2fb science 21 0.30 3000 142.86
2 doc-bcb940d2e6f2 code 12 0.20 2000 166.67
3 doc-90510a22cf34 public 18 0.05 500 27.78
4 doc-a86ae901cca2 public 22 0.05 500 22.73

The toy root combines sorted, untagged content and configuration digests. The leaves omit source IDs, row order, leaf roles, and document-level domain and token assignments. Odd-node padding can also hide differences in leaf count. Use typed leaf records and bind their count and fields when the audit needs those distinctions. The hashed training-run record names its configuration digest separately. Record consumed inputs separately from the plan.

The table's sampling_weight, expected_tokens, and epochs fields describe targets and a planned repetition estimate. The bigram demo reads each retained document once in order. Its realized token counts come from the packed positions below. For a distributed job, compare the planned shard IDs with worker consumption records and retain the sampling and exposure counts separately. A finite sample can deviate from its target proportions.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy