Masking

Masking turns a ConversationSnapshot and a CoalitionMask into the prompt the model sees: partitioning picks players, the absence policy renders absent ones, the codec keys each mask.

Partitioning

TokenPartitioner makes each whitespace token a player, with an id from the snapshot id and its position, and returns a PlayerSet in mask-bit order. Other partitioners (sentences, messages, image regions) return other player sets (Extending mllm-shap).

Absence policies

“Cancel my old phone plan today” with Cancel, phone and plan present:

Policy

Rendered prompt

Trade-off

delete (default)

Cancel phone plan

Later tokens shift; the empty coalition is empty text, scored as \(v(\emptyset)\).

pad

Cancel [MASK] [MASK] phone plan [MASK]

No shift; the placeholder must suit the tokenizer and model.

neutral

Cancel __ ___ phone plan _____

Keeps string length (_ per character), no special token.

infill

a masked language model’s top word per gap

Natural text; extra infill (Masking views).

Structural sharing

A MaskedSnapshot references the original snapshot and differs only in mask and policy until MaskBuilder renders it.

Packed masks

MaskCodec packs a mask into little-endian bytes and hashes them with BLAKE2b: the coalition above, bits 1 0 0 1 1 0, is the byte \(1 + 8 + 16 = 25\). The hash ignores PYTHONHASHSEED, so keys match across runs and machines.

MaskSpace maps feature-level splits to full masks when some positions are always present. Custom samplers use it; ExplainRunner does not.

See also