mirror of
https://github.com/lancedb/lancedb.git
synced 2026-10-17 01:02:28 +00:00
docs: bring the open-source documentation into this repository
The pages describing this code lived in lancedb/docs, a repository with ten stars that neither contributing guide mentioned. A user who hit a wrong page while reading the source had to find a separate, near-invisible repository to fix it. These 102 pages now sit beside the code, and a documentation fix is a pull request in the repository the reader already had open. `docs/web` is a complete Mintlify site: `cd docs/web && mint dev` serves it with no other checkout. Enterprise pages stay private and are merged in when the published site is assembled, so links into them do not resolve here — every open-source page does. `docs/web-tests` holds the tests the code examples are extracted from. They ran against a published wheel before; here they can run against this repository's own SDK, so an example that stops compiling fails the pull request that broke it rather than being noticed later. Both directories sit beside `docs/src` and are invisible to it: mkdocs reads `docs_dir: src`, so the SDK reference builds and deploys exactly as before.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
---
|
||||
title: AWS Bedrock
|
||||
sidebarTitle: AWS
|
||||
---
|
||||
|
||||
import { PyEmbeddingAwsUsage } from '/snippets/integrations.mdx';
|
||||
|
||||
AWS Bedrock supports multiple base models for generating text embeddings. You need to setup the AWS credentials to use this embedding function.
|
||||
You can do so by using `awscli` and also add your session_token:
|
||||
```shell
|
||||
aws configure
|
||||
aws configure set aws_session_token "<your_session_token>"
|
||||
```
|
||||
to ensure that the credentials are set up correctly, you can run the following command:
|
||||
```shell
|
||||
aws sts get-caller-identity
|
||||
```
|
||||
|
||||
Supported Embedding modelIDs are:
|
||||
* `amazon.titan-embed-text-v1`
|
||||
* `cohere.embed-english-v3`
|
||||
* `cohere.embed-multilingual-v3`
|
||||
|
||||
Supported parameters (to be passed in `create` method) are:
|
||||
|
||||
| Parameter | Type | Default Value | Description |
|
||||
|---|---|---|---|
|
||||
| **name** | str | "amazon.titan-embed-text-v1" | The model ID of the bedrock model to use. Supported base models for Text Embeddings: amazon.titan-embed-text-v1, cohere.embed-english-v3, cohere.embed-multilingual-v3 |
|
||||
| **region** | str | "us-east-1" | Optional name of the AWS Region in which the service should be called (e.g., "us-east-1"). |
|
||||
| **profile_name** | str | None | Optional name of the AWS profile to use for calling the Bedrock service. If not specified, the default profile will be used. |
|
||||
| **assumed_role** | str | None | Optional ARN of an AWS IAM role to assume for calling the Bedrock service. If not specified, the current active credentials will be used. |
|
||||
| **role_session_name** | str | "lancedb-embeddings" | Optional name of the AWS IAM role session to use for calling the Bedrock service. If not specified, a "lancedb-embeddings" name will be used. |
|
||||
| **runtime** | bool | True | Optional choice of getting different client to perform operations with the Amazon Bedrock service. |
|
||||
| **max_retries** | int | 7 | Optional number of retries to perform when a request fails. |
|
||||
|
||||
Usage Example:
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingAwsUsage}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
@@ -0,0 +1,51 @@
|
||||
---
|
||||
title: Cohere
|
||||
sidebarTitle: Cohere
|
||||
---
|
||||
|
||||
import { PyEmbeddingCohereUsage } from '/snippets/integrations.mdx';
|
||||
|
||||
Using cohere API requires cohere package, which can be installed using `pip install cohere`. Cohere embeddings are used to generate embeddings for text data. The embeddings can be used for various tasks like semantic search, clustering, and classification.
|
||||
You also need to set the `COHERE_API_KEY` environment variable to use the Cohere API.
|
||||
|
||||
Supported models are:
|
||||
|
||||
- embed-english-v3.0
|
||||
- embed-multilingual-v3.0
|
||||
- embed-english-light-v3.0
|
||||
- embed-multilingual-light-v3.0
|
||||
- embed-english-v2.0
|
||||
- embed-english-light-v2.0
|
||||
- embed-multilingual-v2.0
|
||||
|
||||
|
||||
Supported parameters (to be passed in `create` method) are:
|
||||
|
||||
| Parameter | Type | Default Value | Description |
|
||||
|---|---|--------|---------|
|
||||
| `name` | `str` | `"embed-english-v2.0"` | The model ID of the cohere model to use. Supported base models for Text Embeddings: embed-english-v3.0, embed-multilingual-v3.0, embed-english-light-v3.0, embed-multilingual-light-v3.0, embed-english-v2.0, embed-english-light-v2.0, embed-multilingual-v2.0 |
|
||||
| `source_input_type` | `str` | `"search_document"` | The type of input data to be used for the source column. |
|
||||
| `query_input_type` | `str` | `"search_query"` | The type of input data to be used for the query. |
|
||||
|
||||
Cohere supports following input types:
|
||||
|
||||
| Input Type | Description |
|
||||
|-------------------------|---------------------------------------|
|
||||
| "`search_document`" | Used for embeddings stored in a vector|
|
||||
| | database for search use-cases. |
|
||||
| "`search_query`" | Used for embeddings of search queries |
|
||||
| | run against a vector DB |
|
||||
| "`semantic_similarity`" | Specifies the given text will be used |
|
||||
| | for Semantic Textual Similarity (STS) |
|
||||
| "`classification`" | Used for embeddings passed through a |
|
||||
| | text classifier. |
|
||||
| "`clustering`" | Used for the embeddings run through a |
|
||||
| | clustering algorithm |
|
||||
|
||||
Usage Example:
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingCohereUsage}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
@@ -0,0 +1,53 @@
|
||||
---
|
||||
title: ColPali
|
||||
sidebarTitle: ColPali
|
||||
---
|
||||
|
||||
import {
|
||||
PyEmbeddingColpaliSetup,
|
||||
PyEmbeddingColpaliTextSearch,
|
||||
} from '/snippets/integrations.mdx';
|
||||
|
||||
We support [ColPali](https://github.com/illuin-tech/colpali) model embeddings for multimodal multi-vector retrieval. ColPali produces multiple embedding vectors per input (multi-vector), enabling more nuanced similarity matching between text queries and image documents.
|
||||
|
||||
Using ColPali requires the colpali-engine package, which can be installed using `pip install colpali-engine`.
|
||||
|
||||
<Info>
|
||||
ColPali produces **multi-vector** embeddings, meaning each input generates multiple embedding vectors rather than a single vector. Use `MultiVector(func.ndims())` instead of `Vector(func.ndims())` when defining your schema.
|
||||
</Info>
|
||||
|
||||
Supported models are:
|
||||
|
||||
- Metric-AI/ColQwen2.5-3b-multilingual-v1.0 (default)
|
||||
- vidore/colpali-v1.3
|
||||
- vidore/colqwen2-v1.0
|
||||
- vidore/colSmol-256M
|
||||
|
||||
Supported parameters (to be passed in `create` method) are:
|
||||
|
||||
| Parameter | Type | Default Value | Description |
|
||||
|---|---|---|---|
|
||||
| `model_name` | `str` | `"Metric-AI/ColQwen2.5-3b-multilingual-v1.0"` | The name of the model to use. |
|
||||
| `device` | `str` | `"auto"` | The device for inference. Can be `"auto"`, `"cpu"`, `"cuda"`, or `"mps"`. |
|
||||
| `dtype` | `str` | `"bfloat16"` | Data type for model weights (bfloat16, float16, float32, float64). |
|
||||
| `pooling_strategy` | `str` | `"hierarchical"` | Token pooling strategy: `"hierarchical"`, `"lambda"`, or `None`. |
|
||||
| `pool_factor` | `int` | `2` | Factor to reduce sequence length when pooling is enabled. |
|
||||
| `batch_size` | `int` | `2` | Batch size for processing inputs. |
|
||||
| `quantization_config` | `Optional[BitsAndBytesConfig]` | `None` | Quantization configuration for the model (requires bitsandbytes). |
|
||||
|
||||
This embedding function supports ingesting images as both bytes and URLs. You can query them using text.
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingColpaliSetup}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
|
||||
Now we can search using text queries:
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingColpaliTextSearch}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
---
|
||||
title: Gemini
|
||||
sidebarTitle: Gemini
|
||||
---
|
||||
|
||||
import { PyEmbeddingGeminiUsage } from '/snippets/integrations.mdx';
|
||||
|
||||
With Google's Gemini, you can represent text (words, sentences, and blocks of text) in a vectorized form, making it easier to compare and contrast embeddings. For example, two texts that share a similar subject matter or sentiment should have similar embeddings, which can be identified through mathematical comparison techniques such as cosine similarity. For more on how and why you should use embeddings, refer to the Embeddings guide.
|
||||
The Gemini Embedding Model API supports various task types:
|
||||
|
||||
| Task Type | Description |
|
||||
|-------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| "`retrieval_query`" | Specifies the given text is a query in a search/retrieval setting. |
|
||||
| "`retrieval_document`" | Specifies the given text is a document in a search/retrieval setting. Using this task type requires a title but is automatically provided by Embeddings API |
|
||||
| "`semantic_similarity`" | Specifies the given text will be used for Semantic Textual Similarity (STS). |
|
||||
| "`classification`" | Specifies that the embeddings will be used for classification. |
|
||||
| "`clustering`" | Specifies that the embeddings will be used for clustering. |
|
||||
|
||||
|
||||
Usage Example:
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingGeminiUsage}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
title: Hugging Face
|
||||
sidebarTitle: Hugging Face
|
||||
---
|
||||
|
||||
import { PyEmbeddingHuggingfaceUsage } from '/snippets/integrations.mdx';
|
||||
|
||||
We offer support for all Hugging Face models (which can be loaded via [transformers](https://huggingface.co/docs/transformers/en/index) library). The default model is `colbert-ir/colbertv2.0` which also has its own special callout - `registry.get("colbert")`. Some Hugging Face models might require custom models defined on the HuggingFace Hub in their own modeling files. You may enable this by setting `trust_remote_code=True`. This option should only be set to True for repositories you trust and in which you have read the code, as it will execute code present on the Hub on your local machine.
|
||||
|
||||
Example usage:
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingHuggingfaceUsage}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
@@ -0,0 +1,64 @@
|
||||
---
|
||||
title: IBM watsonx
|
||||
sidebarTitle: IBM WatsonX
|
||||
---
|
||||
|
||||
import { PyEmbeddingIbmUsage } from '/snippets/integrations.mdx';
|
||||
|
||||
Generate text embeddings using IBM's watsonx.ai platform.
|
||||
|
||||
## Supported Models {#supported-models}
|
||||
|
||||
You can find a list of supported models at [IBM watsonx.ai Documentation](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-models-embed.html?context=wx). The currently supported model names are:
|
||||
|
||||
| Model ID | Dimensions |
|
||||
|----------------------------------------------|------------|
|
||||
| `ibm/granite-embedding-278m-multilingual` | 768 |
|
||||
| `ibm/slate-125m-english-rtrvr-v2` | 768 |
|
||||
| `ibm/slate-30m-english-rtrvr-v2` | 384 |
|
||||
| `intfloat/multilingual-e5-large` | 1024 |
|
||||
| `sentence-transformers/all-minilm-l6-v2` | 384 |
|
||||
|
||||
<Info>
|
||||
For new tables, `ibm/granite-embedding-278m-multilingual` is the recommended default. Older model IDs (such as `ibm/slate-125m-english-rtrvr` and `sentence-transformers/all-minilm-l12-v2`) remain resolvable for tables whose stored metadata references them, but they are no longer advertised for new use.
|
||||
</Info>
|
||||
|
||||
## Parameters {#parameters}
|
||||
|
||||
The following parameters can be passed to the `create` method:
|
||||
|
||||
| Parameter | Type | Default Value | Description |
|
||||
|------------|----------|----------------------------------|-----------------------------------------------------------|
|
||||
| name | str | `"ibm/slate-125m-english-rtrvr"` | The model ID of the watsonx.ai model to use. Pass one of the current supported IDs above (e.g. `"ibm/granite-embedding-278m-multilingual"`) when creating new tables. |
|
||||
| api_key | str | None | Optional IBM Cloud API key (or set `WATSONX_API_KEY`) |
|
||||
| project_id | str | None | Optional watsonx project ID (or set `WATSONX_PROJECT_ID`). Mutually exclusive with `space_id`. |
|
||||
| space_id | str | None | Optional watsonx deployment space ID (or set `WATSONX_SPACE_ID`). Mutually exclusive with `project_id`. |
|
||||
| url | str | None | Optional custom URL for the watsonx.ai instance |
|
||||
| params | dict | None | Optional additional parameters for the embedding model (e.g. `{"truncate_input_tokens": 512}`) |
|
||||
|
||||
<Info>
|
||||
You must supply exactly one of `project_id` or `space_id` (either as an argument or via its environment variable). Setting both, or neither, raises a `ValueError`.
|
||||
</Info>
|
||||
|
||||
## Usage Example {#usage-example}
|
||||
|
||||
First, the watsonx.ai library is an optional dependency, so must be installed separately:
|
||||
|
||||
```
|
||||
pip install ibm-watsonx-ai
|
||||
```
|
||||
|
||||
Optionally set environment variables (if not passing credentials to `create` directly):
|
||||
|
||||
```sh
|
||||
export WATSONX_API_KEY="YOUR_WATSONX_API_KEY"
|
||||
# Provide exactly one of the following:
|
||||
export WATSONX_PROJECT_ID="YOUR_WATSONX_PROJECT_ID"
|
||||
export WATSONX_SPACE_ID="YOUR_WATSONX_SPACE_ID"
|
||||
```
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingIbmUsage}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
@@ -0,0 +1,54 @@
|
||||
---
|
||||
title: ImageBind
|
||||
sidebarTitle: ImageBind
|
||||
---
|
||||
|
||||
import {
|
||||
PyEmbeddingImagebindSetup,
|
||||
PyEmbeddingImagebindImageSearch,
|
||||
PyEmbeddingImagebindAudioSearch,
|
||||
PyEmbeddingImagebindTextSearch,
|
||||
} from '/snippets/integrations.mdx';
|
||||
|
||||
We have support for [imagebind](https://github.com/facebookresearch/ImageBind) model embeddings. You can download our version of the packaged model via - `pip install imagebind-packaged==0.1.2`.
|
||||
|
||||
This function is registered as `imagebind` and supports Audio, Video and Text modalities(extending to Thermal,Depth,IMU data):
|
||||
|
||||
| Parameter | Type | Default Value | Description |
|
||||
|---|---|---|---|
|
||||
| `name` | `str` | `"imagebind_huge"` | Name of the model. |
|
||||
| `device` | `str` | `"cpu"` | The device to run the model on. Can be `"cpu"` or `"gpu"`. |
|
||||
| `normalize` | `bool` | `False` | set to `True` to normalize your inputs before model ingestion. |
|
||||
|
||||
Below is an example demonstrating how the API works:
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingImagebindSetup}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
|
||||
Now, we can search using any modality:
|
||||
|
||||
#### image search {#image-search}
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingImagebindImageSearch}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
#### audio search {#audio-search}
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingImagebindAudioSearch}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
#### Text search {#text-search}
|
||||
You can add any input query and fetch the result as follows:
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingImagebindTextSearch}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
|
||||
If you have any questions about the embeddings API, supported models, or see a relevant model missing, please raise an issue [on GitHub](https://github.com/lancedb/lancedb/issues).
|
||||
@@ -0,0 +1,39 @@
|
||||
---
|
||||
title: Instructor
|
||||
sidebarTitle: Instructor
|
||||
---
|
||||
|
||||
import { PyEmbeddingInstructorUsage } from '/snippets/integrations.mdx';
|
||||
|
||||
[Instructor](https://instructor-embedding.github.io/) is an instruction-finetuned text embedding model that can generate text embeddings tailored to any task (e.g. classification, retrieval, clustering, text evaluation, etc.) and domains (e.g. science, finance, etc.) by simply providing the task instruction, without any finetuning.
|
||||
|
||||
If you want to calculate customized embeddings for specific sentences, you can follow the unified template to write instructions.
|
||||
|
||||
<Info>
|
||||
Represent the `domain` `text_type` for `task_objective`:
|
||||
|
||||
- `domain` is optional, and it specifies the domain of the text, e.g. science, finance, medicine, etc.
|
||||
- `text_type` is required, and it specifies the encoding unit, e.g. sentence, document, paragraph, etc.
|
||||
- `task_objective` is optional, and it specifies the objective of embedding, e.g. retrieve a document, classify the sentence, etc.
|
||||
</Info>
|
||||
|
||||
More information about the model can be found at the [source URL](https://github.com/xlang-ai/instructor-embedding).
|
||||
|
||||
| Argument | Type | Default | Description |
|
||||
|---|---|---|---|
|
||||
| `name` | `str` | "hkunlp/instructor-base" | The name of the model to use |
|
||||
| `batch_size` | `int` | `32` | The batch size to use when generating embeddings |
|
||||
| `device` | `str` | `"cpu"` | The device to use when generating embeddings |
|
||||
| `show_progress_bar` | `bool` | `True` | Whether to show a progress bar when generating embeddings |
|
||||
| `normalize_embeddings` | `bool` | `True` | Whether to normalize the embeddings |
|
||||
| `quantize` | `bool` | `False` | Whether to quantize the model |
|
||||
| `source_instruction` | `str` | `"represent the document for retrieval"` | The instruction for the source column |
|
||||
| `query_instruction` | `str` | `"represent the document for retrieving the most similar documents"` | The instruction for the query |
|
||||
|
||||
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingInstructorUsage}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
@@ -0,0 +1,49 @@
|
||||
---
|
||||
title: Jina
|
||||
sidebarTitle: Jina
|
||||
---
|
||||
|
||||
import {
|
||||
PyEmbeddingJinaText,
|
||||
PyEmbeddingJinaMultimodal,
|
||||
} from '/snippets/integrations.mdx';
|
||||
|
||||
## Text Embedding Models {#text-embedding-models}
|
||||
|
||||
Jina embeddings are used to generate embeddings for text and image data.
|
||||
You also need to set the `JINA_API_KEY` environment variable to use the Jina API.
|
||||
|
||||
You can find a list of supported models under [https://jina.ai/embeddings/](https://jina.ai/embeddings/)
|
||||
|
||||
Supported parameters (to be passed in `create` method) are:
|
||||
|
||||
| Parameter | Type | Default Value | Description |
|
||||
|---|---|---|---|
|
||||
| `name` | `str` | `"jina-clip-v1"` | The model ID of the jina model to use |
|
||||
|
||||
Usage Example:
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingJinaText}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
|
||||
## Multimodal Embedding Models {#multimodal-embedding-models}
|
||||
|
||||
Jina embeddings can also be used to embed both text and image data, only some of the models support image data and you can check the list
|
||||
under [https://jina.ai/embeddings/](https://jina.ai/embeddings/)
|
||||
|
||||
Supported parameters (to be passed in `create` method) are:
|
||||
|
||||
| Parameter | Type | Default Value | Description |
|
||||
|---|---|---|---|
|
||||
| `name` | `str` | `"jina-clip-v1"` | The model ID of the jina model to use |
|
||||
|
||||
Usage Example:
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingJinaMultimodal}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: Ollama
|
||||
sidebarTitle: Ollama
|
||||
---
|
||||
|
||||
import { PyEmbeddingOllamaUsage } from '/snippets/integrations.mdx';
|
||||
|
||||
Generate embeddings via the [ollama](https://github.com/ollama/ollama-python) python library. More details:
|
||||
|
||||
- [Ollama docs on embeddings](https://github.com/ollama/ollama/blob/main/docs/api.md#generate-embeddings)
|
||||
- [Ollama blog on embeddings](https://ollama.com/blog/embedding-models)
|
||||
|
||||
| Parameter | Type | Default Value | Description |
|
||||
|------------------------|----------------------------|--------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `name` | `str` | `nomic-embed-text` | The name of the model. |
|
||||
| `host` | `str` | `http://localhost:11434` | The Ollama host to connect to. |
|
||||
| `options` | `ollama.Options` or `dict` | `None` | Additional model parameters listed in the documentation for the Modelfile such as `temperature`. |
|
||||
| `keep_alive` | `float` or `str` | `"5m"` | Controls how long the model will stay loaded into memory following the request. |
|
||||
| `ollama_client_kwargs` | `dict` | `{}` | kwargs that can be past to the `ollama.Client`. |
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingOllamaUsage}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
title: OpenAI
|
||||
sidebarTitle: OpenAI
|
||||
---
|
||||
|
||||
import { PyEmbeddingOpenaiBasic } from '/snippets/integrations.mdx';
|
||||
|
||||
LanceDB registers the OpenAI embeddings function in the registry by default, as `openai`. Below are the parameters that you can customize when creating the instances:
|
||||
|
||||
| Parameter | Type | Default Value | Description |
|
||||
|---|---|---|---|
|
||||
| `name` | `str` | `"text-embedding-ada-002"` | The name of the model. |
|
||||
| `dim` | `int` | Model default | For OpenAI's newer text-embedding-3 model, we can specify a dimensionality that is smaller than the 1536 size. This feature supports it |
|
||||
| `use_azure` | bool | `False` | Set true to use Azure OpenAI SDK |
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingOpenaiBasic}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
@@ -0,0 +1,46 @@
|
||||
---
|
||||
title: OpenCLIP
|
||||
sidebarTitle: OpenCLIP
|
||||
---
|
||||
|
||||
import {
|
||||
PyEmbeddingOpenclipSetup,
|
||||
PyEmbeddingOpenclipTextSearch,
|
||||
PyEmbeddingOpenclipImageSearch,
|
||||
} from '/snippets/integrations.mdx';
|
||||
|
||||
We support CLIP model embeddings using the open source alternative, [open-clip](https://github.com/mlfoundations/open_clip) which supports various customizations. It is registered as `open-clip` and supports the following customizations:
|
||||
|
||||
| Parameter | Type | Default Value | Description |
|
||||
|---|---|---|---|
|
||||
| `name` | `str` | `"ViT-B-32"` | The name of the model. |
|
||||
| `pretrained` | `str` | `"laion2b_s34b_b79k"` | The name of the pretrained model to load. |
|
||||
| `device` | `str` | `"cpu"` | The device to run the model on. Can be `"cpu"` or `"gpu"`. |
|
||||
| `batch_size` | `int` | `64` | The number of images to process in a batch. |
|
||||
| `normalize` | `bool` | `True` | Whether to normalize the input images before feeding them to the model. |
|
||||
|
||||
This embedding function supports ingesting images as both bytes and urls. You can query them using both text and other images.
|
||||
|
||||
<Info>
|
||||
LanceDB supports ingesting images directly from accessible links.
|
||||
</Info>
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingOpenclipSetup}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
Now we can search using text from both the default vector column and the custom vector column
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingOpenclipTextSearch}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
|
||||
Because we're using a multimodal embedding function, we can also search using images
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingOpenclipImageSearch}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
@@ -0,0 +1,169 @@
|
||||
---
|
||||
title: Sentence Transformers
|
||||
sidebarTitle: Sentence Transformers
|
||||
---
|
||||
|
||||
import { PyEmbeddingSentenceTransformersBaai } from '/snippets/integrations.mdx';
|
||||
|
||||
Allows you to set parameters when registering a `sentence-transformers` object.
|
||||
|
||||
<Info>
|
||||
Sentence transformer embeddings are normalized by default. It is recommended to use normalized embeddings for similarity search.
|
||||
</Info>
|
||||
|
||||
<Warning>
|
||||
The `trust_remote_code` parameter defaults to `True`, which allows models to execute arbitrary code from their Hugging Face repository during loading. If you are loading untrusted models, set `trust_remote_code=False` to prevent remote code execution.
|
||||
</Warning>
|
||||
|
||||
| Parameter | Type | Default Value | Description |
|
||||
|---|---|---|---|
|
||||
| `name` | `str` | `all-MiniLM-L6-v2` | The name of the model |
|
||||
| `device` | `str` | `cpu` | The device to run the model on (can be `cpu` or `gpu`) |
|
||||
| `normalize` | `bool` | `True` | Whether to normalize the input text before feeding it to the model |
|
||||
| `trust_remote_code` | `bool` | `True` | Whether to trust and execute remote code from the model's Huggingface repository |
|
||||
|
||||
|
||||
<Details title="Check out available sentence-transformer models here!">
|
||||
```markdown
|
||||
- sentence-transformers/all-MiniLM-L12-v2
|
||||
- sentence-transformers/paraphrase-mpnet-base-v2
|
||||
- sentence-transformers/gtr-t5-base
|
||||
- sentence-transformers/LaBSE
|
||||
- sentence-transformers/all-MiniLM-L6-v2
|
||||
- sentence-transformers/bert-base-nli-max-tokens
|
||||
- sentence-transformers/bert-base-nli-mean-tokens
|
||||
- sentence-transformers/bert-base-nli-stsb-mean-tokens
|
||||
- sentence-transformers/bert-base-wikipedia-sections-mean-tokens
|
||||
- sentence-transformers/bert-large-nli-cls-token
|
||||
- sentence-transformers/bert-large-nli-max-tokens
|
||||
- sentence-transformers/bert-large-nli-mean-tokens
|
||||
- sentence-transformers/bert-large-nli-stsb-mean-tokens
|
||||
- sentence-transformers/distilbert-base-nli-max-tokens
|
||||
- sentence-transformers/distilbert-base-nli-mean-tokens
|
||||
- sentence-transformers/distilbert-base-nli-stsb-mean-tokens
|
||||
- sentence-transformers/distilroberta-base-msmarco-v1
|
||||
- sentence-transformers/distilroberta-base-msmarco-v2
|
||||
- sentence-transformers/nli-bert-base-cls-pooling
|
||||
- sentence-transformers/nli-bert-base-max-pooling
|
||||
- sentence-transformers/nli-bert-base
|
||||
- sentence-transformers/nli-bert-large-cls-pooling
|
||||
- sentence-transformers/nli-bert-large-max-pooling
|
||||
- sentence-transformers/nli-bert-large
|
||||
- sentence-transformers/nli-distilbert-base-max-pooling
|
||||
- sentence-transformers/nli-distilbert-base
|
||||
- sentence-transformers/nli-roberta-base
|
||||
- sentence-transformers/nli-roberta-large
|
||||
- sentence-transformers/roberta-base-nli-mean-tokens
|
||||
- sentence-transformers/roberta-base-nli-stsb-mean-tokens
|
||||
- sentence-transformers/roberta-large-nli-mean-tokens
|
||||
- sentence-transformers/roberta-large-nli-stsb-mean-tokens
|
||||
- sentence-transformers/stsb-bert-base
|
||||
- sentence-transformers/stsb-bert-large
|
||||
- sentence-transformers/stsb-distilbert-base
|
||||
- sentence-transformers/stsb-roberta-base
|
||||
- sentence-transformers/stsb-roberta-large
|
||||
- sentence-transformers/xlm-r-100langs-bert-base-nli-mean-tokens
|
||||
- sentence-transformers/xlm-r-100langs-bert-base-nli-stsb-mean-tokens
|
||||
- sentence-transformers/xlm-r-base-en-ko-nli-ststb
|
||||
- sentence-transformers/xlm-r-bert-base-nli-mean-tokens
|
||||
- sentence-transformers/xlm-r-bert-base-nli-stsb-mean-tokens
|
||||
- sentence-transformers/xlm-r-large-en-ko-nli-ststb
|
||||
- sentence-transformers/bert-base-nli-cls-token
|
||||
- sentence-transformers/all-distilroberta-v1
|
||||
- sentence-transformers/multi-qa-MiniLM-L6-dot-v1
|
||||
- sentence-transformers/multi-qa-distilbert-cos-v1
|
||||
- sentence-transformers/multi-qa-distilbert-dot-v1
|
||||
- sentence-transformers/multi-qa-mpnet-base-cos-v1
|
||||
- sentence-transformers/multi-qa-mpnet-base-dot-v1
|
||||
- sentence-transformers/nli-distilroberta-base-v2
|
||||
- sentence-transformers/all-MiniLM-L6-v1
|
||||
- sentence-transformers/all-mpnet-base-v1
|
||||
- sentence-transformers/all-mpnet-base-v2
|
||||
- sentence-transformers/all-roberta-large-v1
|
||||
- sentence-transformers/allenai-specter
|
||||
- sentence-transformers/average_word_embeddings_glove.6B.300d
|
||||
- sentence-transformers/average_word_embeddings_glove.840B.300d
|
||||
- sentence-transformers/average_word_embeddings_komninos
|
||||
- sentence-transformers/average_word_embeddings_levy_dependency
|
||||
- sentence-transformers/clip-ViT-B-32-multilingual-v1
|
||||
- sentence-transformers/clip-ViT-B-32
|
||||
- sentence-transformers/distilbert-base-nli-stsb-quora-ranking
|
||||
- sentence-transformers/distilbert-multilingual-nli-stsb-quora-ranking
|
||||
- sentence-transformers/distilroberta-base-paraphrase-v1
|
||||
- sentence-transformers/distiluse-base-multilingual-cased-v1
|
||||
- sentence-transformers/distiluse-base-multilingual-cased-v2
|
||||
- sentence-transformers/distiluse-base-multilingual-cased
|
||||
- sentence-transformers/facebook-dpr-ctx_encoder-multiset-base
|
||||
- sentence-transformers/facebook-dpr-ctx_encoder-single-nq-base
|
||||
- sentence-transformers/facebook-dpr-question_encoder-multiset-base
|
||||
- sentence-transformers/facebook-dpr-question_encoder-single-nq-base
|
||||
- sentence-transformers/gtr-t5-large
|
||||
- sentence-transformers/gtr-t5-xl
|
||||
- sentence-transformers/gtr-t5-xxl
|
||||
- sentence-transformers/msmarco-MiniLM-L-12-v3
|
||||
- sentence-transformers/msmarco-MiniLM-L-6-v3
|
||||
- sentence-transformers/msmarco-MiniLM-L12-cos-v5
|
||||
- sentence-transformers/msmarco-MiniLM-L6-cos-v5
|
||||
- sentence-transformers/msmarco-bert-base-dot-v5
|
||||
- sentence-transformers/msmarco-bert-co-condensor
|
||||
- sentence-transformers/msmarco-distilbert-base-dot-prod-v3
|
||||
- sentence-transformers/msmarco-distilbert-base-tas-b
|
||||
- sentence-transformers/msmarco-distilbert-base-v2
|
||||
- sentence-transformers/msmarco-distilbert-base-v3
|
||||
- sentence-transformers/msmarco-distilbert-base-v4
|
||||
- sentence-transformers/msmarco-distilbert-cos-v5
|
||||
- sentence-transformers/msmarco-distilbert-dot-v5
|
||||
- sentence-transformers/msmarco-distilbert-multilingual-en-de-v2-tmp-lng-aligned
|
||||
- sentence-transformers/msmarco-distilbert-multilingual-en-de-v2-tmp-trained-scratch
|
||||
- sentence-transformers/msmarco-distilroberta-base-v2
|
||||
- sentence-transformers/msmarco-roberta-base-ance-firstp
|
||||
- sentence-transformers/msmarco-roberta-base-v2
|
||||
- sentence-transformers/msmarco-roberta-base-v3
|
||||
- sentence-transformers/multi-qa-MiniLM-L6-cos-v1
|
||||
- sentence-transformers/nli-mpnet-base-v2
|
||||
- sentence-transformers/nli-roberta-base-v2
|
||||
- sentence-transformers/nq-distilbert-base-v1
|
||||
- sentence-transformers/paraphrase-MiniLM-L12-v2
|
||||
- sentence-transformers/paraphrase-MiniLM-L3-v2
|
||||
- sentence-transformers/paraphrase-MiniLM-L6-v2
|
||||
- sentence-transformers/paraphrase-TinyBERT-L6-v2
|
||||
- sentence-transformers/paraphrase-albert-base-v2
|
||||
- sentence-transformers/paraphrase-albert-small-v2
|
||||
- sentence-transformers/paraphrase-distilroberta-base-v1
|
||||
- sentence-transformers/paraphrase-distilroberta-base-v2
|
||||
- sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2
|
||||
- sentence-transformers/paraphrase-multilingual-mpnet-base-v2
|
||||
- sentence-transformers/paraphrase-xlm-r-multilingual-v1
|
||||
- sentence-transformers/quora-distilbert-base
|
||||
- sentence-transformers/quora-distilbert-multilingual
|
||||
- sentence-transformers/sentence-t5-base
|
||||
- sentence-transformers/sentence-t5-large
|
||||
- sentence-transformers/sentence-t5-xxl
|
||||
- sentence-transformers/sentence-t5-xl
|
||||
- sentence-transformers/stsb-distilroberta-base-v2
|
||||
- sentence-transformers/stsb-mpnet-base-v2
|
||||
- sentence-transformers/stsb-roberta-base-v2
|
||||
- sentence-transformers/stsb-xlm-r-multilingual
|
||||
- sentence-transformers/xlm-r-distilroberta-base-paraphrase-v1
|
||||
- sentence-transformers/clip-ViT-L-14
|
||||
- sentence-transformers/clip-ViT-B-16
|
||||
- sentence-transformers/use-cmlm-multilingual
|
||||
- sentence-transformers/all-MiniLM-L12-v1
|
||||
```
|
||||
</Details>
|
||||
|
||||
<Info>
|
||||
You can also load many other model architectures from the library. For example models from sources such as BAAI, Nomic, Salesforce Research, etc. See this HF hub page for all [supported models](https://huggingface.co/models?library=sentence-transformers).
|
||||
</Info>
|
||||
|
||||
<Note title="BAAI embeddings example">
|
||||
Here is an example that uses the BAAI embedding model from the Hugging Face Hub [supported models](https://huggingface.co/models?library=sentence-transformers).
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingSentenceTransformersBaai}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
</Note>
|
||||
Visit sentence-transformers [HuggingFace HUB](https://huggingface.co/sentence-transformers) page for more information on the available models.
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
---
|
||||
title: Superlinked
|
||||
sidebarTitle: Superlinked
|
||||
---
|
||||
|
||||
[Superlinked](https://superlinked.com) is a self-hosted inference engine (SIE) for embedding, reranking, and extraction. The `sie-lancedb` package registers SIE as a first-class embedding function in LanceDB's embeddings registry, so embeddings are computed automatically on insert and search. You need a running SIE instance - see the [Superlinked quickstart](https://superlinked.com/docs) for deployment options.
|
||||
|
||||
## Installation {#installation}
|
||||
|
||||
<CodeGroup>
|
||||
```bash Python icon=Python
|
||||
pip install sie-lancedb
|
||||
```
|
||||
|
||||
```bash TypeScript icon=js
|
||||
npm install @superlinked/sie-lancedb @lancedb/lancedb
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## Registered functions {#registered-functions}
|
||||
|
||||
Importing `sie_lancedb` registers two embedding functions in LanceDB's registry:
|
||||
|
||||
| Name | Purpose |
|
||||
|---|---|
|
||||
| `"sie"` | Dense text embeddings |
|
||||
| `"sie-multivector"` | ColBERT-style late interaction with MaxSim scoring |
|
||||
|
||||
Supported parameters on `.create()`:
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|---|---|---|
|
||||
| `model` | `str` | Any of 85+ SIE-supported models (e.g. `BAAI/bge-m3`, `NovaSearch/stella_en_400M_v5`, `jinaai/jina-colbert-v2`) |
|
||||
| `base_url` | `str` | URL of the SIE endpoint (e.g. `http://localhost:8080`) |
|
||||
|
||||
## Usage {#usage}
|
||||
|
||||
```py Python icon=Python
|
||||
import lancedb
|
||||
from lancedb.embeddings import get_registry
|
||||
from lancedb.pydantic import LanceModel, Vector
|
||||
import sie_lancedb # registers "sie" and "sie-multivector"
|
||||
|
||||
sie = get_registry().get("sie").create(
|
||||
model="BAAI/bge-m3",
|
||||
base_url="http://localhost:8080",
|
||||
)
|
||||
|
||||
class Documents(LanceModel):
|
||||
text: str = sie.SourceField()
|
||||
vector: Vector(sie.ndims()) = sie.VectorField()
|
||||
|
||||
db = lancedb.connect("~/.lancedb")
|
||||
table = db.create_table("docs", schema=Documents, mode="overwrite")
|
||||
|
||||
table.add([
|
||||
{"text": "Machine learning is a subset of AI."},
|
||||
{"text": "Neural networks use multiple layers."},
|
||||
{"text": "Python is popular for ML development."},
|
||||
])
|
||||
|
||||
results = table.search("What is deep learning?").limit(3).to_list()
|
||||
```
|
||||
|
||||
LanceDB handles embedding generation for both inserts and queries automatically, based on the `SourceField` / `VectorField` declarations on the schema.
|
||||
|
||||
## Hybrid search with reranker {#hybrid-search-with-reranker}
|
||||
|
||||
`SIEReranker` plugs into LanceDB's hybrid search pipeline. It uses SIE's cross-encoder `score()` to rerank combined vector + full-text search results. You need a full-text search index on the column first:
|
||||
|
||||
```py Python icon=Python
|
||||
from sie_lancedb import SIEReranker
|
||||
|
||||
# Create FTS index for hybrid search
|
||||
table.create_fts_index("text", replace=True)
|
||||
|
||||
results = (
|
||||
table.search("What is deep learning?", query_type="hybrid")
|
||||
.rerank(SIEReranker(model="jinaai/jina-reranker-v2-base-multilingual"))
|
||||
.limit(5)
|
||||
.to_list()
|
||||
)
|
||||
|
||||
for r in results:
|
||||
print(f"{r['_relevance_score']:.3f} {r['text']}")
|
||||
```
|
||||
|
||||
The reranker also works with pure vector or pure FTS search via `.rerank()`.
|
||||
|
||||
## ColBERT and multivector {#colbert-and-multivector}
|
||||
`SIEMultiVectorEmbeddingFunction` (registered as `"sie-multivector"`) works with LanceDB's native `MultiVector` type and MaxSim scoring for ColBERT and ColPali models:
|
||||
|
||||
```py Python icon=Python
|
||||
from lancedb.pydantic import MultiVector
|
||||
|
||||
sie_colbert = get_registry().get("sie-multivector").create(
|
||||
model="jinaai/jina-colbert-v2",
|
||||
base_url="http://localhost:8080",
|
||||
)
|
||||
|
||||
class ColBERTDocs(LanceModel):
|
||||
text: str = sie_colbert.SourceField()
|
||||
vector: MultiVector(sie_colbert.ndims()) = sie_colbert.VectorField()
|
||||
|
||||
table = db.create_table("colbert_docs", schema=ColBERTDocs, mode="overwrite")
|
||||
table.add([{"text": "Machine learning is a subset of AI."}])
|
||||
|
||||
# MaxSim search - query and document multivectors compared token-by-token
|
||||
results = table.search("What is ML?").limit(5).to_list()
|
||||
```
|
||||
|
||||
## Entity extraction {#entity-extraction}
|
||||
|
||||
`SIEExtractor` adds entity extraction to LanceDB's data-enrichment workflows. Extract entities from a text column and merge the results back as a structured Arrow column - enabling filtered search on extracted entities:
|
||||
|
||||
```py Python icon=Python
|
||||
from sie_lancedb import SIEExtractor
|
||||
|
||||
extractor = SIEExtractor(
|
||||
base_url="http://localhost:8080",
|
||||
model="urchade/gliner_multi-v2.1",
|
||||
)
|
||||
|
||||
extractor.enrich_table(
|
||||
table,
|
||||
source_column="text",
|
||||
target_column="entities",
|
||||
labels=["person", "technology", "organization"],
|
||||
id_column="id",
|
||||
)
|
||||
```
|
||||
|
||||
The `entities` column stores structured Arrow data (`list<struct<text, label, score, start, end, bbox>>`), so you can filter on extracted entities in queries.
|
||||
|
||||
## Links {#links}
|
||||
|
||||
- [`sie-lancedb` on PyPI](https://pypi.org/project/sie-lancedb/)
|
||||
- [`@superlinked/sie-lancedb` on npm](https://www.npmjs.com/package/@superlinked/sie-lancedb)
|
||||
- [Superlinked on GitHub](https://github.com/superlinked/sie)
|
||||
- [Superlinked docs](https://superlinked.com/docs)
|
||||
@@ -0,0 +1,60 @@
|
||||
---
|
||||
title: VoyageAI
|
||||
sidebarTitle: VoyageAI
|
||||
---
|
||||
|
||||
import { PyEmbeddingVoyageaiUsage, PyEmbeddingVoyageaiMultimodal } from '/snippets/integrations.mdx';
|
||||
|
||||
Voyage AI provides cutting-edge embedding and rerankers.
|
||||
|
||||
|
||||
Using voyageai API requires voyageai package, which can be installed using `pip install voyageai`. Voyage AI embeddings are used to generate embeddings for text data. The embeddings can be used for various tasks like semantic search, clustering, and classification.
|
||||
You also need to set the `VOYAGE_API_KEY` environment variable to use the VoyageAI API.
|
||||
|
||||
Supported models are:
|
||||
|
||||
- voyage-4-large (best retrieval quality, 1024 default dimensions, supports 256/512/1024/2048)
|
||||
- voyage-4 (balanced general-purpose, 1024 default dimensions, supports 256/512/1024/2048)
|
||||
- voyage-4-lite (optimized for latency/cost, 1024 default dimensions, supports 256/512/1024/2048)
|
||||
- voyage-context-3
|
||||
- voyage-3.5
|
||||
- voyage-3.5-lite
|
||||
- voyage-3
|
||||
- voyage-3-lite
|
||||
- voyage-finance-2
|
||||
- voyage-multilingual-2
|
||||
- voyage-law-2
|
||||
- voyage-code-2
|
||||
- voyage-multimodal-3.5 (multimodal - supports text, images, and video)
|
||||
|
||||
<Info>
|
||||
**Multimodal Model:** `voyage-multimodal-3.5` supports text, images, and video inputs. It outputs 1024-dimensional embeddings by default, configurable via the `output_dimension` parameter (256, 512, 1024, 2048). See the [VoyageAI multimodal embeddings documentation](https://docs.voyageai.com/docs/multimodal-embeddings) for more details.
|
||||
</Info>
|
||||
|
||||
Supported parameters (to be passed in `create` method) are:
|
||||
|
||||
| Parameter | Type | Default Value | Description |
|
||||
|---|---|--------|---------|
|
||||
| `name` | `str` | `None` | The model ID of the model to use. Supported models: voyage-4-large, voyage-4, voyage-4-lite, voyage-3, voyage-3-lite, voyage-3.5, voyage-3.5-lite, voyage-context-3, voyage-finance-2, voyage-multilingual-2, voyage-law-2, voyage-code-2, voyage-multimodal-3.5 |
|
||||
| `input_type` | `str` | `None` | Type of the input text. Default to None. Other options: query, document. |
|
||||
| `truncation` | `bool` | `True` | Whether to truncate the input texts to fit within the context length. |
|
||||
| `output_dimension` | `int` | `None` | Output embedding dimension. Only supported by `voyage-multimodal-3.5`. Valid options: 256, 512, 1024 (default), 2048. |
|
||||
|
||||
|
||||
Usage Example:
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingVoyageaiUsage}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
|
||||
### Multimodal Example {#multimodal-example}
|
||||
|
||||
The `voyage-multimodal-3.5` model can embed text alongside images. You can use image URLs, file paths, or PIL Image objects:
|
||||
|
||||
<CodeGroup>
|
||||
<CodeBlock filename="Python" language="Python" icon="python">
|
||||
{PyEmbeddingVoyageaiMultimodal}
|
||||
</CodeBlock>
|
||||
</CodeGroup>
|
||||
Reference in New Issue
Block a user