SemanticRanking[{text1, …},ref]
sorts textual items texti by semantic similarity to the reference string ref.
SemanticRanking[list,ref,prop]
returns the specified property prop.


SemanticRanking
SemanticRanking[{text1, …},ref]
sorts textual items texti by semantic similarity to the reference string ref.
SemanticRanking[list,ref,prop]
returns the specified property prop.
Details


- SemanticRanking reorders the input textual list according to semantic similarity to a provided reference string.
- SemanticRanking[{text1, text2, text3,… }, ref] sorts texti from the most to least similar.
- Possible values for prop include:
-
"Ordering" similarity rank for each item "Item" items in the original order "Rank" item position in the ordered list "RankedItem" items reordered from most to least similar (default) "Relevance" numerical similarity between each item and the reference {prop1,…} a list of properties All a Tabular with all the properties - The following options can be given:
-
Method Automatic semantic ranking method - Possible values for Method include:
-
Automatic default local model Tiny, Small, Medium, Large predefined model sizes {"string",size} a named model of the specified size f a custom ranking function - A custom ranker f must operate on the reference string and a list of strings to produce a numerical vector of the same length. The higher the number, the more similar the pair is.
- Specific ranking models include:
-
"MiniLM" default (Medium) "MiniLM" ranker {"MiniLM",Tiny} MiniLM-V2 L-2 {"MiniLM",Small} MiniLM-V2 L-4 {"MiniLM",Medium} MiniLM-V2 L-6 {"MiniLM",Large} MiniLM-V2 L-12
Examples
open all close allBasic Examples (2)
Scope (3)
Options (1)
Properties & Relations (1)
SemanticSearch automatically reranks the results using SemanticRanking:
This is equivalent to retrieving the "MinItems" for RerankingMethod without actually doing it:
Then taking the first five results after using SemanticRanking:
Possible Issues (2)
Create several paragraphs of text:
Reranking such a large number of items is slow:
Instead create a SemanticSearchIndex:
Use SemanticSearch to get a shortlist of the best matches:
The closest result is identical:
Words without context may not be ordered as expected:
A larger ranking model may improve results:
Alternatively, add more context to make the results more reliable:
See Also
Related Guides
History
Text
Wolfram Research (2025), SemanticRanking, Wolfram Language function, https://reference.wolfram.com/language/ref/SemanticRanking.html.
CMS
Wolfram Language. 2025. "SemanticRanking." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SemanticRanking.html.
APA
Wolfram Language. (2025). SemanticRanking. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SemanticRanking.html
BibTeX
@misc{reference.wolfram_2025_semanticranking, author="Wolfram Research", title="{SemanticRanking}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/SemanticRanking.html}", note=[Accessed: 04-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_semanticranking, organization={Wolfram Research}, title={SemanticRanking}, year={2025}, url={https://reference.wolfram.com/language/ref/SemanticRanking.html}, note=[Accessed: 04-August-2025]}