SemanticSearchBehaviorProperties.ScoreThreshold Property
Gets or sets the similarity score threshold at which search results are considered relevant.
Namespace: DevExpress.AIIntegration.WinForms
Assembly: DevExpress.AIIntegration.WinForms.SemanticSearch.v25.1.dll
NuGet Package: DevExpress.AIIntegration.WinForms.SemanticSearch
Declaration
Property Value
Type | Default | Description |
---|---|---|
Double | 0 | The similarity score threshold at which search results are considered relevant. |
Remarks
In your vectorized data model, you must annotate a vector field with the VectorStoreVector
attribute and specify the desired similarity metric using the DistanceFunction
property:
using Microsoft.Extensions.VectorData;
// Define a record stored in the vector store for semantic search.
public class VectorStoreRecord {
// A unique identifier for the record in a vector store.
[VectorStoreKey]
public string Key { get; set; }
// Azure OpenAI (embedding model) produces 1536-dimensional vectors.
// Specify how vector data is stored and compared in a vector store.
// This example uses cosine similarity as the distance function for comparisons.
[VectorStoreVector(1536, DistanceFunction = DistanceFunction.CosineDistance)]
public string Vector { get; set; }
}
Warning
The VectorStoreVector
attribute indicates the preferred distance function, but the vector store ultimately determines which similarity metric is supported. If your vector store does not support the specified function, it will throw a runtime error.
Use the following properties to configure similarity filtering:
Score Threshold
The SemanticSearchBehavior.Properties.ScoreThreshold
property specifies the minimum or maximum score at which search results are considered relevant. The actual meaning of the score depends on the selected similarity metric/distance function. For example:
- Cosine Similarity
Value Description 1.0
Vectors are identical (maximum similarity) 0.0
Vectors are orthogonal (no similarity) -1.0
Vectors are opposite - Cosine Distance
Value Description 0.0
Vectors are identical (maximum similarity) 1.0
Vectors are orthogonal (no similarity) 2.0
Vectors are opposite
Score Threshold Filter
The SemanticSearchBehavior.Properties.ScoreThresholdFilter property specifies how the ScoreThreshold
is applied during filtering:
Value | Description |
---|---|
None |
No filtering is applied. All results are returned regardless of score. |
GreaterOrEqual |
Include results with a score greater than or equal to ScoreThreshold . Used with Cosine Similarity, where higher scores mean greater similarity. |
LessOrEqual |
Include results with a score less than or equal to ScoreThreshold . Used with Cosine Distance, where lower scores mean greater similarity. |
Examples
- Cosine Similarity Filtering
Returns results with similarity scores from
0.5
to1.0
:// Higher = more similar semanticSearchBehavior.ScoreThreshold = 0.5; semanticSearchBehavior.ScoreThresholdFilter = ScoreThresholdFilter.GreaterOrEqual;
- Cosine Distance Filtering
Returns results with distance scores from
0.0
to0.5
:// Lower = more similar semanticSearchBehavior.ScoreThreshold = 0.5; semanticSearchBehavior.ScoreThresholdFilter = ScoreThresholdFilter.LessOrEqual;
See the following help topic for additional information: Semantic Search.