TypeFormer: Transformers for Mobile Keystroke Biometrics

Giuseppe Stragapede, Paula Delgado-Santos, Ruben Tolosana, Ruben Vera-Rodriguez, Richard Guest, Aythami MoralesarXiv 2022

TL;DR

TypeFormer is a novel Transformer-based architecture designed for continuous, passive user authentication on mobile devices using free-text keystroke dynamics. By leveraging a specialized two-branch structure and hybrid attention-recurrent layers, it achieves a state-of-the-art Equal Error Rate (EER) of 3.25%, significantly outperforming previous RNN-based models and narrowing the performance gap between mobile and desktop biometric systems.

What Problem Does This Paper Address?

As mobile devices become central to our lives, securing the sensitive data they hold is paramount. Traditional authentication methods like PINs or fingerprints are often "one-time" entry points and can be obtrusive. Behavioral biometrics, specifically keystroke dynamics, offer a way to verify identity continuously and transparently as a user types.

However, mobile "free-text" scenarios—where a user types anything they want—are incredibly challenging. Unlike "fixed-text" (like typing a specific password), free-text data is unstructured, noisy, and highly variable. Factors like typing with one vs. two hands, walking while typing, or even emotional state can drastically change a user's keystroke patterns. The authors aim to overcome these hurdles with a deep learning architecture that can extract robust, identity-revealing features from these complex signals.

Methods

The core of the paper is the TypeFormer architecture, which departs from standard Transformers in several key ways:

  • Two-Branch Architecture: The model consists of a Temporal Module to extract time-based features and a Channel Module that processes transposed data to capture inter-feature relationships.
  • Hybrid Layers: Instead of pure self-attention, TypeFormer integrates Multi-scale Keystroke LSTM layers within its Transformer blocks. This helps the model capture local temporal dependencies that standard attention mechanisms might miss.
  • Gaussian Range Encoding (GRE): Standard Transformers use Positional Encoding to understand sequence order. TypeFormer replaces this with GRE, which uses probability density functions to better preserve position information in keystroke sequences.
  • Block-Recurrent Structure: It incorporates recurrent connections between Transformer layers to retain temporal information across longer sequences more effectively.
  • Triplet Loss Training: The model is trained to map keystroke sequences into an embedding space where sequences from the same person are close together (low intra-subject variability) and sequences from different people are far apart (high inter-subject variability).
Fig. 2. Graphical representation of TypeFormer, based on a Transformer architecture for biometrics keystroke free-text verification. T: Transposition operation; GRE: Gaussian Range Encoding; N, R, M, H: Number of layers of each of the modules; X: Pre-processed input sequence; P: Output feature embedding vector.

The input features for each keypress include hold latency, inter-key latency, press latency, release latency, and the ASCII code of the key.

Fig. 3. Example of the keystroke features extracted from the Aalto mobile keystroke database [12]. HL: Hold Latency; IL: Inter-key Latency; PL: Press Latency; RL: Release Latency; ASCII: Key Pressed.

Datasets

The researchers evaluated TypeFormer across several major benchmarks:

  • Aalto Mobile Keystroke Database: The primary dataset, featuring data from over 60,000 subjects typing freely on mobile devices.
  • Aalto Desktop Keystroke Database: Used for cross-database evaluation to test how well a mobile-trained model generalizes to mechanical keyboards.
  • Clarkson II Database: A long-term, completely unsupervised free-text desktop dataset.
  • Buffalo Database: A desktop dataset containing both transcription and uncontrolled free-text tasks.

Key Insights and Ideas

  • Transformers are Keystroke-Ready: While often associated with massive natural language tasks, Transformers (with the right modifications) are exceptionally good at modeling the subtle temporal patterns in short keystroke sequences.
  • LSTMs + Attention = Better Together: The hybrid approach of using LSTMs within Transformer blocks proved crucial. The LSTMs handle local "rhythm," while the attention mechanism captures long-range dependencies across the sentence.
  • The "Sweet Spot" for Sequence Length: Interestingly, the authors found that a sequence length of 50 keystrokes was optimal. Performance actually degraded with longer sequences (70 or 100), likely due to the noise introduced by zero-padding shorter sentences to reach those lengths.
  • Robust Generalization: TypeFormer showed significantly better robustness in cross-database scenarios compared to previous SOTA models like TypeNet, suggesting it learns more fundamental "typing signatures" rather than just dataset-specific quirks.

Key Results

  • State-of-the-Art Performance: On the Aalto mobile database, TypeFormer achieved an EER of 3.25% using just 5 enrollment sessions. This is a 65% relative improvement over the previous RNN-based benchmark (TypeNet), which sat at 9.2%.
  • Efficiency: The system can verify identity passively. As shown in the workflow, it continuously compares test samples ($X_t$) against enrolled samples ($X_e$) in a high-dimensional embedding space.
Fig. 1. Graphical representation of the workflow of TypeFormer, the proposed biometric keystroke free-text verification system.
  • Cross-Database Robustness: In cross-database tests, TypeFormer achieved an average absolute improvement of 8.60% EER over TypeNet, proving its superior ability to generalize across different hardware and environments.

Limitations and Future Work

Despite the gains, challenges remain:

  • Cross-Database Drop: While better than predecessors, there is still a significant performance drop when moving between different databases (e.g., training on mobile and testing on desktop).
  • Variable Length Handling: The performance dip at higher sequence lengths suggests that the current method of zero-padding isn't ideal for Transformers in this domain.
  • Privacy Concerns: The authors note that keystroke embeddings might inadvertently contain sensitive metadata like gender or age. Future work will investigate how to ensure these biometric templates remain privacy-preserving.
  • Hard Triplet Mining: The researchers plan to explore more sophisticated training techniques, like hard triplet mining, to further sharpen the model's ability to distinguish between very similar typists.

Summary updated

BibTeX
@misc{stragapede2022typeformer,
  author = {Giuseppe Stragapede and Paula Delgado-Santos and Ruben Tolosana and Ruben Vera-Rodriguez and Richard Guest and Aythami Morales},
  title = {{TypeFormer: Transformers for Mobile Keystroke Biometrics}},
  year = {2022},
  eprint = {2212.13075},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2212.13075},
}
Figure