Vespa Cloud instance
or a local
Docker instance.
Here, we will create a new Vespa application and deploy that using Docker.Creating a Vespa application‚ÄãFirst, we need to create an application package:from vespa.package import ApplicationPackage, Field, RankProfileapp_package = ApplicationPackage(name="testapp")app_package.schema.add_fields(    Field(name="text", type="string", indexing=["index", "summary"], index="enable-bm25"),    Field(name="embedding", type="tensor<float>(x[384])",          indexing=["attribute", "summary"],          attribute=[f"distance-metric: angular"]),)app_package.schema.add_rank_profile(    RankProfile(name="default",                first_phase="closeness(field, embedding)",                inputs=[("query(query_embedding)", "tensor<float>(x[384])")]                ))This sets up a Vespa application with a schema for each document that contains
two fields: text for holding the document text and embedding for holding
the embedding vector. The text field is set up to use a BM25 index for
efficient text retrieval, and we'll see how to use this and hybrid search a
bit later.The embedding field is set up with a vector of length 384 to hold the
embedding representation of the text. See
Vespa's Tensor Guide
for more on tensors in Vespa.Lastly, we add a rank profile to
instruct Vespa how to order documents. Here we set this up with a
nearest neighbor search.Now we can deploy this application locally:from vespa.deployment import VespaDockervespa_docker = VespaDocker()vespa_app = vespa_docker.deploy(application_package=app_package)This deploys and creates a connection to a Vespa service. In case you
already have a Vespa application running, for instance in the cloud,
Vespa is a fully featured search engine and vector database. It supports vector search (ANN), lexical search, and search in structured data, all in the same query.
Vespa is a fully featured search engine and vector database. It supports vector search (ANN), lexical search, and search in structured data, all in the same query. ->: Vespa Cloud instance
or a local
Docker instance.
Here, we will create a new Vespa application and deploy that using Docker.Creating a Vespa application‚ÄãFirst, we need to create an application package:from vespa.package import ApplicationPackage, Field, RankProfileapp_package = ApplicationPackage(name="testapp")app_package.schema.add_fields(    Field(name="text", type="string", indexing=["index", "summary"], index="enable-bm25"),    Field(name="embedding", type="tensor<float>(x[384])",          indexing=["attribute", "summary"],          attribute=[f"distance-metric: angular"]),)app_package.schema.add_rank_profile(    RankProfile(name="default",                first_phase="closeness(field, embedding)",                inputs=[("query(query_embedding)", "tensor<float>(x[384])")]                ))This sets up a Vespa application with a schema for each document that contains
two fields: text for holding the document text and embedding for holding
the embedding vector. The text field is set up to use a BM25 index for
efficient text retrieval, and we'll see how to use this and hybrid search a
bit later.The embedding field is set up with a vector of length 384 to hold the
embedding representation of the text. See
Vespa's Tensor Guide
for more on tensors in Vespa.Lastly, we add a rank profile to
instruct Vespa how to order documents. Here we set this up with a
nearest neighbor search.Now we can deploy this application locally:from vespa.deployment import VespaDockervespa_docker = VespaDocker()vespa_app = vespa_docker.deploy(application_package=app_package)This deploys and creates a connection to a Vespa service. In case you
already have a Vespa application running, for instance in the cloud,