Embeddings
SvectorDB provides an API to calculate embeddings for text and images using popular models
Embeddings are a way to represent various entities, such as text or images, as an array of numbers. The distance between these arrays can be used to measure the similarity between the entities. For example, the cosine similarity between two text embeddings can be used to measure the similarity between two pieces of text.
Supported Models
Model | Name | Text | Images | Notes |
---|---|---|---|---|
sentence-transformers/all-MiniLM-L6-v2 | ALL_MINILM_L6_V2 | Yes | No | |
openai/clip-vit-base-patch32 | CLIP_VIT_BASE_PATH32 | Yes | Yes | Embeds text and images into a common space |
Please reach out to us if you would like to see support for additional models
Usage
Text Embeddings
To calculate text embeddings, ensure that the input
object contains the text
key with the text you want to embed.
- JavaScript
- Python
client.embed({
databaseId: databaseId,
model: EmbeddingModel.ALL_MINILM_L6_V2,
input: {
text: 'The quick brown fox jumps over the lazy dog.',
},
})
client.embed(EmbedInput(
database_id=databaseId,
model=EmbeddingModel.ALL_MINILM_L6_V2,
input=EmbeddingInputText("The quick brown fox jumps over the lazy dog.")
))
Image Embeddings
To calculate image embeddings, ensure that the input
object contains the image
key with the byte array of the image you want to embed. Images must be 6 MB or less in size. Images are expected to be in PNG or JPEG format.
- JavaScript
- Python
client.embed({
databaseId: databaseId,
model: EmbeddingModel.CLIP_VIT_BASE_PATH32,
input: {
image: Buffer.from(...)
},
})
client.embed(EmbedInput(
database_id=databaseId,
model=EmbeddingModel.CLIP_VIT_BASE_PATH32,
input=EmbeddingInputImage(bytes(...))
))
Pricing
Embeddings are currently available free of charge while in beta.