class LabelBotService

Methods

array
getLabelsForAnnotation(Annotation $annotation, int $volumeId, Request $request)

Get the suggested labels of a new annotation either by using a label_id or a feature_vector from the request.

enforceRateLimit($user)

No description

array
getLabelTreeIds(mixed $user, int $volumeId)

Get all label trees that are used by all projects which are visible to the user.

array
performVectorSearch(vector $featureVector, int[] $trees, string $model)

Perform vector search using the Dynamic Index Switching (DIS) technique.

array
performAnnSearch(Vector $featureVector, int[] $trees, $model)

Perform Approximate Nearest Neighbor (ANN) search using the HNSW index with Post-Subquery Filtering (PSF).

array
performAnnSearchWithIterativeIndexScan(Vector $featureVector, int[] $trees, $model)

Perform Approximate Nearest Neighbor (ANN) search using the HNSW iterative index scan.

ImageAnnotationLabelFeatureVector|VideoAnnotationLabelFeatureVector>
getFeatureVectorModelFor(Annotation $annotation)

Get the correct model class for the annotation type.

Details

at line 27
array getLabelsForAnnotation(Annotation $annotation, int $volumeId, Request $request)

Get the suggested labels of a new annotation either by using a label_id or a feature_vector from the request.

Parameters

Annotation $annotation
int $volumeId
Request $request

Return Value

array

at line 64
protected enforceRateLimit($user)

No description

Parameters

$user

at line 85
protected array getLabelTreeIds(mixed $user, int $volumeId)

Get all label trees that are used by all projects which are visible to the user.

Parameters

mixed $user
int $volumeId

Return Value

array

at line 121
protected array performVectorSearch(vector $featureVector, int[] $trees, string $model)

Perform vector search using the Dynamic Index Switching (DIS) technique.

The search process first attempts to retrieve results using an Approximate Nearest Neighbor (ANN) search via the HNSW index. If the ANN search returns no results, it falls back to an exact KNN search using the B-Tree index for filtering, ensuring that results are always returned.

Parameters

vector $featureVector

The input feature vector to search for nearest neighbors.

int[] $trees

The label tree IDs to filter the data by.

string $model

Class name of the feature vector model to use

Return Value

array

The array of top N labels that are the closest to the input feature vector.

at line 146
protected array performAnnSearch(Vector $featureVector, int[] $trees, $model)

Perform Approximate Nearest Neighbor (ANN) search using the HNSW index with Post-Subquery Filtering (PSF).

The search uses the HNSW index to find the top K nearest neighbors of the input feature vector, and then applies filtering based on the label_tree_id values. If no results are found or if the filtering removes all results, an empty array is returned.

Parameters

Vector $featureVector

The input feature vector to search for nearest neighbors.

int[] $trees

The label tree IDs to filter the data by.

$model

Return Value

array

The array of label IDs representing the top nearest neighbors.

at line 183
protected array performAnnSearchWithIterativeIndexScan(Vector $featureVector, int[] $trees, $model)

Perform Approximate Nearest Neighbor (ANN) search using the HNSW iterative index scan.

The search uses the HNSW iterative index scan to find the top K nearest neighbors of the input feature vector, and then applies filtering based on the label_tree_id values. If the filtering removes all results, the iterative scan will automatically scan more of the index until enough results are found (or it reaches hnsw.max_scan_tuples, which is 20,000 by default), finally if no results are found, an empty array is returned.

Parameters

Vector $featureVector

The input feature vector to search for nearest neighbors.

int[] $trees

The label tree IDs to filter the data by.

$model

Return Value

array

The array of label IDs representing the top nearest neighbors.

at line 220
protected ImageAnnotationLabelFeatureVector|VideoAnnotationLabelFeatureVector> getFeatureVectorModelFor(Annotation $annotation)

Get the correct model class for the annotation type.

Parameters

Annotation $annotation

Return Value

ImageAnnotationLabelFeatureVector|VideoAnnotationLabelFeatureVector>