This study proposes a method to enhance the performance and stability of keystroke dynamics–based user authentication by combining the Transformer architecture (TypeFormer) with the Set-Margin Triplet Loss (SM-TL) and introducing a Temporal Soft Mas...
This study proposes a method to enhance the performance and stability of keystroke dynamics–based user authentication by combining the Transformer architecture (TypeFormer) with the Set-Margin Triplet Loss (SM-TL) and introducing a Temporal Soft Masking mechanism to handle variable-length input sequences in free-text environments. The model learns through two parallel branches—Temporal and Channel—on the same input, where the Temporal branch consistently applies soft masking to both the attention and LSTM layers to reduce the effect of padding regions. The loss function adopts SM-TL, which introduces a margin concept defined over class sets.
The evaluation was conducted on the Aalto Desktop (keyboard) dataset by varying the number of enrollment samples (E) and comparing the results with TypeNet (Triplet) and the original TypeFormer (Triplet) under identical protocols. An initial exploration of masking configurations showed that Temporal Soft Masking provided the most consistent performance and training stability compared to full-sequence masking or Channel-only masking. Subsequently, the loss function of TypeFormer was replaced from Triplet to SM-TL, and the margin parameter was tuned to determine the optimal configuration.
The optimal configuration was found at a margin value of m = 1.4, under which the proposed model achieved EERs of 4.41%, 2.87%, 2.14%, 2.06%, and 2.10% for E = 1, 2, 5, 7, and 10, respectively. Under the same conditions, TypeNet (Triplet) achieved 5.40%, 3.60%, 2.20%, 1.80%, and 1.60%, while the original TypeFormer (Triplet) exhibited substantially higher error rates in the keyboard environment. These comparisons confirmed that the proposed model performs particularly well in low-enrollment settings (E = 1, 2, 5). Furthermore, t-SNE visualizations revealed that, compared with Triplet Loss, the proposed approach forms a more distinct structure with stronger inter-class separation and intra-class cohesion.
The main contributions of this study are as follows:
1) It systematically demonstrates that Temporal Soft Masking provides tangible performance gains in free-text keyboard environments.
2) It quantitatively shows that the TypeFormer + SM-TL combination outperforms competing models when the number of enrollment samples is limited.
3) It identifies m = 1.4 as the optimal margin value, providing a reproducible reference for how loss-function design influences embedding structures and authentication performance.