Skip to main content
The suggestion ranking system determines how spelling corrections are scored and ordered. Multiple ranking strategies are available, from simple edit distance to sophisticated multi-factor ranking.

Overview

SuggestionData

All ranking input is encapsulated in SuggestionData:

Data Fields

Ranking Strategies

DefaultRanker

Balanced ranking considering multiple factors:
Scoring Formula:
Bonuses:

FrequencyFirstRanker

Prioritizes common words over edit distance:
Scoring Formula:
Use Case: Autocomplete-style suggestions where common words are preferred.

EditDistanceOnlyRanker

Simple ranking by edit distance only:
Use Case: Testing, debugging, or when frequency data is unavailable.

PhoneticFirstRanker

Prioritizes phonetically similar words:
Scoring Formula:
Use Case: Myanmar text with common phonetic confusions (medial swaps).

UnifiedRanker

Consolidates suggestions from multiple sources:
Source Weights:

Configuration

RankerConfig

Integration with SymSpell

UnifiedRanker Features

Deduplication

Batch Ranking

Nasal Variant Handling

Myanmar has multiple nasal endings that are often confused:

Custom Rankers

Implement custom ranking strategy:

Neural Reranker

After the primary ranker scores suggestions, an optional neural reranker (MLP) can reorder them based on learned patterns. This is configured via NeuralRerankerConfig.
The neural reranker:
  • Uses an MLP (20→64→1) trained with cross-entropy loss on suggestion quality signals
  • Runs ONNX inference to score each candidate
  • Skips reranking when the confidence gap between top-2 suggestions exceeds confidence_gap_threshold (the top suggestion is already clearly best)
  • Caps candidates at max_candidates per error for performance

Feature Vector (19 dimensions)

Each candidate is represented by a 19-dimensional feature vector: See Neural Reranker for model types, inference, and training details.

Integration Flow

The neural reranker runs as the final step in the suggestion pipeline:
  1. SymSpell generates initial candidates
  2. N-gram context rescores using left/right probabilities
  3. Targeted rerank rules apply heuristic promotions/injections
  4. Neural reranker extracts 19 features, runs ONNX MLP, reorders by score

Training a Reranker

Performance

See Also