Overview
SuggestionData
All ranking input is encapsulated inSuggestionData:
Data Fields
Ranking Strategies
DefaultRanker
Balanced ranking considering multiple factors:FrequencyFirstRanker
Prioritizes common words over edit distance:EditDistanceOnlyRanker
Simple ranking by edit distance only:PhoneticFirstRanker
Prioritizes phonetically similar words:UnifiedRanker
Consolidates suggestions from multiple sources: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 viaNeuralRerankerConfig.
- 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_candidatesper 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:- SymSpell generates initial candidates
- N-gram context rescores using left/right probabilities
- Targeted rerank rules apply heuristic promotions/injections
- Neural reranker extracts 19 features, runs ONNX MLP, reorders by score
Training a Reranker
Performance
See Also
- SymSpell Algorithm - Suggestion generation
- Edit Distance - Distance calculations
- Phonetic Matching - Phonetic scoring
- Configuration Guide - RankerConfig options