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 "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 "BGE" BAAI BGE-V2-M3
Examples
open allclose allBasic Examples (1)
Scope (2)
Options (1)
Properties & Relations (1)
SemanticSearch automatically reranks the results using SemanticRerank:
This is equivalent to retrieving the "MinItems" for RerankingMethod without actually doing it:
Then taking the first five results after using SemanticRanking:
Possible Issues (1)
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:
Text
Wolfram Research (2025), SemanticRanking, Wolfram Language function, https://reference.wolfram.com/language/ref/SemanticReranking.html.
CMS
Wolfram Language. 2025. "SemanticRanking." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SemanticReranking.html.
APA
Wolfram Language. (2025). SemanticRanking. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SemanticReranking.html