\section{Introduction}
Neural approaches
have made significant progress in recent years, with Transformer models \citep{vaswani2017attention}  rapidly becoming the dominant architecture in NLP, due to their efficient parallel training and their ability to effectively capture features of long sequences. 
Following the release of BERT \citep{devlin-etal-2019-bert} along with other Transformer models pretrained on large corpora \citep{liu2019roberta, lewis-etal-2020-bart, joshi-etal-2020-spanbert, lee2020biobert}, the most successful strategy on many
NLP leaderboards is currently to fine-tune such pretrained models to the particular target NLP  task (e.g., summarization, text classification).
However, despite the strong empirical performance of this
strategy, understanding and interpreting the training and fine-tuning processes remains a critical and challenging step for model developers and researchers \citep{kovaleva-etal-2019-revealing, hao-etal-2019-visualizing, merchant-etal-2020-happens, hao-etal-2020-investigating}. 

Generally speaking, a large number of visual analytics tools have been shown to effectively support the analysis and interpretation of deep learning models
\citep{hohman2018visual}. For instance, to remedy the black-box nature of neural network hidden states, previous work has used scatterplots to visualize high dimensional vectors in  projection views \citep{smilkov2016embedding, kahng2017cti}, with \citet{aken2020visbert} visualizing 
the differences of token representations from different layers of BERT \citep{devlin-etal-2019-bert}.
Similarly, despite some limitations
regarding the explanatory capabilities of the attention mechanism
\citep{jain-wallace-2019-attention, wiegreffe-pinter-2019-attention}, its visualization has also been shown to be beneficial, with promising recent work focusing on Transformers \citep{vig-2019-multiscale, hoover-etal-2020-exbert}.


Besides the works on exploring what has been learnt in the pretrained models, there are also several visualization tools developed
to show saliency scores generated by gradient-based \citep{simonyan2013deep, bach2015pixel, shrikumar2017learning} and perturbation-based methods \citep{ribeiro16, li2016understanding},
which can  help with interpreting the relative importance of individual tokens in the input with respect to a target prediction \citep{wallace-etal-2019-allennlp, johnson2020njm, tenney-etal-2020-language}.

However,
only a few studies have instead focused on visualizing the overall training dynamics, where  support is critical for identifying mislabeled or failure cases \citep{liu2018deeptracker, xiang2019interactive, swayamdipta-etal-2020-dataset}










In essence, the T\textsuperscript{3}-Vis framework we propose in this paper synergistically integrates  some of the interactive visualizations mentioned above to support developers in the challenging task of training and fine-tuning Transformers. 
This is in contrast with other similar recent visual tools (\autoref{table:recent-comparison}), which either only focus on single data point explanations for uncovering model bias and finding decision boundaries (e.g., AllenNLP Interpret \citep{wallace-etal-2019-allennlp}), or only focus on analyzing failed examples and understanding model's behaviour (e.g., Language Interpretability Tool (LIT) \citep{tenney-etal-2020-language}).

\begin{table*}[ht!]
\begin{center}
\resizebox{\linewidth}{!}{
\begin{tabular}{ |c|c|c|c|c|c|c|c|c| } 
    \hline
    \multirow{2}{*}{\large{Frameworks}} & \multicolumn{5}{c|}{Components} & \multicolumn{3}{c|}{Functions} \\
    \cline{2-9}
    & Dataset & Embeddings & \begin{tabular}{@{}c@{}}Head \\ Importance\end{tabular} & Attention & \begin{tabular}{@{}c@{}}Training \\ Dynamics\end{tabular} & Interpretations & Pruning & Comparison \\
    \hline
    BertViz \cite{vig-2019-multiscale} & & & & \checkmark & & & & \\
    \hline
    \begin{tabular}{@{}c@{}}AllenNLP Interpret \\ \cite{wallace-etal-2019-allennlp}\end{tabular}  & & & & & & \checkmark & & \\
    \hline
    exBERT \cite{hoover-etal-2020-exbert} & \checkmark & \checkmark & & \checkmark & & & & \\
    \hline
   
   
    LIT \cite{tenney-etal-2020-language}  & \checkmark & \checkmark & & \checkmark & & \checkmark & & \checkmark \\
    \hline
    InterperT \citep{lal-etal-2021-interpret} & \checkmark & \checkmark & \checkmark & \checkmark & &  & & \\
    \hline
    \textbf{T\textsuperscript{3}-Vis} & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark \\
    \hline
\end{tabular}
}
\end{center}
\caption{Comparison with other visual frameworks from recent work.}
\label{table:recent-comparison}
\end{table*}









