Model Evaluation
Query Distance
In shortHow far apart two search queries are, measured by spelling (fuzzy matching), by meaning (embeddings) or by the results they share.
Query distance describes how far apart two search queries are. A small distance means the queries are closely related, such as two phrasings of the same need or a query and its refinement. Measuring it across a keyword set helps you find near-duplicates, group related searches and trace the sequences people follow as they refine what they are looking for.
How it works
There are three main ways to measure it, and each answers a slightly different question:
- By spelling. Fuzzy matching scores, such as Levenshtein-based ratios or Jaccard similarity on words, measure how similar the strings look.
- By meaning. Turn each query into an embedding with a model such as Sentence-BERT and measure cosine distance, so “cheap flights” and “budget airfare” come out close.
- By results. Compare the URLs that rank for each query. Queries with heavily overlapping results are treated as the same topic by the search engine.
How it’s used in SEO and marketing
- Keyword clean-up. Merge near-duplicate keywords before prioritising.
- Content briefs. For each main keyword, list its closest neighbours as subheadings or FAQs.
- Query paths. Order related queries to see how people move from broad to specific searches.
- Cannibalisation checks. Find pages targeting queries that are too close to need separate pages.
Example
In the Semantic Keyword Research course, a Colab notebook takes a list of keywords and returns, for each one, the most similar keywords and a similarity percentage. For “home gym all in one equipment”, it surfaces terms such as “home gym beginner equipment” and “home gym cardio equipment”, which together outline a cluster and the sections a guide on the topic should cover.
Limitations and things to watch
- Spelling-based distance is lexical. It catches typos and word-order changes but misses synonyms, so check the meaning-based or results-based view before merging keywords.
- Embedding distance can group queries with different intents, such as “buy running shoes” and “running shoe reviews”.
- Results-based distance needs SERP data and changes over time.
- Every method needs a threshold, so calibrate it on a sample you have checked by hand.
Learn it on MLforSEO
Where Query Distance shows up on MLforSEO
Learn it in a course
Read about it on the blog
Sources and further reading
Other terms from Model Evaluation
- Accuracy (ML metric)Accuracy is the share of all predictions a model gets right. It is the simplest evaluation metric, but it misl…
- Coherence ScoreA metric for how interpretable a topic model's topics are, based on how often each topic's top words appear to…
- Confusion MatrixA confusion matrix is a table comparing a classifier's predictions with the true labels, showing exactly which…
- Cosine SimilarityA measure of how closely two vectors point in the same direction, used to score how similar two texts, keyword…
- Emotion ScoresPer-emotion scores (joy, sadness, fear, disgust, anger) an emotion analysis API assigns to a text, each from 0…
- Entity Salience ScoreA 0 to 1 score from Google's Natural Language API showing how central each extracted entity is to the analysed…
- Euclidean DistanceEuclidean distance is the straight-line distance between two points in any number of dimensions, used to compa…
- F1 ScoreA single evaluation metric that balances precision and recall (their harmonic mean); useful when classes are i…
- Ground TruthGround truth is the set of correct answers, usually labelled by people, that a model is trained on or checked…
