VectorDatabaseSearch

VectorDatabaseSearch[db,vector]

gives the element of the vector database db closest to vector.

VectorDatabaseSearch[db,vector,n]

gives the n nearest vectors.

VectorDatabaseSearch[db,vector,prop,n]

returns the property prop associated with the result

Details

  • VectorDatabaseSearch performs a search on the vector database using a query to find and retrieve similar items.
  • This function is used for tasks like finding similar documents, images or products via their vector representation, enhancing capabilities in recommendation systems and content discovery.
  • The database db must be a VectorDatabaseObject or a valid database name.
  • The search vectors must have the same length as the vector stored in the database.
  • Possible property values prop include:
  • "Distance"the distance from vector
    "Element"the vector found to be nearest
    "Index"the element position in the database
    "Metadata"metadata associated with the element
    "Metadata"taga specific metadata value
    {prop1,}a list of properties
    Alla Dataset with all the properties

Examples

open allclose all

Basic Examples  (1)

Initialize a new vector database with a list of vectors:

Perform a search operation:

Scope  (3)

Initialize a new vector database with a list of vectors:

Find the first nearest vector:

Find the list of the first three nearest vectors:

Find the vectors together with their distance:

List all the properties of each result:

Create a vector database with labeled arrays:

The label is automatically returned when searching:

Return the vector instead:

Return the label explicitly:

Filter the result to only contain vectors with a specific label:

Create a vector database with metadata associated to each vector:

Search for the two nearest vectors:

Return only vectors matching a specified filter:

Applications  (1)

Image Search  (1)

Assemble a collection of images:

Label each image with a class:

Define a feature extraction function that uses a neural network to compute vector features:

Compute the feature vector for each image:

Create a vector database with the labeled vectors:

Search for similar images in the database:

Wolfram Research (2024), VectorDatabaseSearch, Wolfram Language function, https://reference.wolfram.com/language/ref/VectorDatabaseSearch.html.

Text

Wolfram Research (2024), VectorDatabaseSearch, Wolfram Language function, https://reference.wolfram.com/language/ref/VectorDatabaseSearch.html.

CMS

Wolfram Language. 2024. "VectorDatabaseSearch." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/VectorDatabaseSearch.html.

APA

Wolfram Language. (2024). VectorDatabaseSearch. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/VectorDatabaseSearch.html

BibTeX

@misc{reference.wolfram_2024_vectordatabasesearch, author="Wolfram Research", title="{VectorDatabaseSearch}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/VectorDatabaseSearch.html}", note=[Accessed: 04-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_vectordatabasesearch, organization={Wolfram Research}, title={VectorDatabaseSearch}, year={2024}, url={https://reference.wolfram.com/language/ref/VectorDatabaseSearch.html}, note=[Accessed: 04-November-2024 ]}