Transformer

The transformer is the learned reranker inside key lime's global-key estimator. It keeps the DSP analyzer in the loop: key lime first extracts chroma, scores all 24 major and minor keys with profile-based DSP, and then lets the reranker choose the final global key from the same evidence.

Flow diagram: audio produces chroma frames and DSP key scores, which feed a compact transformer reranker that outputs the selected key, estimator name, and DSP prior.
key lime global-key reranker. Chroma frames and DSP key scores feed a compact transformer that chooses the global key.

Why it exists

Profile-based key estimators are small, portable, and easy to inspect. Close-key cases are the hard part: relative, parallel, and fifth-related keys can all have evidence in the same track. The key lime scorer keeps the DSP ranking and adds a small sequence model that reads the frame-level chroma before choosing the global key.

The learned model reuses the same chroma features and the same 24 DSP key scores that key lime already computes for local analysis. It reranks the DSP evidence rather than replacing the rest of key lime.

Model

The reranker has 21,528 parameters. It uses a circular pitch-class input stage, one transformer encoder layer, and a residual projection over the DSP key scores. The circular input lets the model read transposed pitch-class patterns without treating C and B as far apart.

The Rust crate embeds the selected seed-1729 weights and runs the forward pass directly. The release build does not require ONNX Runtime. Tests compare Rust logits against the ONNX reference artifact so the packaged model remains the same model used for validation.

Validation

Validation answers one practical question: does the small reranker improve global-key choice while keeping the same DSP features and output shape? On the sealed 1,000-track FMAKv2 holdout, the answer is yes.

DSP scorer

61.08 MIREX key score

52.30% exact accuracy

Reranker average

73.55 MIREX key score

67.07% exact accuracy

Shipping seed

73.53 MIREX key score

67.00% exact accuracy

The reranker average is computed across three training seeds. The shipping seed is the seed-1729 model embedded in the Rust crate.

MIREX key score gives partial credit for fifth, relative, and parallel-key errors, so it is more useful than exact accuracy when a model moves an estimate to a musically close key.

Scatter plot of FMAKv2 MIREX key score against installed footprint on a log scale. KL-FMAK, the transformer reranker, reaches 73.6, close to madmom and above S-KEY. KL-DSP, the deterministic scorer, reaches 61.1.

FMAKv2 MIREX key score against installed footprint. KL-DSP is the deterministic key lime scorer and KL-FMAK is the transformer reranker.

Paper

The model, training setup, and evaluation are described in the key lime paper. The arXiv preprint link will be added here when the preprint is posted (arXiv: TBD).

References