Following
the well-established Nested Model for visualization design \citep{munzner2009nested}, we first
perform an extensive requirement analysis, from which 
we derive user tasks and data abstractions
to guide the design of visual encoding and interaction techniques. More specifically, the resulting T\textsuperscript{3}-Vis framework provides an intuitive overview that allows users to explore different facets of the model (e.g., hidden states, attention, training dynamics) through interactive visualization, along with a suite of built-in algorithms that compute the importance of model components and different parts of the input sequence.

Our contributions are as follows: 
\textbf{(1)} An extensive user requirement analysis on supporting the training and fine-tuning of Transformer models, based on extensive literature review and interviews with NLP researchers,  
\textbf{(2)} the design and implementation of an open-sourced visual analytic framework for assisting researchers in the fine-tuning process
with a suite of built-in interpretation methods for understanding model behaviour, and 
\textbf{(3)} the first steps of an iterative design based on case studies and feedback from a user focus group.

\section{Visualization Design}
The design of our T\textsuperscript{3}-Vis is based on the
nested model for InfoVis design
\citep{munzner2009nested}. 

\subsection{User Requirements}
\label{ssec:user_requirements}
To derive useful analytical user tasks,
we first identify a set of high-level user requirements through interviews with five NLP researchers as well as surveying recent literature related to the interpretability of pretrained Transformers. In the interviews, we prompt participants with the open-ended question of "\emph{If a visualization tool is provided to speed up your development (using fine-tuning pretrained Transformers), what information would you like to see and explore?}". 
Combining the interview results and insights from the literature review,
we organize these findings into five high-level requirements, each highlighting a different facet of the model for visualization.

\textbf{Hidden state visualization (UR-1)}: Support the exploration for hidden state representations from the pretrained model
to assist users in the training process.

\textbf{Attention visualization (UR-2)}:
Allow users
to examine and explore the linguistic or positional patterns exhibited in the self-attention distribution for different attention heads in the model.

\textbf{Attention head importance(UR-3)}:
Enable users to investigate and understand the importance of the attention heads for the downstream task and the effects of pruning them on the model's behaviour.


\textbf{Interpretability of models (UR-4)}:  In addition to attention maps,
support a suite of alternative explanation methods based on token input importance, thus allowing users to better understand the model behaviours
during inference.

\textbf{Training dynamics (UR-5)}: 
Assist users in identifying relevant data examples based on their roles in the training process. 

