## 3 Materials and Methods
### Saliency Visualization of Accident Attributes in Unstructured Free-Text Data  
Motivated by the desire to unravel the inner workings of GPT models and address their inherent black-box nature, the authors further developed a model to shed light on the transparent process of output generation. By systematically assessing the impact of individual words within an input sentence on the final output, this paper strives to enhance interpretability and provide users with a clearer understanding of the model's prediction accuracy. This is accomplished by strategically manipulating the location of words within a sentence, enabling the discernment of their unique contributions to the overall output. Each word is removed from its respective position, and the sentence is reassembled to obtain prediction accuracy. The Importance Score for a specific word in the sentence, denoted as \(w_{i}\), is computed as follows:  
\[\begin{array}{c}Importance\ Score_{i}=1-\frac{P(S-\{w_{i}\})}{P(S)}\\ =1-P(w_{i}^{c}|S)\\ where,\quad S=\{w_{1},\ w_{2},\ w_{3},\ \cdots,\ w_{n}\}\end{array} \tag{1}\]  
* \(S\) represents the set of all word elements contained in the sentence.
* \(w\) represents an individual word in the set \(S\), with the subscript indicating the positional information of that word.  
In this equation, \(P(S-\{w_{i}\})\) represents the probability of an accident that can occur within the sentence \(S\) occurring when the researchers remove or exclude the element, a word, \(w_{i}\) from it. \(P(S)\) represents the probability of an accident that can occur within the sentence \(S\) happening in its entirety. The \(Importance\ Score_{i}\) essentially quantifies the significance or importance of the element \(w_{i}\) within the context of event \(S\). It is calculated as the difference between 1 and the product of two probabilities: one representing the occurrence of \(S\) with the element \(w_{i}\) removed and the other representing the overall probability of \(S\). Ultimately, it can be summarized as \(1-P(w_{i}^{c}|S)\) by the properties of the set difference and conditional probability. If log probability is used, then the values should be normalized to a range between 0 and 1 using exponential transformation:  
\[Importance\ Score_{i}=1-e^{P(S-\{w_{i}\})-P(S)} \tag{2}\]  
Algorithm 1 illustrates the pseudocode to operate saliency visualization. This methodology allows for a quantitative comparison of the impact of each word on the final output, providing insights into the black-box behavior of the GPT model. Using this methodology, the researchers can obtain a set of Importance Scores for all the words that make up a sentence. Below is the detailed description of Algorithm 1:The algorithm commences by performing tokenization on the input sentence, \(Sent\), resulting in the generation of a list of words, denoted as \(S\). It subsequently initializes score variables \(Score_{1}\) through \(Score_{n}\) for each word in the sentence. The algorithm then proceeds to iterate through each word, eliminating the \(i\)-th word \(w_{i}\) from \(S\), thereby creating modified sentences \(S_{i}\). The scores \(Score_{i}\) for each modified sentence \(S_{i}\) are calculated using the formula:  
\[Score_{i}=1-\frac{P(S_{i})}{P(Sent_{i})},\]  
where \(P(S_{i})\) represents the probability of the modified sentence, and \(P(Sent)\) represents the probability of the original sentence. Finally, the resulting scores \(Score_{1}\) through \(Score_{n}\) are stored in the \(Scores\) list for subsequent analysis and interpretation.  
This algorithm provides a systematic approach to assess the impact of individual words within a given sentence. It calculates a score for each word by considering the change in sentence probability when that word is removed. These scores can be valuable for various NLP tasks, such as keyword extraction, text summarization, and sentiment analysis.