diff --git a/spatial/data.py b/spatial/data.py index d4981c1..2488066 100644 --- a/spatial/data.py +++ b/spatial/data.py @@ -220,6 +220,15 @@ def collate(batch, max_entities: int = 32): elif edit.get("op") == "remove_entity": edit_op[i] = 2 edit_idx[i] = ids.get(edit.get("entity"), -1) + # an entity that is gone takes its relations with it. Without this + # the post-intervention graph still has T resting on the pedestal it + # just lost, the hop distance still reports support, and the only + # evidence against support is the edit token itself -- which makes + # "an edit happened, answer false" the cheapest consistent rule. + gone = edit.get("entity") + for k, ed in enumerate(sc.obs.edges): + if gone in (ed.a, ed.b): + edge_removed[i, k] = 1.0 answer[i] = ANSWERS.index(sc.label.answer) change[i] = CHANGES.index(sc.label.change)