\begin{table*}[ht!]
\begin{center}
\resizebox{\linewidth}{!}{
\begin{tabular}
{ |c|c|c|c|c|c|c| } 
 \hline
 \textbf{\#} & \textbf{Question} & \textbf{When} & \textbf{Granularity} & \textbf{UR} & \textbf{Components} \\
 \hline
 T1 & \shortstack{How to determine the model \\ representation for a given NLP task?} & Before & Dataset & UR-1 & Projection \\
 \hline
 T2 & \shortstack{What are the outliers of the dataset?} & Before, During, After & Dataset & UR-1, UR-5 & Projection\\ 
 \hline
 T3 & \shortstack{What types of linguistic or positional attributes do \\ the attention patterns exhibit for each attention heads?}   \ & Before, During, After & Instance & UR-2 & Projection\\
 \hline
 T4 & \shortstack{Which attention heads are considered important \\ for the task, and what are its functions
 } & After & Both & UR-2, UR-3 & \shortstack{Attention Head \\ Instance Investigator}\\ 
 \hline
 T5 & \shortstack{How does pruning attention heads affects the model?}  & After & Instance & UR-3 & Attention Head \\ 
 \hline
 T6 & \shortstack{How does the model changes at \\ different stages of fine-tuning?} & During, After & Both & UR-1, UR-2, UR-3 & All\\ 
 \hline
 T7 & \shortstack{Does the model rely on specific parts of the \\ input sequence when making predictions? } & After & Instance & UR-4 & Instance Investigator\\ 
 \hline
 T8 & \shortstack{Are there mislabeled examples in the dataset?} & During, After & Both & UR-1, UR-5 & Projection\\ 
 \hline
 T9 & \shortstack{How can the dataset be augmented to improve \\the performance and robustness of the model?}& During, After & Both & UR-5 & Projection \\ 
 \hline
\end{tabular}}
\end{center}
\caption{Supported analytical tasks: questions that our interface helps to answer.}
\label{table:task-abstractions}
\end{table*}









\subsection{Supported Tasks and Data Model}

Based on these user requirements, we derive nine analytical tasks framed as information seeking questions (\autoref{table:task-abstractions}).
The questions are categorized based on their \textit{Granularity} (dataset vs. instance-level) and \textit{When} they are relevant during the fine-tuning process.
If we then look at the specific data the tasks are applied to, we characterize our data model as comprising the model hidden states, the dataset examples along with their label/training features, the attention values, head importance scores, and input saliency map.
Although our task and data models are derived for the fine-tuning of pretrained models, they can naturally be extended to training any 
Transformer models from scratch.
Importantly, all the questions are invariant to any Transformer-based models 
for any downstream tasks (e.g. classification, sequence-generation or labeling)

\begin{comment}
\begin{itemize}
    \item \textbf{T1}: For any given task, the naive approach involves training the models to convergence and compare their performance using an established metric. In an effort to reduce the computational cost for training, the user can rely on the hidden states of the data examples to select a favorable representation for the task. For example, the hidden states of a specific layer of the model might might be considered a good representation for a classification task when intra-class examples are closely clustered and inter-class examples are well separated. 
    \item \textbf{T2}: Outliers can be defined as examples that are significant different from others in the dataset. Users need to identify such instances in order to determine whether they should be kept (improve robustness) or removed (mislabeled). They can either be classified based on input representation (i.e. distance between hidden states) or training dynamics (e.g. high variance during training).
    \item \textbf{T3, T4, T5}: While quantitative evaluations can measure the accuracy of how well different attention heads are associated with certain linguistic or positional patterns, it is often easier to determine the type of pattern by directly visualizing the attention weights. For example, certain attention heads correspond well to linguistic notions of syntax and co-reference, while others attend solely to preceding/seceding tokens of the input sequence. Additionally, the user might be interested in determining whether the patterns encoded in the attention heads are actually being used by the model during inference through its importance score, as well as the model's behaviour when certain attention heads are pruned.
    \item \textbf{T6}: The user may be interested in how the parameters of the pretrained model have been augmented during the course of fine-tuning to assess the relative importance of different model components and the need for hyperparameter adjustments during fine-tuning. While the change in the model's input representation can be visualized from the changes in hidden states. Changes for model's different parameter groups can be inferred from the comparison of model components from different checkpoints. For example, the change in attention patterns for different heads.
    \item \textbf{T7}: The instance-level explanation helps to understand which parts of an input led to the prediction. The user might be interested in finding out whether the model is taking advantage of the positional bias on a dataset-level or relying on spurious clue or annotation artifacts when predicting on certain instances (e.g. outliers).
    \item \textbf{T8, T9}: During the fine-tuning process, the user may be interested in selecting data instances based on their roles in the training dynamics. For examples, a proportion of the outliers discovered during training might be due to mistakes in annotations, while easy-to-learn instances can be augmented by the user to improve generalizability. 
\end{itemize}
\end{comment}

\begin{comment}
\begin{table*}[ht!]
\begin{center}
\begin{tabular}{ |c|c|c|c|c| } 
 \hline
 \textbf{Derived from} & \textbf{Data variable} & \textbf{Abstract type} & \textbf{Addition transformation} & \textbf{Scale} \\
 \hline
 Dataset & Input & Categorical & Map to text & $\bar{n} \times |D|$ \\
 \hline
 \multirow{3}{*}{Model} & Hidden State & Quantitative & Dimension Reduction & $2 \times |D|$ \\
                        \cline{2-5}
                        & Attention Map & Quantitative & None & $N \times h \times \bar{n}^2 \times |D|$\\
                        \cline{2-5}
                        & Output & Quantitative & Task dependent & $\bar{m} \times |D|$\\
 \hline 
 \multirow{2}{*}{\shortstack{Additional \\ algorithm}} & Saliency Map & Quantitative & None & $\bar{n}^2 \times |D|$ \\
                        \cline{2-5}
                        & Head Importance Score & Quantitative & Normalize & $N \times h \times |D|$ \\
 \hline
\end{tabular}
\end{center}
\caption{Data Abstractions (maybe changed during implementation to save space)}
\label{table:data-abstractions}
\end{table*}



From the data variables (e.g. hidden states, attention map, etc.) identified earlier, we list them based on how they are derived (\autoref{table:data-abstractions}). For the scale of these variables, we define them in terms of dataset size $|D|$, average length of the documents $\bar{n}$ and model output $\bar{m}$, as well as model hyperparameters $N$ and $h$, where $N$ is the number of layers and $h$ is the number of attention heads per layer. 
\end{comment}



\begin{comment}
\subsection{Design Principles}
\label{ssec:principles}
The design of T\textsuperscript{3}-Vis is based on the following principles, each enabling one or more tasks.



   \textbf{Exploration across granularities}:
   Since the task model deals with data types at different granularities (dataset and instance level), T\textsuperscript{3}-Vis facilitates the interaction to switch between views operating with data at the two scales. Additionally, the comparison between the instance and dataset level views offers users insights
   on the variance within the dataset, as well as how much each instance deviates from the average (\textbf{T2}). Importantly, viewing the same components at different scales can reveal complementary insights.
   For example, visualizing  attention weights aggregated at the dataset level can more effectively inform the user about the redundancy in attention heads' functions (\textbf{T4}), while instance level visualization can reveal the specific linguistic pattern
   learned by the attention head (\textbf{T3}). 
   
   \textbf{Faceted overview}: To facilitate the transition between different granularities, the overview should provide a multi-faceted summary with the relevant task-specific knowledge for the user to determine which instances to drill-down. In particular, the answer to \textbf{T2} (outliers) may require task specific metadata (e.g., document length) to determine how a specific instance fares within the dataset. 
   
   \textbf{Preserving global context}: To determine an instance's relevancy within the dataset, it is essential to preserve the global context when a specific document is selected for drill-down. Simultaneously visualizing the instance-level elements along with the global context can reduce the view-change costs associated with the interactively switching between different views. For example, to answer \textbf{T5}, the user needs to know how the head importance score of individual instances differs from the global importance score of the dataset.
  
  \textbf{Dynamic interactions with the model}:
   Instead of visualizing abstract data types as static files, dynamic interactions with the model provides the user with the ability to observe the changes when different facets of the model are modified. For example, a user answering \textbf{T5} may want to prune certain attention heads to see how the updated model performs. Alternatively, to answer \textbf{T6} and \textbf{T7}, certain input tokens could be removed to better understand the model's behaviour.
  
  
  

\end{comment}

\subsection{T\textsuperscript{3}-Vis Components: Visual Encoding and Interactive Techniques}
\label{ssec:components}
 


\textbf{Projection View}
To assist users in visualizing the model's hidden state representation (\textbf{UR-1}) and to identify the training role of the data examples (\textbf{UR-5}), we design the Projection View (Figure \ref{fig:teaser}-(A)) as the main overview of our interface, and visualize the entire (or a subset of the) dataset on a 2D scatterplot, where each data point on the plot encodes a single data example (e.g. document) in the dataset. While the scatterplots can be generated in a variety of ways based on the user's needs, we provide two implementations (See Figure \ref{fig:projection-view}): (1) t-SNE projection \citep{van2008visualizing} of the model's hidden states, and (2) plotting the examples by their confidence and variability across epochs based on the Data Map technique \citep{swayamdipta-etal-2020-dataset}. The color of the data points can be selected by the user via a dropdown menu to encode attributes of the data examples, where color saturation is used for continuous attributes (e.g. loss, prediction confidence), while hue is used for categorical attributes (e.g. labels, prediction). The user can also filter the data points by
attributes, where a range slider is used for filtering the data points by continuous attributes, while a selectable dropdown menu is used to filter by categorical attributes. 
Furthermore, we also introduce a comparison mode by displaying the two scatterplots side-by-side, which allows for the flexibility of comparing across different checkpoints and the projection of different hidden state layers.

\begin{figure}
    \centering
    \includegraphics[width=\linewidth]{figures/projection-view-V2.png}
    \caption{Interactive scatterplots based on the data examples' training dynamics (left), and the t-SNE projections of hidden states (right)}
    \label{fig:projection-view}

\end{figure}

\textbf{Data Table}
The Data Table (Figure \ref{fig:teaser}-(B)) lists all examples of the dataset in a single scrollable list, where each row of the table shows the input text of a data example along with its ground truth label. When the user filters the dataset in the Projection View, the Data Table is also updated simultaneously, where only examples that satisfy the filtered criteria are kept.   

\textbf{Attention Head View}
In order to visualize the importance of the models' attention heads (\textbf{UR-4}), as well as the patterns encoded in the attention weight matrices (\textbf{UR-3}), we design the Attention Head View (Figure \ref{fig:teaser}-(C)) with an $l \times h$ matrix ($l$ layers and $h$ heads), where each block in the matrix represents a single attention head at the respective index for layer and head. In this view, we provide two separate visualization techniques: namely (1) Head Importance (\autoref{fig:attention-importance}) and (2) Attention Pattern (\autoref{fig:attention-weights}), that can be switched using a toggle button. The Head Importance technique visualizes the normalized task-specific head importance score \footnote{Details are in \ref{sec:head-importance} of the Appendix}, where score of each head is encoded with the background color saturation of each block with the value also displayed in the middle. On the other hand, the Attention Pattern technique uses a heatmap to visualize the self-attention pattern of each head where the color saturation encodes magnitude of the associated weight matrices. We also provide a toggle button for the user to visualize the importance score and attention patterns on two scales, where the \textbf{aggregate}-scale visualizes the score and patterns averaged over the entire dataset, while the \textbf{instance}-scale visualizes the score and patterns for a selected data example. Lastly, we also offer an interactive technique for the user to dynamically prune attention heads and visualize the effects on a selected example. By hovering over each attention head block in the view, the user can click on the close icon to prune the respective attention head from the model.

\begin{figure}[!tbp]
  \begin{subfigure}[b]{0.49\linewidth}
    \includegraphics[width=\linewidth]{figures/attention-importance.png}
    \caption{Head Importance}
    \label{fig:attention-importance}
  \end{subfigure}
  \hfill
  \begin{subfigure}[b]{0.49\linewidth}
    \includegraphics[width=\linewidth]{figures/attention-weights.png}
    \caption{Attention Pattern}
    \label{fig:attention-weights}
  \end{subfigure}
  \caption{The two visualization techniques in the Attention Head View.}
  \label{fig:attention-head-view}
  \vspace{-2mm}
\end{figure}


\textbf{Instance Investigation View}
After the user selects a data example from the Projection View or Data Table, the Instance Investigation View (Figure \ref{fig:teaser}-(D)) renders the corresponding input text sequence along with the model predictions and labels to allow the user to perform detailed analysis on the data example. Our interface provides two analysis techniques: (1) self-attention weights (\textbf{UR-3}), and (2) input interpretation methods (\textbf{UR-4}). In this view, each token of the input sequence is displayed in a separate text block, where the background color saturation of each text block encodes the relative saliency or importance of the token based on the interpretation methods. 
By selecting a head in the Attention Head View (\autoref{fig:attention-head-view}), the user can click on the text block of any input token to visualize the self-attention distribution of the selected token over the input text sequence (what the selected token attends to). Similarly, the user can visualize the input saliency map
with respect to a model output, by clicking the corresponding output token. Our interface provides the implementation of two input interpretation methods\footnote{Details are in \ref{sec:input-interpretation} of the Appendix}
: (1) Layer-wise relevance propagation \citep{bach2015pixel}, and (2) input gradient \citep{simonyan2013deep}.








\subsection{Implementation}





\paragraph{Data Processing}
For each model checkpoint, data pertaining to dataset-level visualizations including hidden state projections, prediction confidence/variability, head importance score, and other attributes (e.g. loss, prediction) are first processed and saved in a back-end directory. The only added computational overhead to the user's training process is the dimension reduction algorithm for projecting hidden state representation, as other visualized values can all be extracted from the forward (e.g. confidence, variability, loss) and backward pass (e.g. head importance, input saliency) of model training.

\paragraph{Back-end}
Our back-end Python server provides built-in support for the PyTorch HuggingFace library \citep{wolf-etal-2020-transformers}, including methods for extracting attention values, head pruning, computing importance scores, and interpreting the model predictions. In order to avoid saving instance-level data (e.g., attention weights, input heatmap, etc.) for all examples in the dataset, our python server dynamically computes these values for a selected data example by performing a single forward and backward pass on the model. This requires the server to keep track of the model's current state, as well as a dataloader for indexing the selected data example. 

\paragraph{Front-end}
Our front-end implementation keeps track of the current visual state of the interface including the selections, filters, and checkpoint. The interface can be accessed through any web browser, where data is retrieved from the back-end server via RESTful API. The interactive visual components of the interface are implemented using the D3.js \citep{bostock2011d3}, and other UI components (e.g. buttons, sliders) are implemented with popular front-end libraries (e.g. jQuery, Bootstrap).  

\section{Iterative Design}
\subsection{Focus Group Study}
In order to collect suggestions and initial feedback on T\textsuperscript{3}-Vis, we conducted a focus group study with $20$ NLP researchers that work regularly with pretrained Transformer models. In this study, we first presented the design of the interface, then gave a demo showing its usage on an example, and throughout the process we gathered responses from the participants. 

Most positive feedback focused on the effectiveness of our techniques for visualizing self-attention especially on longer documents (in contrast to showing links between tokens \citep{vig-2019-multiscale}). There were also comments on the usefulness of the input saliency map in providing insightful clues on the model's decision process.

Some participants also suggested that the interface would be more useful for classification problems with well-defined evaluation metrics since data examples tended to be better clustered in the Projection View so that they could be easily filtered for error analysis.
The need of optimizing the front-end to support the visualization of large-scale datasets was also mentioned.

On the negative side, some participants were concerned by the information loss intrinsic in the dimension reduction methods, whose possible negative effects on the user analysis tasks definitely requires further study. Encouragingly, at the end, a few participants expressed interest in applying and evaluating T\textsuperscript{3}-Vis on their datasets and NLP tasks.



\subsection
Case Studies}
This section describes two case studies of how T\textsuperscript{3}-Vis facilitates the understanding and exploration of the fine-tuning process through applications with real-world corpora. These studies provide initial evidence on the effectiveness of different visualization components, and serve as examples for how our framework can be used in applications.

\subsubsection{Pattern Exploration for an Extractive Summarizer}

NLP researchers in our group, who work on summarization,  applied T\textsuperscript{3}-Vis to the extractive summarization task, which aims to compress a document by selecting its most informative sentences.
BERTSum, which is fine-tuned from a BERT model\cite{liu-lapata-2019-text}, is one of the top-performing models for extractive summarization,  but why and how it works remains a mystery. With our interface, the researchers explored patterns captured by the model that played important roles in model predictions. They performed an analysis on the CNN/Daily Mail dataset \cite{cnndm}, which is arguably the most popular benchmark for summarization tasks. 

The first step was to find the important heads among all the heads across all the layers. From the Head Importance View (Figure \ref{fig:teaser}-(C)), the researchers selected the attention heads with high head importance scores, so that the corresponding attention distribution was available to interact with. Then they selected some tokens in the Attention View to see which tokens they mostly attended to, and repeated this process for multiple other data examples, in order to explore whether there was a general pattern across different data examples.

While examining attention heads based on their importance in descending order, the researchers observed that tokens tended to have high attention on other tokens of the same word on the important attention heads. For example, the token ``victim" attributed almost all of its attention score to other instances of the token ``victim" in the source document. They further found two more patterns in other important heads, in which the tokens tended to have more attention on the tokens within the same sentence, as well as the adjacent tokens.
These behaviours were consistent across different pretrained models (e.g. RoBERTaSum). 

These findings provided useful insights to assist the researchers in designing more efficient and accurate summarization models in the future, and served as a motivation for the researchers to perform similar analysis for other NLP tasks.






\subsubsection{Error Analysis for Topic Classification}
Other researchers in our group explored the interface for error analysis to identify possible improvements of a BERT-based model for topic classification. The Yahoo Answers dataset \citep{zhang2015character} was used, which contains 10 topic classes.

Researchers first used the Projection View (Figure \ref{fig:teaser}-(A)) to find misclassified data examples as applying filters to select label and prediction classes. For a selected topic class in the t-SNE projection of the model's hidden states, they found out that the misclassified data points far away from clusters of correctly predicted examples were often mislabeled during annotation. Therefore, misclassfied data points within such clusters were of greater interest to them since such points tends to indicate model failures (instead of mistakes in annotation). 
Furthermore, data points in the area with low variability and low confidence on the Data Map plot were also selected for investigation since they are interpreted as consistently misclassified across epochs. After selecting the examples, the researchers inspected each instance by using the Instance Investigation View (Figure \ref{fig:teaser}-(D)) with the Input Gradient method to visualize the input saliency map for the prediction of each class. 


From this analysis, they discovered two scenarios that led to misclassification. First, the model focused on unimportant and possibly misleading details that are not representative of the document's overall topic. For instance, a document about \textit{Business \& Finance} was classified into the \textit{Sport} category because the model attended to ``hockey player'', ``football player'', and ``baseball player'', which were listed as job titles while discussing available jobs in Michigan. Second, the model failed in cases where background knowledge is required. For example, a document under the \textit{Entertainment \& Music} category mentioned names of two actors which were key clues for the topic, but the model only attended to other words, and made a wrong prediction. 
 

These findings helped researchers to gain insights for future model design where additional information such as discourse structure (which can better reveal importance) and encyclopedic knowledge could be injected into the model's architecture to improve the task performance.

















 








 

 


 


\section{Conclusion}
In this paper, we presented T\textsuperscript{3}-Vis, a visual analytic framework designed to help researchers better understand training and fine-tuning processes of  Transformer-based models. Our visual interface provides faceted visualization of a Transformer model and allows exploring data across multiple granularities, while enabling users to dynamically interact with the model. 
Our focus group and case studies demonstrated the effectiveness of our interface by assisting the researchers in interpreting the models' behaviour and identifying potential directions to improve task performances. 

For future work, we will continue to improve our framework through the iterative process of exploring further usage scenarios and collecting feedback from users. We will extend our framework to provide a more advanced visualization for custom Transformers. For example, we may want to support the visualization of models with more complex connections (e.g. parallel attention layers) or an advanced attention mechanism (e.g. sparse attention). 



\clearpage

