Ecco: An Open Source Library for the Explainability of Transformer Language Models
Paper · 2021 · J Alammar
Summary
When a language system completes a sentence correctly, its answer does not reveal which parts of the input mattered or how its internal processing supported the choice. Ecco addresses that explanatory gap. The paper presents an open-source Python package for interpretability that records internal activity and turns it into interactive displays. Its purpose is to make investigation easier: researchers can examine evidence behind individual generated tokens, compare representations across processing layers, and look for recurring patterns in neuron activity. These views help formulate questions about computation that an output alone cannot answer.
Ecco connects pretrained Transformer systems with analysis interfaces displayed in Jupyter notebooks. Alongside describing support for GPT2, BERT, and RoBERTa, the paper identifies the features available for each architecture. For generated text, its attribution displays assign importance scores to preceding tokens for a selected output token. Other interfaces compare internal representations or apply the final output-scoring mechanism at intermediate layers to track candidate words. A further set of features collects activations inside feed-forward components, which the author emphasizes because they often account for two-thirds of a Transformer block’s parameters.
The demonstrations illustrate different investigative questions. GPT2-XL supplies Shakespeare’s birth year through the tokens 15 and 64, allowing the attribution for each piece to be inspected separately. In a subject–verb agreement example, DistilGPT-2 eventually prefers are over is when the subject concerns keys, despite an intervening reference to a cabinet. The intermediate rankings do not consistently favor that grammatical answer. Another display applies non-negative matrix factorization, or NMF, to neuron activity, exposing a factor apparently associated with pronouns and other factors concentrated in particular passage regions. These examples show what the interfaces make visible; they do not establish complete explanations of the corresponding behavior.
The paper also reports a controlled experiment on part-of-speech tagging. External linear classifiers predict grammatical categories from either BERT’s hidden states or its internal feed-forward activations. Of the dataset’s 10,000 English tokens drawn from version 2 of Universal Dependencies, 67% serve as training data and 33% as test data. Feed-forward representations support accuracy comparable to hidden states, but their trajectories differ: at layers 2 and 3, feed-forward probe accuracy declines while hidden-state accuracy increases. Randomized-label tasks qualify those accuracy results through a measure called selectivity. The empirical contribution is therefore specific: grammatical labels are accessible from both representation types, yet their accessibility changes differently across the network. The paper leaves the mechanism behind that divergence open.
Interesting ideas
Explain the smallest meaningful choice. A generated sentence comprises distinct prediction events, and evidence relevant to one event may differ from evidence relevant to another. Ecco lets the investigator choose the output token being examined. This design principle applies to structured extraction, multistep reasoning, and operational workflows: attach an explanation to the decision it actually concerns before attempting a summary of the whole result.
Make competing outcomes visible. A final answer hides the alternatives that lost. Tracking selected candidates through successive processing stages can reveal where a preference emerges or reverses. Ecco’s grammatical example shows the value of that view without claiming that intermediate rankings are independent decisions. Comparable displays could clarify search procedures, rule cascades, or classification pipelines whose aggregate output conceals important internal disagreements.
Look inside substantial but neglected components. Familiar inspection targets can become default targets merely because convenient interfaces already exist. The paper redirects attention from block outputs toward feed-forward activity within blocks. Engineers can borrow this habit when reviewing systems with intermediate transformations, feature stores, or routing mechanisms that influence behavior but rarely appear in diagnostic reports.
Reduce complexity while retaining examples. NMF produces a manageable collection of patterns from a much larger activation record. The interface then reconnects each pattern to the text positions that elicited it. This is useful beyond neuron analysis: summaries of corpus features, error signatures, or execution traces become more informative when a reader can move directly from the summary to the observations behind it.
Challenge the diagnostic itself. A classifier trained to inspect a representation can exploit its own learning opportunities. Ecco therefore pairs grammatical prediction with randomized-label controls. The reusable principle is to test whether an analytical method succeeds after the relationship of interest has been removed. Such controls are relevant whenever an evaluator, selector, or explanatory procedure might manufacture an apparently meaningful result.
Compare several measurements of the same representation. Accuracy and selectivity answer different questions, while hidden states and feed-forward activity offer different observation points. Keeping these distinctions visible prevents a single favorable score from becoming an unrestricted claim about understanding. The approach generalizes to any investigation where several imperfect measurements describe different aspects of the same process.
Use exploration to formulate a refutable account. A coherent visual pattern can suggest an explanation without proving it. The author explicitly treats visual inspection as preparation for hypotheses that evidence could contradict. A productive workflow records the pattern, states what it is thought to mean, and identifies a comparison that would undermine that interpretation. This gives exploratory interfaces a scientific role beyond making complicated activity look comprehensible.
Deep dive: Ecco: An Open Source Library for the Explainability of Transformer Language Models
Ecco combines token attribution, interactive views of Transformer activity, and controlled probes to investigate internal language processing. · about 38 minutes to read
How Mova uses it
Mova is a compact Rust system whose native language path constructs dependency trees, extracts frames, and maintains a world of entities and events. Its emphasis on explicit rules and statistics differs from Ecco’s investigation of neural computation. Nevertheless, the paper offers useful designs for observing decisions, organizing diagnostic evidence, and testing interpretations. The most direct transfers concern those designs instead of importing neuron-analysis machinery into Mova’s native core.
The marks below compare proposals with documented Mova mechanisms. They indicate conceptual overlap and possible development work, not measured adoption of Ecco. Existing features are not attributed to this paper without evidence. Where a proposal is marked new, that judgment remains provisional because the documented coverage is incomplete. None of the proposed extensions has an established effect merely because the corresponding idea is useful in Ecco.
Idea: Give every supported conclusion its own evidence attachment. Where: Section 2 and Figures 3 and 4. Area: explanation granularity. Mova: частково є (answer reasons and explicit rule evidence in README.md and docs/architecture.md). Ecco changes the displayed attribution when the selected output changes. Mova could apply that discipline to separate claims within an answer, showing the relevant world state and rule for each. Why Mova: A compound response may contain a well-supported conclusion beside an uncertain one, and a shared explanation can obscure that difference.
Idea: Show computational segmentation alongside readable text. Where: Section 2.1 and Figure 3. Area: tokenization. Mova: частково є (French segmentation in en/src/tok.rs and token-position evidence in tools/dictindex). The divided birth year demonstrates that a surface expression need not match the units processed internally. Mova could align source spans with its syntactic tokens in diagnostic displays. Why Mova: Developers could identify whether a failed interpretation began with segmentation before changing later grammatical or semantic rules.
Idea: Provide linked summary and precise inspection views. Where: Sections 2.1 and 2.2. Area: diagnostic presentation. Mova: частково є (brief answer reasons, assessment traces, and parser audit outputs). Ecco offers both shading and a more explicit attribution display. A corresponding Mova interface could connect an accessible explanation to exact tree relations, frame roles, and source records. Why Mova: Different readers need different levels of detail, but those views should describe the same recorded evidence.
Idea: Label normalized quantities as presentation choices. Where: Section 2.2 and Figure 4. Area: statistics and interface semantics. Mova: нове. Ecco presents normalized attribution percentages; these concern a selected calculation rather than probabilities of an explanation being correct. Any analogous Mova display could declare the normalization scope and underlying quantity. Why Mova: A percentage can look authoritative even when it merely rescales diagnostic values. The documentation does not establish a matching normalization contract, so the novelty mark is tentative.
Idea: Preserve the distinction between influence and justification. Where: Section 2.2, gradient-based attribution discussion. Area: epistemic status. Mova: частково є (typed evidential information in prag/src/frames.rs and evidence boundaries in docs/hybrid-system.md). If sensitivity scores are added around learned components, they should remain a separate observation type from rule-based reasons. Why Mova: A feature can influence a score without supplying a logically sufficient premise, and Mova’s explanations should retain that boundary.
Idea: State what information a scalar summary discards. Where: Section 2.2, the L2 aggregation in the attribution formula. Area: mathematical diagnostics. Mova: частково є (declared observation contracts in groupants and correspondence tooling). Ecco reduces a vector to a magnitude. Mova could require comparable diagnostic summaries to document whether they retain direction, sign, ordering, or only size. Why Mova: Two underlying observations may receive similar summary values while supporting different interpretations.
Idea: Track rejected candidates through the pipeline. Where: Sections 3.2 and 3.3. Area: error localization. Mova: частково є (staged language processing and logged domain routing in docs/architecture.md). Ecco follows output alternatives across layers. Mova could retain bounded candidate histories across parsing, frame extraction, and world updates. Why Mova: A record of when an alternative disappears would help locate the responsible transformation rather than assigning every wrong answer to the final reader.
Idea: Use grammatical distractors in controlled contrasts. Where: Section 3.3 and Figure 8. Area: syntax evaluation. Mova: частково є (documented syntactic repairs and coreference contrast sets). The keys-and-cabinet example separates the grammatical subject from a nearby noun with conflicting number. Mova could create equivalent controlled cases for dependency roles and agreement-sensitive interpretation. Why Mova: Such cases test whether structural relations survive a misleading local cue, rather than merely checking familiar vocabulary.
Idea: Treat intermediate readouts as declared instruments. Where: Section 3.2. Area: measurement design. Mova: частково є (typed observations and compatibility requirements in docs/hybrid-system.md). Ecco interprets intermediate states through an output head. A Mova diagnostic that converts a tree or graph into answer candidates should similarly identify that conversion as part of the measurement. Why Mova: An inspection procedure may expose useful information without reproducing the actual execution path.
Idea: Inspect components whose influence exceeds their visibility. Where: Section 4, motivation for feed-forward inspection. Area: system observability. Mova: частково є (parser audits, worker outcomes, and frame diagnostics). The transferable principle concerns neglected computation, not a requirement for neural components. Mova could examine feature construction, domain coverage calculations, or retained-state changes that are presently hard to inspect. Why Mova: A hidden preparation step can determine later behavior even when benchmark reports emphasize the final answer.
Idea: Compare representation spaces only under matching conditions. Where: Section 3.1 and Figure 6. Area: representation analysis. Mova: частково є (source-bound comparisons and explicit compatibility checks in groupant tooling). Ecco compares captured internal activity through common analytical methods. Mova could compare tree, frame, and retained-graph observations for the same source and task. Why Mova: Matching the observation conditions would make information loss easier to identify without confusing it with a change of input.
Idea: Keep similarity separate from interchangeability. Where: Section 3.1. Area: mathematical evidence. Mova: вже є (finite correspondence scope and equivalence cautions in docs/correspondences.md and docs/hybrid-system.md). Representation similarity can guide investigation without proving that components perform the same function. Mova already makes an analogous distinction for formalized finite relations. Why Mova: The existing boundary prevents a convenient agreement score from being promoted into an unsupported claim about source equivalence.
Idea: Maintain alternative comparison methods as distinct observations. Where: Section 3.1, discussion of CCA-related interfaces. Area: analysis methodology. Mova: частково є (typed model observations and declared conformance profiles in groupants). Ecco bundles several comparison procedures instead of defining representation relatedness through a single interface. Mova could retain method identity and assumptions whenever several diagnostics examine the same structures. Why Mova: Agreement under one measurement need not settle a question posed by another.
Idea: Summarize large diagnostic collections into inspectable groups. Where: Sections 4.2 and 4.3. Area: exploratory data analysis. Mova: частково є (statistical frame and collocate proposals in tools/dictindex). Ecco’s factors make dense activity records easier to browse. Mova could explore corresponding summaries of rule responses or error patterns, keeping their source members available. Why Mova: Large collections can hide recurring failures, while a compact grouping can suggest a bounded repair hypothesis.
Idea: Allow overlapping patterns rather than forcing a partition. Where: Section 4.2 and the factor-based activation interface. Area: data organization. Mova: вже є (overlapping selectors described in tools/dictindex). Ecco’s view permits several factors to describe activity over the same text. Mova’s dictionary proposals likewise need not divide usages into mutually exclusive senses. Why Mova: A sentence can exhibit several grammatical and lexical properties simultaneously, so premature exclusive grouping can conceal useful evidence.
Idea: Keep statistical group names provisional. Where: Section 4.2 and Figure 9. Area: lexical interpretation. Mova: вже є (reviewed, versioned labels separated from statistical proposals in tools/dictindex). The pronoun-associated factor is an interpretation of observed activity, not an admitted linguistic definition. Mova already requires review before a selector acquires accepted dictionary meaning. Why Mova: An attractive group description should remain revisable when additional examples reveal mixed behavior.
Idea: Test position as an alternative explanation. Where: Figure 9 and its discussion of passage regions. Area: confound analysis. Mova: нове. A group that appears semantic might instead follow sentence position, document region, or layout. Mova could compare those explanations when reviewing diagnostic clusters. Why Mova: Positional regularities can masquerade as meaning, particularly in repetitive source formats. A matching implemented check is unknown, and the new-status proposal does not prove its absence.
Idea: Analyze activity at several scopes. Where: Section 4.3. Area: aggregation design. Mova: частково є (individual-crate checks and complete reading-path assessments). Ecco allows factorization over selected layers or broader activation collections. Mova could connect reports for individual rules, rule families, and whole workflows. Why Mova: An aggregate improvement may conceal a local regression, while an isolated pattern may fail to survive the full pipeline.
Idea: Preserve exact examples behind every compact pattern. Where: Section 4.2 and Figure 9. Area: provenance. Mova: вже є (stable posting identifiers, sentence text, source credits, and selector members in tools/dictindex). Ecco’s interaction connects factor activity with particular text positions. Mova’s indexed evidence already supports an analogous route from a statistical proposal to attributed occurrences. Why Mova: Review depends on inspecting the actual witnesses, including parser mistakes and unusual source conventions.
Idea: Ask whether information is recoverable before changing the solver. Where: Sections 4.1 and 5.1. Area: diagnostic learning. Mova: частково є (explicit intermediate structures and categorized fast-reader failures). A bounded probe could test whether an existing representation supports a distinction that the current reader misses. Why Mova: Missing representation and ineffective decision logic require different changes. A diagnostic could help distinguish them while remaining separate from the production answer path.
Idea: Establish an early-stage baseline. Where: Section 5 and Table 1, embedding comparison. Area: baseline design. Mova: частково є (school controls and audits of lexical contributions). Ecco tests the representation available before contextual layers as well as later representations. Mova could compare dictionary-only evidence with evidence after frame construction or retention. Why Mova: An apparent reasoning success may rely on lexical information already available before the reasoning stage begins.
Idea: Apply matched random-label controls to learned inspections. Where: Sections 5.1 and 5.2. Area: evaluation controls. Mova: частково є (school controls and permuted-confidence analysis in prag/src/eval.rs). Ecco trains separate probes on labels unrelated to the intended grammatical target. An analogous Mova diagnostic would need its own matched control, instead of relying on a favorable real-label score. Why Mova: Diagnostic training can introduce memorization that is absent from native deterministic inference.
Idea: Report real-task performance together with control sensitivity. Where: Section 5.1 and Table 1. Area: metric interpretation. Mova: частково є (control-bearing assessment reports and confidence-reliability analyses). Ecco reports selectivity beside accuracy. If Mova introduces representation probes, their reports should retain both quantities and explain their different meanings. Why Mova: A strong score becomes more informative when readers can see whether the inspection method also succeeds under an intentionally uninformative target.
Idea: Separate changes in task accuracy from changes in control behavior. Where: Section 5.3 and Table 1. Area: statistical diagnosis. Mova: частково є (multiple evaluation controls and explicit failure categories). Selectivity can rise even when actual-task accuracy falls, because it incorporates the randomized task. Mova could preserve both underlying measurements whenever a derived diagnostic is reported. Why Mova: A favorable summary should not conceal deterioration in the practical target or improvement caused mainly by a weaker control result.
Idea: Keep comparison conditions aligned. Where: Section 5.2. Area: experimental design. Mova: вже є (same-question comparisons in tools/enrich and regression requirements in docs/architecture.md). Ecco uses a common probing task across layers and representation types. Mova’s existing practice similarly requires comparable assessment conditions when judging a proposed change. Why Mova: Differences are easier to interpret when they cannot be explained by a different item collection or an altered scoring procedure.
Idea: Report variability introduced by diagnostic training. Where: Section 5.2 and Table 1. Area: statistical reporting. Mova: частково є (deterministic repeat checks and bootstrap analyses in documented evaluations). Ecco repeats probe training and reports averaged results with accompanying variation. A learned Mova diagnostic should expose its training variability separately from deterministic native outputs. Why Mova: Repeatable execution does not eliminate uncertainty introduced by sampled data or a separately trained evaluator.
Idea: Record tuning choices without confusing them with final evidence. Where: Section 5.2, learning-rate comparison. Area: evaluation procedure. Mova: частково є (held-out development gates and restricted assessment access). The paper names the tried learning rates and its chosen setting, while leaving selection details incomplete. Mova could make a diagnostic’s selection record explicit. Why Mova: Reviewers need to know which decisions were exploratory and which conditions were fixed before the reported comparison.
Idea: Investigate local declines without assuming global failure. Where: Section 5.3 and Table 1. Area: pipeline interpretation. Mova: частково є (fast-reader analyses distinguishing representation, inference, parameter, and parse failures). Ecco finds different trajectories at internal observation points. Mova could preserve such disagreements between stages instead of demanding that every intermediate score improve together. Why Mova: A local diagnostic may measure a different accessible property from the property needed by the final reader.
Idea: Specify the exact point where an observation is collected. Where: Section 5.1, feed-forward sampling after GELU. Area: instrumentation. Mova: частково є (named pipeline stages and source-bound worker observations). Ecco identifies a particular internal activation location. Mova could require equally precise event names and state boundaries for comparisons of parsing, interpretation, and retention. Why Mova: Similar labels such as intermediate state can conceal materially different observations.
Idea: Separate evidence capture from presentation. Where: System Design section. Area: software architecture. Mova: частково є (structured command results, retained artifacts, and worker reports). Ecco collects internal data, performs analysis, and renders interactive views through separate implementation responsibilities. Mova could expose an observation record usable by both command-line and graphical consumers. Why Mova: A revised interface should not change the authoritative evidence or require rerunning the original task unnecessarily.
Idea: Publish capability boundaries per analysis path. Where: Limitations section. Area: capability contracts. Mova: вже є (explicit CPU/GPU boundaries and configured deputy capabilities). Ecco distinguishes attribution availability from activation collection and reduction support. Mova already documents comparable distinctions between execution paths and admitted tasks. Why Mova: Users should be able to determine whether an operation is supported rather than inferring it from another nearby feature.
Idea: Design interaction around a question, not an undifferentiated dashboard. Where: Sections 2.1, 3.3, and 4.2. Area: human inspection. Mova: частково є (question traces and source-bound queries in tools/dictindex). Ecco’s interfaces select a token, an alternative pair, or a factor. Mova could offer similarly focused views of a disputed dependency, world update, or dictionary selector. Why Mova: A specific investigative target makes a large diagnostic record easier to evaluate.
Idea: Promote observations into tests through an explicit review step. Where: Limitations and Conclusion sections. Area: falsifiable evaluation. Mova: вже є (held-out gates, negative controls, and reviewed enrichment staging). Ecco encourages investigation beyond visual intuition. Mova’s existing change process can turn an observed pattern into a contrast set or scoped rule proposal before acceptance. Why Mova: A test capable of rejecting a plausible explanation provides stronger evidence than a convincing display.
Idea: Keep exploratory output outside automatic knowledge admission. Where: Sections 4.2 and 5, together with the stated visualization caution. Area: durable learning. Mova: вже є (review-only consultant notes, staged proposals, and separate admitted training). Neither a factor interpretation nor a successful probe supplies a new dictionary fact on its own. Why Mova: Preserving this boundary allows broad exploration without letting an erroneous explanation silently alter the retained graph or shipped rules.
The problem and its context
Performance and explanation answer different questions
The paper begins with rapid progress in language technology built around Transformers. It cites applications extending into vision, including image recognition with Transformers. Its concern is that practical achievements have advanced faster than understanding of the computations behind them. Ecco responds to that mismatch by improving access to internal observations.
An output supplies behavioral evidence. It tells an investigator which continuation was selected or which answer appeared. It does not identify the input cues responsible for that outcome, show whether intermediate processing supported an alternative, or explain the contribution of a particular component. Those are separate questions requiring additional observations and carefully chosen analytical procedures.
The repeated structure introduced in Attention Is All You Need makes several observation points available. Researchers can inspect the representation after a block, the activity inside its feed-forward component, or the output scores associated with the final prediction. Ecco organizes methods for examining these objects without treating them as interchangeable descriptions of the same fact.
The paper situates this need alongside pretrained systems such as BERT and RoBERTa. It also references the development represented by Language Models are Few-Shot Learners. These works provide motivation for inspection. Ecco does not reproduce their task results or claim that a single visualization explains the capabilities they demonstrate.
Attribution needed a generation-oriented interface
The paper introduces input attribution through an image-classification example associated with Ribeiro and colleagues. An animal prediction might depend on the animal’s appearance or on snow elsewhere in the picture. A saliency display helps investigate that possibility by assigning importance to parts of the input.
In language processing, the input units are tokens rather than pixels. The general problem remains the same: determine how an attribution procedure connects an output to its input features. The paper cites earlier language-oriented visualization and broader explainable artificial intelligence research as background.
Its particular interface choice concerns text generation. The author notes that attribution research had more commonly addressed classification. A classification display typically concerns a chosen class for an input. Generated text creates successive output events, so the investigator must also specify which generated token is being explained.
Ecco makes that selection part of the interface. The user can inspect one output and then move to another without treating the whole continuation as a single attribution target. This is a practical contribution to access and presentation, built around an existing gradient-based technique rather than a newly introduced attribution theory.
Representation analysis already had established methods
Ecco draws together several traditions in internal analysis. Some methods compare representations with one another. Others predict external linguistic labels from representations. Still others inspect individual neurons or groups of activations. The paper’s contribution is the combined environment and its attention to an internal representation that had received less probing attention.
For representation comparisons, the author describes earlier work on information flow, multilingual systems, and relationships between different language systems. Canonical correlation analysis and related methods provide tools for comparing observed activity. Ecco includes procedures associated with work on similarity between neural representations.
For linguistic testing, the background includes auxiliary prediction tasks and studies of linguistic properties recoverable from representations. A trained diagnostic classifier asks whether a representation supports prediction of a selected label. The paper adopts this approach while also incorporating concerns about what the diagnostic classifier itself can learn.
The use of probe control tasks addresses that concern. Good classification accuracy can reflect more than a clean linguistic organization in the representation being inspected. The diagnostic learner may exploit token identity or memorize useful associations. A randomized target provides a comparison against which real-label success can be judged.
Neuron inspection motivates the feed-forward study
Earlier work cited by the paper examines neuron responses in language and vision. References include visual analysis of recurrent computation, interactive inspection systems, and studies of individual neurons. Ecco continues that investigative tradition while directing attention to Transformer feed-forward components.
The paper gives a structural reason for that attention: the feed-forward sublayer frequently contains two-thirds of the parameters in a Transformer block. Its internal activity is consequently a substantial object of analysis, even though many investigations have focused on hidden states at block boundaries.
This motivation leads to a concrete empirical question. If grammatical labels are predictable from hidden states, are they also predictable from the activity inside feed-forward sublayers? Furthermore, does predictability develop in the same way at those different locations? The case study is designed to answer those limited questions, leaving broader claims about causal function for further work.
The method, step by step
Observation begins with an ordinary processing run
Ecco operates around an already trained language system. Its wrapper records the internal quantities required by an analysis and then computes diagnostic results from those records. Depending on the question, the captured data can include hidden states, feed-forward activations, or gradients used for attribution.
This arrangement separates the object of investigation from the investigation procedure. The underlying system processes the input. Ecco makes selected aspects of that processing available for analysis. A factor extracted from activations does not become an additional step in generation, and a probe trained afterward is not part of the original prediction mechanism.
The implementation uses PyTorch and Hugging Face Transformers alongside scientific-computing packages including NumPy, Matplotlib, and Scikit-Learn. Interactive displays use web components manipulated with D3.js. The paper also credits existing implementations for its representation-comparison methods.
The broad investigative sequence is:
Ecco’s path from computation to investigation
The steps in order.
Not every use follows every step. A person examining an attribution display may stop after exploring a prediction. The quantitative study continues into controlled testing. The diagram represents the relationship among those activities rather than a mandatory execution pipeline.
Select the output before calculating attribution
Ecco’s generation-oriented attribution begins with a particular output token. The relevant question is how the score for that token relates to the embeddings of tokens already available as input. An embedding is a vector through which a token is represented in the neural computation.
The selected output has a score. Back-propagation calculates the gradient of that score with respect to each input embedding. A gradient describes local sensitivity: how the selected score responds to changes in the embedding coordinates around the observed computation.
Ecco uses Gradients X Inputs, multiplying each embedding coordinate by the corresponding gradient coordinate. It then summarizes the resulting vector through an L2 norm. Rewriting the paper’s expression with an explicit name for the resulting score gives:
sᵢ = ‖∇ₓᵢ f꜀(X₁:ₙ) ⊙ Xᵢ‖₂
Here, sᵢ denotes the attribution magnitude for input position i. Xᵢ is the embedding vector at that position. X₁:ₙ represents the embedding sequence through position n. The function f꜀ returns the score associated with selected output token c. The expression ∇ₓᵢ is the gradient with respect to Xᵢ. The symbol ⊙ means coordinatewise multiplication. The surrounding norm converts that vector into its L2 magnitude.
The formula matters because it specifies the observation being displayed. Ecco is not simply counting input words related to the output. It is calculating a quantity from the current embedding values and the sensitivity of a selected score. The resulting scalar measures magnitude under that procedure.
The paper motivates the choice by citing prior evaluation of attribution methods for Transformer text classification. It also cites earlier work associated with the Gradients X Inputs technique. That background explains the methodological choice, but it is separate from a generation-specific validation of every attribution displayed by Ecco.
Render the same attribution at different levels of detail
The overview interface shades input tokens according to their attribution values. Darker backgrounds indicate larger values. Selecting a different generated token changes the target score and therefore changes the attribution question.
A more detailed interface presents normalized values as percentages and bars. This makes relative magnitudes easier to inspect than shading alone. The detailed view is especially useful when an investigator needs to compare tokens whose colors appear similar.
These percentages require careful interpretation. They express the normalized attribution display for a chosen output. They are not probabilities that the corresponding token supplies a correct explanation, nor are they measurements of logical necessity. The calculation remains the gradient-based magnitude defined above.
The birth-year example shows why separate output selection is useful. The written year 1564 is absent as a single vocabulary item, so GPT2-XL produces 15 followed by 64. Each generated piece has its own score and attribution pattern. The readable answer appears unified, but the underlying prediction events are separate.
This example also introduces tokenization as an explanatory consideration. An investigator looking only at words or complete numbers can overlook the actual computational units. Ecco’s interface preserves those units rather than attaching a single undifferentiated explanation to the final surface string.
Compare observed representations
Hidden states are vector representations carried through successive blocks. They provide one observation point for studying how processing changes the information accessible at each layer. Feed-forward activations provide another observation point inside a block.
Ecco exposes several procedures for comparing representation collections: CCA, SVCCA, PWCCA, and CKA. Their purpose is to quantify relationships between internal activity spaces. The paper describes these methods as established techniques that it makes conveniently accessible.
Canonical correlation approaches seek related structure between sets of observed activations. In the paper’s explanation, the resulting scale extends from no correlation to a relationship expressible through linear transformations. The article does not derive these procedures or propose a replacement objective for them.
The demonstration involving a distilled BERT system compares hidden states with feed-forward activity. This illustrates that the same analytical environment can examine more than block outputs. It does not establish that high similarity entails equivalent linguistic content or interchangeable computational function.
The distinction between comparison and explanation is important. Two representations can be related under a chosen metric while differing in what an external classifier can recover from them. Conversely, different-looking spaces may support similar task performance. Ecco provides tools for investigating these relationships instead of collapsing them into a single interpretation.
Project intermediate states into candidate words
Another interface makes hidden-state evolution readable through the output vocabulary. The language system’s output head normally maps a final representation to vocabulary scores. Ecco applies that head to representations from intermediate layers as well.
This produces a diagnostic sequence of rankings. A candidate can rise, fall, or exchange position with another candidate as processing proceeds. The investigator sees a trajectory expressed in familiar words instead of having to interpret raw vector coordinates.
The country-list example follows possible country continuations. The figure caption identifies GPT2-XL and states that output generation uses top50 sampling. The purpose of the display is to show how candidate rankings evolve, rather than to benchmark geographical knowledge.
A ranking at an intermediate layer should be read as the result of applying the chosen output projection there. The paper’s method does not imply that the system commits to a sequence of provisional answers in precisely that form. The display translates internal states through a common instrument so that differences become visible.
Follow grammatical alternatives
Ecco can narrow the ranking display to selected competing tokens. The paper uses a subject–verb agreement example inspired by syntax-sensitive dependency evaluation. The sentence concerns keys associated with a cabinet, and the completion alternatives are is and are.
The grammatical subject is plural, whereas the intervening cabinet reference is singular. A preference based on the nearest noun could therefore conflict with the grammatical relationship. This makes the example useful for examining whether a representation supports the appropriate continuation.
DistilGPT-2 ultimately ranks are above is. However, the displayed trajectory shows that this preference is not present throughout the intermediate layers. The author emphasizes the unresolved question raised by the late correction.
The method therefore accomplishes a narrower but valuable task: it identifies a discrepancy worth explaining. It does not yet determine whether particular attention patterns, feed-forward transformations, or other computations cause the final ranking reversal.
Record the internal feed-forward representation
The quantitative case study collects a specific internal activation point in BERT. The author records the widest feed-forward layer after GELU, an activation function. That location supplies 3072 neuron values for each token.
Naming the location prevents ambiguity. A block’s output hidden state and its internal post-GELU activation are different observations. Calling both simply a layer representation would conceal the distinction that the experiment is designed to investigate.
This sampling choice also bounds the result. The study concerns information accessible from the captured activations, not every possible representation within the feed-forward component. A different internal location could support a different diagnostic outcome, but the paper does not evaluate that possibility.
Extract shared activation patterns with NMF
Neuron activity across a passage creates a large record. NMF reduces that record to a smaller set of factors whose activation patterns can be examined across token positions. The paper describes this as a way to reveal behavior shared by groups of neurons.
The demonstration derives ten factors from activity in layer #0 while processing a passage from Notes from Underground. The interface places compact line plots beside the text. A line plot summarizes where a factor is active across the sequence; selecting it reveals the corresponding activity over individual tokens.
Factor 5 appears to respond to pronouns. Other factors concentrate on the beginning, middle, or end of the passage. These patterns offer different kinds of possible interpretation: one apparently grammatical, others associated with position.
The text-to-factor connection is central to the interface. Without it, a factor would remain an abstract numerical component. Highlighting the contributing positions lets an investigator inspect whether the apparent interpretation actually matches the examples.
NMF can be applied to activity from an individual layer, selected layers, or a broader network collection. The paper supplies an intuitive factorization explanation but no additional optimization formula in the text. Its methodological claim is about making large activation records easier to explore, not establishing an optimal factor count or a uniquely correct linguistic decomposition.
Train external classifiers on fixed representations
The probing study begins by passing the dataset through BERT and recording the selected representations. The author then trains linear classifiers to predict each token’s grammatical category from those recorded values.
A linear probe uses a restricted classifier family, making the test a question about what can be recovered through that family. It is an external diagnostic trained for the investigation. BERT itself is not described as being retrained for part-of-speech prediction in this experiment.
The dataset comes from Universal Dependencies version 2 and contains English tokens. The author extracts 10,000 tokens, assigning 67% to training and 33% to testing. Probe training runs for 50 epochs with Adam.
The paper reports trials with learning rates 0.1, 0.001, and 1e-5. Results are presented for 0.001, identified as the strongest setting. The selection procedure is not described in enough detail to determine exactly which data governed that choice.
The experiment includes five trials. Within each trial, probes are trained across layer locations, representation types, and real or randomized labels. The resulting table reports average performance accompanied by variation.
Add a control for the diagnostic learner
A probe can succeed in part because it learns useful associations during its own training. To investigate this possibility, the paper assigns random grammatical labels for a control task and trains a separate probe on that task.
Selectivity is the actual-label accuracy after subtracting the control-task accuracy. It therefore asks how much stronger the real grammatical prediction is than the matched randomized target. Larger selectivity strengthens the case that the representation supports the intended distinction beyond what the control reveals.
This is not the same quantity as task accuracy. A representation can yield high actual-label accuracy while also supporting strong randomized-label performance. Its selectivity can consequently remain low.
The control also does not make probing a causal experiment. It addresses a concern about the diagnostic learner, while leaving open how the original language system uses the representation. The paper’s conclusions are strongest when accuracy, selectivity, and observation location are considered together.
Experiments and results
The measured task is diagnostic prediction
The main numerical experiment compares grammatical-category prediction from different BERT representations. Its practical target is external linear-probe test accuracy, accompanied by selectivity from the randomized-label comparison.
The hidden-state probe provides a familiar reference, while the feed-forward probe addresses the paper’s less explored target. An embedding-level result gives an earlier baseline before contextual processing through the blocks.
All these results belong to the stated English Universal Dependencies setup. They are not measurements of a newly trained end-to-end tagger competing against specialist tagging systems. Nor do they quantify whether Ecco users explain predictions more accurately after inspecting the interface.
This distinction helps interpret the paper’s empirical contribution. It shows what an external diagnostic can extract from the selected representations under a common protocol. It does not establish how the original system represents grammatical categories in every task or whether those categories directly control generation.
A local divergence appears across layers
The most striking comparison concerns layers 2 and 3. Feed-forward probe accuracy falls, while the corresponding hidden-state probes continue improving. Including layer 1 makes the opposing trajectories visible.
English UD test accuracy from BERT internal representations
The sampled feed-forward activations and hidden states expose different layerwise trajectories.
The numbers
| System or setting | probe accuracy % |
|---|---|
| Layer 1 feed-forward | 93.3 |
| Layer 1 hidden state | 93.6 |
| Layer 2 feed-forward | 87.3 |
| Layer 2 hidden state | 94.2 |
| Layer 3 feed-forward | 84.7 |
| Layer 3 hidden state (this paper) | 94.7 |
The reported feed-forward result at layer 2 is 87.3 (±0.5), while its hidden-state counterpart is 94.2 (±0.3). At layer 3, the feed-forward entry is 84.7 (±0.5), alongside 94.7 (±0.3) for the hidden state.
These observations prevent a simple interpretation in which every representation inside a block exposes grammatical information to the probe in the same way. The internal feed-forward measurement is not an adequate substitute for the block-output measurement.
The author suggests that different feed-forward sublayers might expose different grammatical subsets, with useful information accumulated across processing. That proposal is an interpretation to investigate. The study does not identify those subsets or isolate the computation that combines them.
Strong performance is available from both representation types
The local divergence does not mean that feed-forward activations are generally uninformative. Elsewhere in the table, they support strong grammatical prediction. Their highest listed accuracy occurs at layer 5, while hidden states reach their highest listed accuracy at layer 4.
Best listed BERT representation settings for English UD probing
Feed-forward activity supports grammatical prediction comparable to the strongest hidden-state setting.
The numbers
| System or setting | probe accuracy % |
|---|---|
| Feed-forward layer 5 | 94.6 |
| Hidden-state layer 4 (this paper) | 94.9 |
The accompanying reported values are 94.6 (±0.3) for the feed-forward setting and 94.9 (±0.2) for the hidden-state setting. These results support the bounded claim that grammatical categories are accessible from the sampled internal feed-forward activity at a level comparable to hidden states.
Comparable accuracy does not imply identical representations. It also does not establish equal performance on another linguistic task. The evidence concerns the labels, classifier family, data selection, and internal locations specified in the experiment.
There is a further reason to resist a single-layer ranking of grammatical understanding. The layers with the strongest accuracy need not be those with the strongest selectivity. Different metrics can favor different observation points because they incorporate different information.
Selectivity changes the interpretation
The embedding baseline yields accuracy of 87.6 (±0.5), accompanied by selectivity of 6.1 (±1.1). The author treats that combination as evidence that accuracy alone overstates what the grammatical result establishes.
The control-adjusted comparison around the divergent layers is also informative. Feed-forward activity can show lower actual-task accuracy while producing stronger selectivity than the corresponding hidden state.
Selectivity of BERT probes on English UD grammatical labels
Accounting for randomized-label performance changes the comparison between internal observations.
The numbers
| System or setting | selectivity |
|---|---|
| Layer 1 feed-forward | 14.8 |
| Layer 1 hidden state | 17.9 |
| Layer 2 feed-forward (this paper) | 35.9 |
| Layer 2 hidden state | 20.9 |
| Layer 3 feed-forward | 34.6 |
| Layer 3 hidden state | 23.9 |
This pattern is consistent with the definition of selectivity. A lower real-task score can coexist with a larger separation from the randomized task. It would therefore be misleading to describe accuracy and selectivity as interchangeable estimates of a single hidden quantity.
Later entries maintain the distinction. The hidden-state result at layer 10 has accuracy of 90.6 (±0.5) and selectivity of 37.3 (±0.9). Feed-forward activity at layer 11 has accuracy of 87.9 (±0.5) and selectivity of 36.5 (±0.8). These paired measurements describe different aspects of the diagnostic outcome.
The table thus supports more than the statement that grammatical labels are predictable. It shows why an investigator should ask how that prediction compares with a control and where inside the network the observation was collected.
The demonstrations have narrower evidential roles
The Shakespeare example demonstrates token-specific attribution. GPT2-XL generates the year 1564 through separate vocabulary items, and Ecco permits their input attribution patterns to be examined independently. The paper does not report a factual-completion benchmark around this example.
The agreement display demonstrates a changing diagnostic preference. DistilGPT-2 eventually favors the plural continuation, although five layers do not place it above the singular alternative. This is evidence about the displayed run and projection, instead of a broad grammatical-competence evaluation.
The factorization example demonstrates that a compact representation of activity can make recognizable patterns visible. Its pronoun-associated factor is not evaluated as a grammatical detector with precision or recall. The positional factors likewise provide an observation without a reported intervention testing their cause.
The similarity view demonstrates another supported analysis route. It makes internal-space comparisons accessible, but the paper does not give a numerical benchmark showing that this interface improves explanation quality. The controlled part-of-speech experiment remains the main source of quantitative findings.
What the ablations show
The paper contains no standard ablation in which a proposed component is removed and task performance is measured; instead, it offers controlled representation comparisons, randomized-label tests, and exploratory analyses.
Randomized labels test a competing explanation
The most consequential control concerns the probe itself. A strong classifier result might suggest that the inspected representation organizes grammatical information clearly. Yet some success could come from associations acquired by the diagnostic learner.
The randomized task preserves an opportunity to train a classifier while removing the intended grammatical target. Its result therefore challenges the interpretation of real-label accuracy. The embedding baseline shows why this challenge matters: favorable accuracy does not automatically produce strong selectivity.
Selectivity summarizes that comparison, but it should not conceal the constituent results. A change in selectivity could arise through a change in grammatical prediction, randomized prediction, or both. Reading it alongside accuracy prevents those possibilities from being collapsed.
The control is valuable because it targets a specific alternative account of diagnostic success. It is not valuable because it eliminates every possible confound. The paper’s design supports a more cautious interpretation of probe accuracy, rather than a universal certification of linguistic representation.
Changing observation location reveals different accessibility
The feed-forward and hidden-state comparison holds the linguistic target constant while changing the source representation. The same general classifier family and data procedure are applied across locations.
The divergent results show that grammatical accessibility is sensitive to that location. A block-output representation can support improving prediction even when the sampled internal activity supports poorer prediction. This is an empirical contrast that a hidden-state-only analysis would miss.
However, it is not a removal experiment. The author does not disable the feed-forward component to see what changes, nor replace its activity while holding the remainder of computation fixed. The findings therefore do not establish whether a particular feed-forward layer is necessary for agreement or part-of-speech information.
The distinction matters for the proposed specialization interpretation. Different accessible subsets are a plausible hypothesis, but the probe comparison does not directly identify their content. A mechanism-level account would require evidence beyond the present measurements.
Candidate comparisons expose timing without explaining cause
The agreement display holds the completion position fixed and follows selected alternatives across layers. It shows where a projected preference becomes grammatical.
This offers a useful analysis of a single computation. It does not establish that the same trajectory appears across other agreement constructions or that the late preference results from a particular component.
Similarly, the country-list display illustrates how several candidates can change rank. Its value is to make a trajectory inspectable. No reported aggregate experiment links a particular ranking pattern to a general capability or failure type.
Factorization offers exploratory structure
The NMF interface compresses activity and reveals patterns that can be interpreted against the text. The pronoun observation is especially suggestive because the highlighted positions share a recognizable grammatical property.
The paper does not compare alternative factor counts quantitatively or test the interpretation on another passage. It also does not establish that the factors form independent linguistic categories. The analysis should therefore be understood as hypothesis generation.
The positional patterns are useful for another reason: they show that an intelligible factor need not concern lexical or grammatical meaning. Some visible regularities may follow where tokens occur. This broadens the set of explanations an investigator should consider before assigning a semantic label.
The learning-rate trials serve a different purpose. They identify a reported probe configuration among tested settings. They document an aspect of experimental tuning but do not explain which Ecco feature causes a measured improvement, because no such end-to-end improvement experiment is reported.
Limitations
Boundaries the author states explicitly
Architecture support differs by feature. Input attribution is described as available for GPT2-based systems. Activation collection and dimensionality reduction also support BERT and RoBERTa. Support for a system therefore does not imply support for every analysis discussed in the paper.
The author also states a methodological caution about visualization. Displays can help develop intuition, but stronger interpretive claims require hypotheses that can be tested and rejected. This limits the status of the most memorable examples.
A factor that seems grammatical is a promising observation. A ranking reversal is a sharply defined question. Neither is automatically an explanation of the underlying computation. The paper’s caution applies to its own demonstrations as well as to the wider practice of visual interpretation.
Additional architecture coverage and explanatory methods are presented as development work. Ecco should consequently be assessed as the described collection of supported operations, not as a complete inspection environment for every Transformer configuration.
Reporting gaps visible to a careful reader
The experimental section identifies English Universal Dependencies version 2 data but does not name a particular treebank. It explains the token count and split proportions without giving the full selection procedure. That leaves uncertainty about which source material was sampled.
The description also does not establish whether the split preserves sentence boundaries. Because tokens can share context, the distinction matters for reconstructing the experiment and assessing independence. This is a reporting limitation, not evidence that a particular inappropriate split was used.
The author reports several learning rates and identifies the chosen one. A separate validation procedure is not specified. A careful reader therefore cannot determine exactly how configuration selection relates to the reported test results.
The parenthetical variation values accompany averages across five trials, but the surrounding explanation does not define those values as a particular statistical interval. They should remain described as reported variation. Assigning them an unstated confidence-interval interpretation would add information the paper does not supply.
The empirical scope is limited
The quantitative task concerns grammatical categories in a selected English dataset. It does not establish corresponding findings for other languages, different grammatical properties, or different domains.
The distinction is especially important because the paper’s motivation is broad. Tools for examining language computation can support many questions, but the controlled evidence here answers a narrow one about linear recovery of part-of-speech labels.
The same caution applies across architectures. Demonstrating an interface on GPT2-based generation and a probing study on BERT does not establish that every observed pattern transfers between them. Shared terminology can conceal differences in execution path and diagnostic support.
The sampled feed-forward representation also has a precise scope. It is the widest post-GELU activation described in the method. Results from that location cannot automatically characterize every internal feed-forward quantity.
A probe does not establish causal use
A label can be predictable from a representation without functioning as an explicit variable in the original computation. The external classifier is trained to recover that label; the original language system was not shown using the same decision rule.
As a consequence, higher probe accuracy means stronger performance by that diagnostic under the stated conditions. It does not by itself identify a causal grammatical mechanism or prove that the representation is used in the way an investigator imagines.
A decline in accuracy is similarly limited. It can indicate reduced accessibility to the chosen classifier family without proving that the full system has lost the relevant capability. The divergence between internal feed-forward activity and hidden states makes this distinction particularly important.
Selectivity addresses the possibility that probe learning inflates apparent linguistic success. It does not transform the study into an intervention on the original computation. Its strength is a better-controlled interpretation of recoverability.
Attribution remains a particular measurement
Gradients X Inputs measures a selected score’s sensitivity in relation to embedding values. The final L2 operation yields a magnitude. That scalar does not retain a signed contribution in the form displayed.
A large attribution therefore should not be interpreted automatically as evidence that a token semantically supports the answer. It also does not establish that removing the token would change the output in a predicted way. Those would be different questions requiring different evidence.
The paper motivates its attribution choice in part through earlier classification research. It does not report a broad generation-focused evaluation establishing faithfulness across the examples and architectures that an investigator might later examine.
Normalization adds another interpretive boundary. A percentage in the detailed interface can improve comparison within a display, but it should not be mistaken for a probability that the corresponding explanation is true.
Attractive patterns can invite stronger claims than the evidence supports
The factor associated with pronouns is not tested as a detector over a separate collection. Its response might include other properties or omit some pronouns. The paper does not supply measurements that would settle those questions.
The factors associated with passage regions are interpreted through positional information. No reported manipulation removes or changes that information to isolate its role. A visible positional pattern is informative, but the causal interpretation remains less directly tested.
Intermediate vocabulary rankings also depend on the chosen readout. Applying an output head before the final layer makes the states easier to discuss, yet that convenience does not mean each layer makes an ordinary output decision.
These are limitations visible in the setup rather than additional restrictions explicitly enumerated by the author. They follow from what each diagnostic measures and from the absence of corresponding mechanism tests.
Tool usefulness is not quantified directly
The paper demonstrates interfaces and reports a representation study. It does not measure whether users discover correct explanations faster, whether explanations become more reliable, or whether debugging outcomes improve compared with another environment.
It also does not show that recording internal observations improves generation or tagging performance. Those are possible uses of an investigative system, but they are not results established here.
This does not diminish the practical importance of accessible inspection. It clarifies what evidence would be required for stronger usability or engineering claims. Ecco’s documented contribution is to make several established analyses easier to apply together and to demonstrate a controlled finding about internal grammatical accessibility.
What came after
The listed later publications that cite Ecco address text similarity, arithmetic evaluation, Transformer internals, neuron analysis, and sequence generation. Their titles identify these subjects, but the available descriptions do not specify which Ecco procedures they reused. The citation relationship supports discussing their place in the same research conversation; it does not justify inventing technical dependencies or later results.
Inseq, published in 2023, presents itself as an interpretability toolkit for sequence generation. That subject directly overlaps with Ecco’s attention to separate generated outputs. Ecco shows why sequence-level inspection needs a way to select the prediction under examination. The later citation establishes relevance to that continuing area of tool development, while leaving the exact relationship between attribution implementations and interface designs unspecified.
The 2022 survey of neuron-level interpretation addresses the scale of analysis emphasized by Ecco’s feed-forward investigation. Ecco contributes both activation access and an example of testing what internal activity makes predictable. Those are relevant subjects for neuron-focused interpretation. The available record does not establish how the survey categorizes Ecco or whether it independently assesses the grammatical findings.
The 2024 primer on Transformer internals has a broader explanatory focus. Ecco’s separate views of input attribution, hidden-state evolution, and neuron activity illustrate why such an account needs several observation levels. Its citation connects Ecco with that broader effort to understand internal computation. Specific conclusions or mechanisms attributed to the primer would require more information than its title and citation relationship provide.
The 2023 arithmetic evaluation study using number decomposition concerns a particular behavioral domain. Ecco’s birth-year demonstration makes a limited conceptual connection available: a written number can correspond to several prediction units, each open to separate inspection. That observation does not establish that the arithmetic study uses Ecco’s attribution calculation, studies the same segmentation issue, or obtains a particular result. Its stated subject and citation are the supported facts.
Similar, but why?, published in 2026, describes a toolkit for explaining text similarity. Its explanatory target differs from Ecco’s generation examples and internal grammatical probes. The shared concern is how an inspection interface can make a numerical or textual outcome easier to investigate. The available information does not establish that the later toolkit adopts Ecco’s representation-comparison methods or any specific visualization.
These citations show Ecco appearing in several subsequent interpretability contexts. The strongest supported account of its contribution remains grounded in its own work: convenient access to internal observations, interactive ways to relate those observations to text, and a controlled demonstration that grammatical prediction can follow different trajectories at different locations inside a Transformer.
Cite
Cite as J Alammar. 2021. Ecco: An Open Source Library for the Explainability of Transformer Language Models. Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing: System Demonstrations.
@inproceedings{j2021ecco,
title = {{Ecco: An Open Source Library for the Explainability of Transformer Language Models}},
author = {J Alammar},
booktitle = {Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing: System Demonstrations},
year = {2021},
doi = {10.18653/v1/2021.acl-demo.30},
url = {https://doi.org/10.18653/v1/2021.acl-demo.30}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/alammar-2021-ecco-open-source-library-explainability/