To store text in a vector database, it must first be converted into a vector,
also known as an embedding. Typically, this vectorization is done by a third
party.
By selecting an embedding model when you create your Upstash Vector database,
you can now upsert and query raw string data when using your database instead of
converting your text to a vector first. The vectorization is done automatically
by your selected model.
Upstash Vector comes with a variety of embedding models that score well in the
MTEB leaderboard, a benchmark
for measuring the performance of embedding models. They support use cases such
as classification, clustering, or retrieval.
You can choose the following general purpose models for dense and hybrid indexes:
The sequence length is not a hard limit. Models truncate the input
appropriately when given a raw text data that would result in more tokens than
the given sequence length. However, we recommend using appropriate models and
not exceeding their sequence length to have more accurate results.
MTEB score for the BAAI/bge-m3 is not fully measured.
For sparse and hybrid indexes, on the following models can be selected:
To start using embedding models, create the index with a model of your choice.
Then, you can start upserting and querying raw text data without any extra
setup.
Copy
from upstash_vector import Indexindex = Index( url="UPSTASH_VECTOR_REST_URL", token="UPSTASH_VECTOR_REST_TOKEN",)index.upsert( [("id-0", "Upstash is a serverless data platform.", {"field": "value"})],)
Copy
from upstash_vector import Indexindex = Index( url="UPSTASH_VECTOR_REST_URL", token="UPSTASH_VECTOR_REST_TOKEN",)index.upsert( [("id-0", "Upstash is a serverless data platform.", {"field": "value"})],)
Copy
import { Index } from "@upstash/vector"const index = new Index({ url: "UPSTASH_VECTOR_REST_URL", token: "UPSTASH_VECTOR_REST_TOKEN",})await index.upsert({ id: "id-0", data: "Upstash is a serverless data platform.", metadata: { field: "value", },})
Copy
package mainimport ( "github.com/upstash/vector-go")func main() { index := vector.NewIndex("UPSTASH_VECTOR_REST_URL", "UPSTASH_VECTOR_REST_TOKEN") index.UpsertData(vector.UpsertData{ Id: "id-0", Data: "Upstash is a serverless data platform.", Metadata: map[string]any{"field": "value"}, })}
Copy
use Upstash\Vector\Index;use Upstash\Vector\DataUpsert;$index = new Index( url: 'UPSTASH_VECTOR_REST_URL', token: 'UPSTASH_VECTOR_REST_TOKEN',);$index->upsertData(new DataUpsert( id: 'id-0', data: 'Upstash is a serverless data platform.', metadata: [ 'field' => 'value', ],));
Copy
curl $UPSTASH_VECTOR_REST_URL/upsert-data \ -X POST \ -H "Authorization: Bearer $UPSTASH_VECTOR_REST_TOKEN" \ -d '{"id": "1", "data": "Upstash is a serverless data platform.", "metadata": {"field": "value"}}'
Copy
from upstash_vector import Indexindex = Index( url="UPSTASH_VECTOR_REST_URL", token="UPSTASH_VECTOR_REST_TOKEN",)index.query( data="What is Upstash?", top_k=1, include_metadata=True,)
Copy
from upstash_vector import Indexindex = Index( url="UPSTASH_VECTOR_REST_URL", token="UPSTASH_VECTOR_REST_TOKEN",)index.query( data="What is Upstash?", top_k=1, include_metadata=True,)
Copy
import { Index } from "@upstash/vector"const index = new Index({ url: "UPSTASH_VECTOR_REST_URL", token: "UPSTASH_VECTOR_REST_TOKEN",})await index.query({ data: "What is Upstash?", topK: 1, includeMetadata: true,})
Copy
package mainimport ( "github.com/upstash/vector-go")func main() { index := vector.NewIndex("UPSTASH_VECTOR_REST_URL", "UPSTASH_VECTOR_REST_TOKEN") index.QueryData(vector.QueryData{ Data: "What is Upstash?", TopK: 1, IncludeMetadata: true, })}
Copy
use Upstash\Vector\Index;use Upstash\Vector\DataQuery;$index = new Index( url: 'UPSTASH_VECTOR_REST_URL', token: 'UPSTASH_VECTOR_REST_TOKEN',);$index->queryData(new DataQuery( data: 'What is Upstash?', topK: 1, includeMetadata: true,));