docs: bring the open-source documentation into this repository (#4122)

Move the public website pages into `docs/web` beside the SDK, with
shared navigation and executable example sources in `docs/web-tests`.
The combined website is assembled by
[lancedb/docs#355](https://github.com/lancedb/docs/pull/355), with six
Enterprise replacements from
[lancedb/sophon#7681](https://github.com/lancedb/sophon/pull/7681).

This includes Function guidance, runnable Quickstarts, regenerated
snippets, production contact/demo fixes, the legacy SQL route, and the
LeRobot redirect. LeRobot remains attributed to Geneva; all 34 Geneva
pages remain in the docs repository until Function officially launches.

Materialized-view guidance follows the full rebuild refresh introduced
by #4373: local refresh writes the complete result, has no `full`
argument, supports `source_version`, and no longer requires stable row
IDs. Deployment SQL refresh options and stable-ID setup are qualified by
version/configuration. Function input guidance distinguishes ordinary
stored columns from computed inputs supported by newer deployments.

**Validation:** independently accepted local checks include 95 Python
tests (real Enterprise excluded), eight TypeScript tests, Rust
Quickstart, snippet parity, typos, deterministic assembly, Mint
validation and links/anchors/redirects. The combined baseline retains
all 181 production routes and 17 legacy redirects. Examples ran locally
against source-built Python SDK 0.40.0b13; existing GitHub workflows do
not run `docs/web-tests`. New main at `069b2f7d` is 0.41.0b0 and adds
computed Function inputs; that SDK was not exercised by the accepted
tests. Latest prose corrections receive focused site validation.

**Merge/rollout:** merge this and #7681 before #355's combined CI, which
reads producer `main`. This is migration infrastructure: section
overlays, source-owned skills and automatic versioned paired releases
remain follow-ups. The current manual publisher is transitional. Hosted
validation, a supported SDK/Enterprise release pair and a real
Enterprise walkthrough remain pending.

Production Mintlify watches `lancedb/docs:deploy-freeze`, directory
`docs`; preserve that source through review. The separate SDK GitHub
Pages reference workflow rebuilds on main merges.

**Updated-head CI (9a50f8db):**
[Typos](https://github.com/lancedb/lancedb/actions/runs/37654185443/job/112904990558),
[PR
title](https://github.com/lancedb/lancedb/actions/runs/37654179507/job/112904974595)
and
[Aikido](https://app.aikido.dev/featurebranch/scan/215386145?groupId=74229)
pass. Critical findings in the example lockfiles were patched: all Sharp
copies use 0.35.5, protobufjs 7.6.6, tar 7.5.22, quinn-proto 0.11.19,
zerovec 0.11.8 and zerovec-derive 0.11.6. The SDK's product dependencies
are unchanged. The revised lockfiles pass eight TypeScript examples,
HuggingFace decode/resize/crop/rescale/normalize plus AVIF roundtrip,
and Rust Quickstart. Aikido passing does not mean every advisory is
cleared; npm still reports 29 high and five moderate advisories in the
example dependency graph. No scanner bypass or suppression was added.

The Function prose correction passes combined/standalone Mint,
deterministic assembly, routes and assets. The revised 325-file site
checksum is
`175bec06864abb400dd292e667ba93448c0479b8359fd7bf6146afabf9040647`. This
PR remains open for independent review; further merges are on hold.

---------

Co-authored-by: Brendan Clement <brendan.clement@lancedb.com>
This commit is contained in:
Jack Ye
2026-10-07 11:15:00 -07:00
committed by GitHub
co-authored by Brendan Clement
parent de005f1d61
commit 47b7babc08
307 changed files with 51361 additions and 2 deletions
+97
View File
@@ -0,0 +1,97 @@
---
title: "dlt"
sidebarTitle: "DLT"
---
import {
PyPlatformsDltAdapterImport,
PyPlatformsDltAdapterUsage,
PyPlatformsDltPipeline,
} from '/snippets/integrations.mdx';
[dlt](https://dlthub.com/docs/intro) is an open-source library that you can add to your Python scripts to load data from various and often messy data sources into well-structured, live datasets. dlt's [integration with LanceDB](https://dlthub.com/docs/dlt-ecosystem/destinations/lancedb) lets you ingest data from any source (databases, APIs, CSVs, dataframes, JSONs, and more) into LanceDB with a few lines of simple python code. The integration enables automatic normalization of nested data, schema inference, incremental loading and embedding the data. dlt also has integrations with several other tools like dbt, airflow, dagster etc. that can be inserted into your LanceDB workflow.
## How to ingest data into LanceDB {#how-to-ingest-data-into-lancedb}
In this example, we will be fetching movie information from the [Open Movie Database (OMDb) API](https://www.omdbapi.com/) and loading it into a local LanceDB instance. To implement it, you will need an API key for the OMDb API (which can be created freely [here](https://www.omdbapi.com/apikey.aspx)).
1. **Install `dlt` with LanceDB extras:**
```sh
pip install dlt[lancedb]
```
2. **Inside an empty directory, initialize a `dlt` project with:**
```sh
dlt init rest_api lancedb
```
This will add all the files necessary to create a `dlt` pipeline that can ingest data from any REST API (ex: OMDb API) and load into LanceDB.
```text
├── .dlt
│ ├── config.toml
│ └── secrets.toml
├── rest_api
├── rest_api_pipeline.py
└── requirements.txt
```
dlt has a list of pre-built [sources](https://dlthub.com/docs/dlt-ecosystem/verified-sources/) like [SQL databases](https://dlthub.com/docs/dlt-ecosystem/verified-sources/sql_database), [REST APIs](https://dlthub.com/docs/dlt-ecosystem/verified-sources/rest_api), [Google Sheets](https://dlthub.com/docs/dlt-ecosystem/verified-sources/google_sheets), [Notion](https://dlthub.com/docs/dlt-ecosystem/verified-sources/notion) etc., that can be used out-of-the-box by running `dlt init <source_name> lancedb`. Since dlt is a python library, it is also very easy to modify these pre-built sources or to write your own custom source from scratch.
3. **Specify necessary credentials and/or embedding model details:**
In order to fetch data from the OMDb API, you will need to pass a valid API key into your pipeline. Depending on whether you're using LanceDB OSS or LanceDB Enterprise, you also may need to provide the necessary credentials to connect to the LanceDB instance. These can be pasted inside `.dlt/secrets.toml`.
dlt's LanceDB integration also allows you to automatically embed the data during ingestion. Depending on the embedding model chosen, you may need to paste the necessary credentials inside `.dlt/secrets.toml`:
```toml
[sources.rest_api]
api_key = "api_key" # Enter the API key for the OMDb API
[destination.lancedb]
embedding_model_provider = "sentence-transformers"
embedding_model = "all-MiniLM-L6-v2"
[destination.lancedb.credentials]
uri = ".lancedb"
api_key = "api_key" # API key to connect to LanceDB Enterprise. Leave out if you are using LanceDB OSS.
embedding_model_provider_api_key = "embedding_model_provider_api_key" # Not needed for providers that don't need authentication (ollama, sentence-transformers).
```
See [here](https://dlthub.com/docs/dlt-ecosystem/destinations/lancedb#configure-the-destination) for more information and for a list of available models and model providers.
4. **Write the pipeline code inside `rest_api_pipeline.py`:**
The following code shows how you can configure dlt's REST API source to connect to the [OMDb API](https://www.omdbapi.com/), fetch all movies with the word "godzilla" in the title, and load it into a LanceDB table. The REST API source allows you to pull data from any API with minimal code, to learn more read the [dlt docs](https://dlthub.com/docs/dlt-ecosystem/verified-sources/rest_api).
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsDltPipeline}
</CodeBlock>
The script above will ingest the data into LanceDB as it is, i.e. without creating any embeddings. If we want to embed one of the fields (for example, `"Title"` that contains the movie titles), then we will use dlt's `lancedb_adapter` and modify the script as follows:
- Add the following import statement:
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsDltAdapterImport}
</CodeBlock>
- Modify the pipeline run like this:
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsDltAdapterUsage}
</CodeBlock>
This will use the embedding model specified inside `.dlt/secrets.toml` to embed the field `"Title"`.
5. **Install necessary dependencies:**
```sh
pip install -r requirements.txt
```
Note: You may need to install the dependencies for your embedding models separately.
```sh
pip install sentence-transformers
```
6. **Run the pipeline:**
Finally, running the following command will ingest the data into your LanceDB instance.
```sh
python custom_source.py
```
For more information and advanced usage of dlt's LanceDB integration, read [the dlt documentation](https://dlthub.com/docs/dlt-ecosystem/destinations/lancedb).
+119
View File
@@ -0,0 +1,119 @@
---
title: "DuckDB"
sidebarTitle: "DuckDB"
description: "Learn how to use the DuckDB-Lance extension to query Lance tables with SQL."
---
LanceDB integrates with [DuckDB](https://duckdb.org/) through the [Lance extension](https://github.com/lance-format/lance-duckdb) for DuckDB. In this page, we'll show how LanceDB manages table lifecycle, and DuckDB provides SQL analytics (including joins) and search over those tables.
Note that earlier versions of LanceDB used to recommend converting Lance tables to Arrow tables via `table.to_arrow()`. Although this method is still available (because DuckDB [natively scans Arrow tables](https://duckdb.org/2021/12/03/duck-arrow)), it is no longer the recommended workflow for working with Lance tables in DuckDB. This page shows how to use the Lance extension with namespace-attached LanceDB tables, allowing you to pushdown SQL queries directly to the Lance layer.
## Install {#install}
Install the DuckDB CLI as per [their docs](https://duckdb.org/install) and alternatively, their Python package with `pip install duckdb`.
Then, open the DuckDB CLI and install and load the Lance extension as follows:
```sql SQL icon="database"
INSTALL lance;
LOAD lance;
```
## Attach the directory namespace in DuckDB {#attach-the-directory-namespace-in-duckdb}
Attach the LanceDB root directory as a Lance namespace:
```sql SQL icon="database"
ATTACH './local_lancedb' AS lance_ns (TYPE LANCE);
```
In this page, tables are referenced using `lance_ns.main.<table_name>`, so the table path is `lance_ns.main.lance_duck`.
## Write Lance table {#write-lance-table}
Create the `lance_duck` table using SQL and populate it with sample data:
```sql SQL icon="database"
CREATE OR REPLACE TABLE lance_ns.main.lance_duck AS
SELECT *
FROM (
VALUES
('duck', 'quack', [0.9, 0.7, 0.1]::FLOAT[]),
('horse', 'neigh', [0.3, 0.1, 0.5]::FLOAT[]),
('dragon', 'roar', [0.5, 0.2, 0.7]::FLOAT[])
) AS t(animal, noise, vector);
```
This table is the source of truth for all DuckDB queries below.
<Info>
The examples below show SQL entered in the DuckDB CLI. You can run the same SQL from
Python as well, using LanceDB and DuckDB's Python clients in your application code.
</Info>
## Query the table with SQL {#query-the-table-with-sql}
```sql SQL icon="database"
SELECT *
FROM lance_ns.main.lance_duck
LIMIT 5;
```
## Vector search {#vector-search}
```sql SQL icon="database"
SELECT animal, noise, vector, _distance
FROM lance_vector_search(
'lance_ns.main.lance_duck',
'vector',
[0.8, 0.7, 0.2]::FLOAT[],
k = 1,
prefilter = true
)
ORDER BY _distance ASC;
```
## Full-text search {#full-text-search}
```sql SQL icon="database"
SELECT animal, noise, vector, _score
FROM lance_fts(
'lance_ns.main.lance_duck',
'animal',
'the brave knight faced the dragon',
k = 1,
prefilter = true
)
ORDER BY _score DESC;
```
## Hybrid search {#hybrid-search}
```sql SQL icon="database"
SELECT animal, noise, vector, _hybrid_score, _distance, _score
FROM lance_hybrid_search(
'lance_ns.main.lance_duck',
'vector',
[0.8, 0.7, 0.2]::FLOAT[],
'animal',
'the duck surprised the dragon',
k = 2,
prefilter = false,
alpha = 0.5,
oversample_factor = 4
)
ORDER BY _hybrid_score DESC;
```
## Directory namespace model {#directory-namespace-model}
A directory namespace maps a LanceDB catalog root to namespace-qualified table identifiers in DuckDB. This keeps table discovery and table naming stable as your project grows.
To learn more about the catalog and namespace model, see [Namespaces and the Catalog Model](/management/namespace).
## Advanced usage {#advanced-usage}
See the [docs](https://github.com/lance-format/lance-duckdb) directory in the Lance-DuckDB extension repo
for more advanced usage on SQL and REST API clients.
@@ -0,0 +1,46 @@
---
title: "Pandas and PyArrow"
sidebarTitle: "Pandas & PyArrow"
---
import {
PyPlatformsPandasAsyncExample,
PyPlatformsPandasCreateTable,
PyPlatformsPandasImports,
PyPlatformsPandasVectorSearch,
} from '/snippets/integrations.mdx';
Because Lance is built on top of [Apache Arrow](https://arrow.apache.org/),
LanceDB fits naturally into Pandas-first workflows. You can ingest a `DataFrame`,
query it with LanceDB's vector operators, and keep working in Pandas without any glue code.
## Create a dataset {#create-a-dataset}
Start by importing LanceDB alongside your usual Pandas utilities and connect to a temporary database.
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsPandasImports}
</CodeBlock>
Use the familiar `pd.DataFrame` API to prepare your rows, then pass the entire frame to `db.create_table`.
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsPandasCreateTable}
</CodeBlock>
## Vector search {#vector-search}
Queries can return Pandas frames as well, so you can immediately inspect the results or pipe them into downstream analytics.
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsPandasVectorSearch}
</CodeBlock>
## Async API {#async-api}
For web services or background jobs that already rely on `asyncio`, use the asynchronous helpers to keep everything non-blocking.
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsPandasAsyncExample}
</CodeBlock>
@@ -0,0 +1,51 @@
---
title: "Polars"
sidebarTitle: "Polars & Arrow"
---
import {
PyPlatformsPolarsCreateTable,
PyPlatformsPolarsImports,
PyPlatformsPolarsLazyframe,
PyPlatformsPolarsPydantic,
PyPlatformsPolarsVectorSearch,
} from '/snippets/integrations.mdx';
LanceDB supports [Polars](https://github.com/pola-rs/polars), a blazingly fast DataFrame library for Python written in Rust. Under the hood, both Lance and Polars speak Arrow, so passing data back and forth stays zero-copy and ergonomic.
## Create and Query a Table {#create-and-query-a-table}
Import the required libraries, including the optional Pydantic helpers if you plan to define schemas.
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsPolarsImports}
</CodeBlock>
Build a Polars `DataFrame`, convert it to Arrow, and use it directly when creating a LanceDB table.
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsPolarsCreateTable}
</CodeBlock>
Run vector search and keep the results as a Polars `DataFrame` for further processing or visualization.
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsPolarsVectorSearch}
</CodeBlock>
## Work with LazyFrames {#work-with-lazyframes}
When you want to operate on the entire table (potentially larger than RAM), convert to a Polars `LazyFrame` so you can chain transformations without loading everything at once.
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsPolarsLazyframe}
</CodeBlock>
## Define Schemas with Pydantic {#define-schemas-with-pydantic}
You can also describe your table via `LanceModel` and continue ingesting data from Polars. This is useful when multiple teams share a schema or when you want validation.
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsPolarsPydantic}
</CodeBlock>
+90
View File
@@ -0,0 +1,90 @@
---
title: "Pydantic"
sidebarTitle: "Pydantic"
---
import {
PyFrameworksPydanticBaseExample,
PyFrameworksPydanticBaseModel,
PyFrameworksPydanticImports,
PyFrameworksPydanticSetUrl,
PyFrameworksPydanticTypeConversion,
PyFrameworksPydanticVectorField,
} from '/snippets/integrations.mdx';
[Pydantic](https://docs.pydantic.dev/latest/) is a data validation library in Python.
LanceDB integrates with Pydantic for schema inference, data ingestion, and query result casting.
Using `lancedb.pydantic.LanceModel`, users can seamlessly
integrate Pydantic with the rest of the LanceDB APIs.
First, import the necessary LanceDB and Pydantic modules:
<CodeBlock filename="Python" language="Python" icon="python">
{PyFrameworksPydanticImports}
</CodeBlock>
Next, define your Pydantic model by inheriting from `LanceModel` and specifying your fields including a vector field:
<CodeBlock filename="Python" language="Python" icon="python">
{PyFrameworksPydanticBaseModel}
</CodeBlock>
Set the database connection URL:
<CodeBlock filename="Python" language="Python" icon="python">
{PyFrameworksPydanticSetUrl}
</CodeBlock>
Now you can create a table, add data, and perform vector search operations:
<CodeBlock filename="Python" language="Python" icon="python">
{PyFrameworksPydanticBaseExample}
</CodeBlock>
## Vector Field {#vector-field}
LanceDB provides a `lancedb.pydantic.Vector` method to define a
vector Field in a Pydantic Model.
<CodeBlock filename="Python" language="Python" icon="python">
{PyFrameworksPydanticVectorField}
</CodeBlock>
This example demonstrates how LanceDB automatically converts Pydantic field types to their corresponding Apache Arrow data types. The `pydantic_to_schema()` function takes a Pydantic model and generates an Arrow schema where:
- `int` fields become `pa.int64()` (64-bit integers)
- `str` fields become `pa.utf8()` (UTF-8 encoded strings)
- `Vector(768)` becomes `pa.list_(pa.float32(), 768)` (fixed-size list of 768 float32 values)
- The `False` parameter indicates that the fields are not nullable
## Type Conversion {#type-conversion}
LanceDB automatically convert Pydantic fields to
[Apache Arrow DataType](https://arrow.apache.org/docs/python/generated/pyarrow.DataType.html#pyarrow.DataType).
Current supported type conversions:
| Pydantic Field Type | PyArrow Data Type |
| ------------------- | ----------------- |
| `int` | `pyarrow.int64` |
| `float` | `pyarrow.float64` |
| `bool` | `pyarrow.bool` |
| `str` | `pyarrow.utf8()` |
| `list` | `pyarrow.List` |
| `BaseModel` | `pyarrow.Struct` |
| `Vector(n)` | `pyarrow.FixedSizeList(float32, n)` |
LanceDB supports to create Apache Arrow Schema from a
`pydantic.BaseModel`
via `lancedb.pydantic.pydantic_to_schema` method.
<CodeBlock filename="Python" language="Python" icon="python">
{PyFrameworksPydanticTypeConversion}
</CodeBlock>
This example shows a more complex Pydantic model with various field types and demonstrates how LanceDB handles:
- Basic types: `int` and `str` fields
- Vector fields: `Vector(1536)` creates a fixed-size list of 1536 float32 values
- List fields: `List[int]` becomes a variable-length list of int64 values
- Schema generation: The `pydantic_to_schema()` function automatically converts all these types to their Arrow equivalents
+212
View File
@@ -0,0 +1,212 @@
---
title: "Voxel51"
sidebarTitle: "Voxel51"
---
import {
PyPlatformsVoxel51BackendFlag,
PyPlatformsVoxel51BackendParams,
PyPlatformsVoxel51BrainConfig,
PyPlatformsVoxel51Cleanup,
PyPlatformsVoxel51ComputeSimilarity,
PyPlatformsVoxel51LoadDataset,
PyPlatformsVoxel51SortBySimilarity,
} from '/snippets/integrations.mdx';
# FiftyOne
[FiftyOne](https://docs.voxel51.com/) is an open source toolkit that enables users to curate better data and build better models. It includes tools for data exploration, visualization, and management, as well as features for collaboration and sharing.
Any developers, data scientists, and researchers who work with computer vision and machine learning can use FiftyOne to improve the quality of their datasets and deliver insights about their models.
![example](/static/assets/images/integrations/voxel.gif)
**FiftyOne** provides an API to create LanceDB tables and run similarity queries, both **programmatically in Python** and via **point-and-click in the App**.
Let's get started and see how to use **LanceDB** to create a **similarity index** on your FiftyOne datasets.
## Overview {#overview}
[Embeddings](/embedding/) are foundational to all of the **vector search** features. In FiftyOne, embeddings are managed by the [**FiftyOne Brain**](https://docs.voxel51.com/user_guide/brain.html) that provides powerful machine learning techniques designed to transform how you curate your data from an art into a measurable science.
> _Have you ever wanted to find the images most similar to an image in your dataset?_
The **FiftyOne Brain** makes computing **visual similarity** really easy. You can compute the similarity of samples in your dataset using an embedding model and store the results in the **brain key**.
You can then sort your samples by similarity or use this information to find potential duplicate images.
We'll be doing the following :
1. **Create Index** - In order to run similarity queries against our media, we need to **index** the data. We can do this via the `compute_similarity()` function.
- In the function, specify the **model** you want to use to generate the embedding vectors, and what **vector search engine** you want to use on the **backend** (here LanceDB).
<Tip>
You can also give the similarity index a name(`brain_key`), which is useful if you want to run vector searches against multiple indexes.
</Tip>
2. **Query** - Once you have generated your similarity index, you can query your dataset with `sort_by_similarity()`. The query can be any of the following:
- An ID (sample or patch)
- A query vector of same dimension as the index
- A list of IDs (samples or patches)
- A text prompt (search semantically)
## Prerequisites: install necessary dependencies {#prerequisites-install-necessary-dependencies}
1. **Create and activate a virtual environment**
Install virtualenv package and run the following command in your project directory.
<CodeBlock filename="bash" language="bash" icon="terminal">
python -m venv fiftyone_
</CodeBlock>
From inside the project directory run the following to activate the virtual environment.
<CodeGroup>
<CodeBlock filename="macOS/Linux" language="bash" icon="linux">
source fiftyone_/Scripts/activate
</CodeBlock>
<CodeBlock filename="Windows" language="bash" icon="windows">
fiftyone_/Scripts/activate
</CodeBlock>
</CodeGroup>
2. **Install the following packages in the virtual environment**
To install FiftyOne, ensure you have activated any virtual environment that you are using, then run
<CodeBlock filename="bash" language="bash" icon="terminal">
pip install fiftyone
</CodeBlock>
## Understand basic workflow {#understand-basic-workflow}
The basic workflow shown below uses LanceDB to create a similarity index on your FiftyOne datasets:
1. Load a dataset into FiftyOne.
2. Compute embedding vectors for samples or patches in your dataset, or select a model to use to generate embeddings.
3. Use the `compute_similarity()` method to generate a LanceDB table for the samples or object patches embeddings in a dataset by setting the parameter `backend="lancedb"` and specifying a `brain_key` of your choice.
4. Use this LanceDB table to query your data with `sort_by_similarity()`.
5. If desired, delete the table.
## Quick Example {#quick-example}
Let's jump on a quick example that demonstrates this workflow.
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsVoxel51LoadDataset}
</CodeBlock>
Make sure you install torch ([guide here](https://pytorch.org/get-started/locally/)) before proceeding.
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsVoxel51ComputeSimilarity}
</CodeBlock>
!!! note
Running the code above will download the clip model (2.6Gb)
Once the similarity index has been generated, we can query our data in FiftyOne by specifying the `brain_key`:
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsVoxel51SortBySimilarity}
</CodeBlock>
The returned result are of type - `DatasetView`.
<Note>
`DatasetView` does not hold its contents in-memory. Views simply store the rule(s) that are applied to extract the content of interest from the underlying Dataset when the view is iterated/aggregated on.
This means, for example, that the contents of a `DatasetView` may change as the underlying Dataset is modified.
</Note>
> _Can you query a view instead of dataset?_
Yes, you can also query a view.
Performing a similarity search on a `DatasetView` will only return results from the view; if the view contains samples that were not included in the index, they will never be included in the result.
This means that you can index an entire Dataset once and then perform searches on subsets of the dataset by constructing views that contain the images of interest.
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsVoxel51Cleanup}
</CodeBlock>
## Using LanceDB backend {#using-lancedb-backend}
By default, calling `compute_similarity()` or `sort_by_similarity()` will use an sklearn backend.
To use the LanceDB backend, simply set the optional `backend` parameter of `compute_similarity()` to `"lancedb"`:
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsVoxel51BackendFlag}
</CodeBlock>
Alternatively, you can configure FiftyOne to use the LanceDB backend by setting the following environment variable.
In your terminal, set the environment variable using:
<CodeGroup>
<CodeBlock filename="macOS/Linux" language="bash" icon="linux">
export FIFTYONE_BRAIN_DEFAULT_SIMILARITY_BACKEND=lancedb
</CodeBlock>
<CodeBlock filename="Windows" language="powershell" icon="windows">
$Env:FIFTYONE_BRAIN_DEFAULT_SIMILARITY_BACKEND="lancedb" //powershell
set FIFTYONE_BRAIN_DEFAULT_SIMILARITY_BACKEND=lancedb //cmd
</CodeBlock>
</CodeGroup>
<Warning>
This will only run during the terminal session. Once terminal is closed, environment variable is deleted.
</Warning>
Alternatively, you can **permanently** configure FiftyOne to use the LanceDB backend creating a `brain_config.json` at `~/.fiftyone/brain_config.json`. The JSON file may contain any desired subset of config fields that you wish to customize.
```json
{
"default_similarity_backend": "lancedb"
}
```
This will override the default `brain_config` and will set it according to your customization. You can check the configuration by running the following code :
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsVoxel51BrainConfig}
</CodeBlock>
## LanceDB config parameters {#lancedb-config-parameters}
The LanceDB backend supports query parameters that can be used to customize your similarity queries. These parameters include:
| Name | Purpose | Default |
| :------------- | :--------------------------------------------------------------------------------------------------------------- | :--------------- |
| **table_name** | The name of the LanceDB table to use. If none is provided, a new table will be created | `None` |
| **metric** | The embedding distance metric to use when creating a new table. The supported values are ("cosine", "euclidean") | `"cosine"` |
| **uri** | The database URI to use. In this Database URI, tables will be created. | `"/tmp/lancedb"` |
There are two ways to specify/customize the parameters:
1. **Using `brain_config.json` file**
```json
{
"similarity_backends": {
"lancedb": {
"table_name": "your-table",
"metric": "euclidean",
"uri": "/tmp/lancedb"
}
}
}
```
2. **Directly passing to `compute_similarity()` to configure a specific new index** :
<CodeBlock filename="Python" language="Python" icon="python">
{PyPlatformsVoxel51BackendParams}
</CodeBlock>
For a much more in depth walkthrough of the integration, visit the LanceDB x Voxel51 [docs page](https://docs.voxel51.com/integrations/lancedb.html).