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 |
|---|---|---|
|
|
Later tokens shift; the empty coalition is empty text, scored as \(v(\emptyset)\). |
|
|
No shift; the placeholder must suit the tokenizer and model. |
|
|
Keeps string length ( |
|
a masked language model’s top word per gap |
Natural text; extra |
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¶
Masking views: usage examples
Masking: module reference
Configuration:
playersandabsence_policysettings