# SQL Injection Detection Based on Lightweight Multi-Head Self-Attention
## 4 Experimental Results
### Numerical Evaluations
In addition, it has comparable precision rate, recall rate, F1 score and accuracy values to those of ALBERT [24], DistilBERT [25], and ELECTRA [27]. The proposed model also has superior precision rate, recall rate, and accuracy values over those of Multi-Model [22]. We can conclude from the results that the proposed model is able to provide accurate SQL injection detection even with a small set of weights. A special type of attacks in the test set \(\mathcal{U}\) was also considered in this study, where the length of each query in \(\mathcal{U}\) exceeded 1000 characters. Note that the training set \(\mathcal{T}\) consists of only the SQL queries with short lengths. Therefore, the evaluations of the models on the test set \(\mathcal{U}\) reveal the robustness of the models on the individual attacks with long \begin{table}
\begin{tabular}{l c c c c c} \hline \hline
**Model** & **Accuracy** & **Precision** & **Recall** & **F1 Score** & **Weight Size** \\ \hline Proposed Model & 98.98\% & 98.01\% & 99.84\% & 98.92\% & 69,269 \\ \hline Multi-Model [22] & 97.88\% & 97.17\% & 98.35\% & 97.76\% & 77,008 \\ \hline ALBERT [24] & 99.16\% & 98.31\% & 99.92\% & 99.11\% & 11,685,122 \\ \hline DistilBERT [25] & 99.60\% & 99.25\% & 99.90\% & 99.57\% & 66,955,010 \\ \hline ELECTRA [27] & 99.33\% & 98.72\% & 99.88\% & 99.30\% & 13,549,314 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Performance of various models for SQL injection detection for the test set \(\mathcal{S}\). There are 24,707 queries in the test set. The length of each query is below 1000 characters. \begin{table}
\begin{tabular}{l c c c c c} \hline \hline
**Model** & **Accuracy** & **Precision** & **Recall** & **F1 Score** & **Weight Size** \\ \hline Proposed Model (SQL-specific Tokenizer+ & & & & \\ Proposed Detection Model) & 98.98\% & 98.01\% & 99.84\% & 98.92\% & 69,269 \\ \hline SentencePiece Tokenizer [31]+ & & & & \\ Proposed Detection Model & 99.15\% & 98.36\% & 99.86\% & 99.10\% & 749,537 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Performance of the proposed model with different tokenizers for the test set \(\mathcal{S}\). There are 24,707 queries in the test set. The length of each query is below 1000 characters. lengths. Table 5 reveals the corresponding results. We can see from the table that the proposed model and models in [24; 25; 27] were able to maintain high accuracy, precision rate, recall rate and F1 score values for the test set \(\mathcal{U}\). Compared to the models in [24; 25; 27], the proposed model is still advantageous because it requires a significantly lower memory size for storing weights. Although the proposed model and the model in [22] have similar weight sizes, the proposed model has higher accuracy, precision rate, recall rate and F1 score values. The proposed model has the superior performance because its self-attention operations are based on the skeleton queries after removing noisy information. That is, the proposed model is able to abstract only the useful information for subsequent detection. It could then be a cost-effective solution for the SQL injection detection applications. To further elaborate the effectiveness of the proposed model, Table 6 shows the average inference time of different models on various edge devices over the test set \(\mathcal{S}\). In the experiments, the average inference time was measured as the average CPU time required to produce detection result per SQL query in the test set \(\mathcal{S}\). The table also includes the standard deviation for each model in each edge device. There were two edge devices considered in the experiments: Up Board and PC. The Up Board uses an Intel Atom X5 Z8350 CPU and 4 GB of main memory. In the PC, the CPU is an Intel Core I9 9900K, and size of its main memory is 64 GB. The PC is also equipped with an NVIDIA GPU RX 3080 Ti. We can see from Table 6 that the average inference time of the proposed model is lower than existing models for each edge device. The proposed model has lower computation complexities for inference because of its small weight size.