Skip to main content
The neural reranker is the final stage of the suggestion pipeline, scoring candidates using a trained ONNX model after rule-based and N-gram ranking. It supports both MLP (multi-layer perceptron) and GBT (gradient-boosted tree) model types, auto-detected from the ONNX model’s input shape.

Overview

The reranker takes the candidate list with extracted features and produces a score for each candidate, reordering them by the model’s prediction of which correction is most likely correct.

Model Types

Model type is auto-detected from the ONNX input shape — no manual configuration needed.

Feature Vector

The reranker uses 19 features extracted from each candidate:

MLP v3 Feature Transforms

For MLP models with feature_schema == "mlp_v3", the reranker automatically applies transforms at inference time:
  • Drops original_rank feature (index 14) to prevent ranking leakage
  • Computes cross-features as configured in the stats file

Usage

Basic Usage

With SpellCheckerBuilder

Stats File Format

The JSON stats file contains normalization parameters for MLP models:

Training

Reranker models are trained offline using the training pipeline:
  1. Generate training data (training/reranker_data.py): Extracts feature vectors from benchmark examples
  2. Train model (training/reranker_trainer.py): Trains MLP and exports to ONNX with quantization
  3. Evaluate: Compare MRR and Top-1 accuracy against the baseline ranker
See the Training Guide for details on the training pipeline.

Performance

  • Latency: ~0.5ms per candidate batch (ONNX optimized)
  • Memory: ~2-5MB model size (quantized)
  • Dependencies: Requires onnxruntime (pip install myspellchecker[ai])

See Also