Improve attribution viz and SliceAggregator
#282
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR performs the following changes:
Visualization
Rows and columns in the visualization now have indices alongside tokens to facilitate index-based slicing, aggregation and alignment
The directions of generated/attributed tokens were clarified in the visualization using arrows instead of x/y
Slicing
SliceAggregator
("slices"
) is added to allow for slicing source (in encoder-decoder) or target (in decoder-only) tokens from aFeatureAttributionSequenceOutput
object, using the same syntax ofContiguousSpanAggregator
. The__getitem__
method of theFeatureAttributionSequenceOutput
is a shortcut for this, allowing slicing with[start:stop]
syntax.FeatureAttributionSequenceOutput
class design, the generated output will always be preserved in the sliced context (i.e. even if not explicitly included intarget_spans
). Analysis ignoring the generated output attributions will need to manually post-process attribution tensors to consider only the spans of interest.Other aggregation
__sub__
method inFeatureAttributionSequenceOutput
is now used as a shortcut forPairAggregator
: