How a billing joke became a dataset

The dataset started by accident. While running RK4, a small software shop I started with a friend who also minored in mathematics, we kept wrestling with how to price client work. Half-joking, I wondered what would happen if we logged every single keypress inside Neovim.

I built keytrack.nvim to capture editor events and forward them to a FastAPI backend backed by SQLite. Five to six weeks later, when I was looking for a real dataset for my Machine Learning II (Deep Learning) final project at Utah Valley University, I ran:

SELECT COUNT(*) FROM keypresses;

Roughly 500,000 rows came back. Because Neovim is modal (the exact same j or w means completely different things in Normal mode versus Insert mode), it turned out to be a surprisingly rich sequence-modeling problem: could a Transformer learn what key I’m going to hit next from my recent editing history?

Feature pipeline and architecture

Every logged event carried more context than the raw key alone:

  • Categorical features: key pressed, editor mode (n, i, c, …), and filetype, encoded with pd.factorize after filling missing values explicitly.
  • Numeric features: cursor line normalized by total file length (line / line_count) and column standardized via z-score ((col - mean) / std), since line widths vary wildly across files.

I sliced the stream into 64-event sliding windows with an 80 / 10 / 10 train, validation, and test split, then built a PyTorch TransformerEncoder (2 layers, 4 attention heads, 128-dim embeddings, 512-dim feedforward). Learned embeddings for key, mode, and filetype are summed with a linear projection of the continuous cursor features and learned positional embeddings, with a linear head predicting next-key logits from the final hidden state.

What the model learned

Testing top-k predictions on held-out sequences confirmed the model picked up the difference between navigating code and writing prose:

  • Normal mode: Given a sequence of movement keys (h, Space, w, j, j, …), the model predicted j next at 73.8% probability.
  • Insert mode: Mid-word while typing ...for the mod, the model predicted e next at 71.1% probability.

Editor mode became one of the strongest signals in the entire sequence, without hard-coding a single rule about Vim.

What stayed with me

Training the network wasn’t the hardest part; inference hygiene was. Cleaning NULL values before dataset construction and carrying the exact training-time encoders and normalization stats (mean, std, factorized maps) into inference prevented subtle silent drift.

If I push this further, the obvious next feature is Tree-sitter syntax context, so the model knows whether the cursor sits inside a function signature, a string literal, or a comment rather than inferring structure from raw keystrokes alone.