1. Install LanceDB
Install LanceDB in your client SDK.2. Connect to a LanceDB database
Using LanceDB’s open source version is as simple as importing LanceDB as a library and pointing to a local path — no servers needed!Optional: LanceDB Cloud or Enterprise versions
If you’re looking for a fully-managed solution, you can use LanceDB Cloud, which provides managed infrastructure, security, and automatic backups. Simply replace the local path with a remoteuri
that points to where your data is stored, and you’re ready to go.
For enormous scale and more advanced use cases beyond just search — like
feature engineering, model training and more, check out LanceDB Enterprise.
3. Obtain data and ingest into LanceDB
Let’s look at an example. We have the following records of characters in an adventure board game. The vector column holds 3-dimensional embeddings representing each character. To ingest the data into LanceDB, obtain data of the required shape and pass in the data object to thecreate_table method as shown below.
Note that LanceDB tables require a schema. If you don’t provide one, LanceDB
will infer it from the data.
4. Run a vector similarity search
Now, let’s perform a vector similarity search. The query vector should have the same dimensionality as your data vectors and be generated using the same embedding model. The search returns the most similar vectors based on a chosen distance metric (default is L2, or Euclidean distance). Our query is a vector that represents a “warrior”. Let’s find the result that’s most similar to it! The example for Python above shows how to convert results to a Polars DataFrame. Depending on your language, you can collect query results as a list/array of objects or DataFrames to be used downstream in your application.Pandas users in Python can get results as a Pandas DataFrame
Pandas users in Python can get results as a Pandas DataFrame
Use the
to_pandas() method to convert query results into a Pandas DataFrame.See the full code for these examples (including helper functions) in the
quickstart file for the appropriate client language in the
docs repo.