Featured image
Infrastructure

Vectorize: Cloudflares Vector Database for Fast AI-powered Applications

avatar

Sven

September 28th, 2023

~ 4 min read

If you're a developer looking to build full-stack, AI-powered applications, then Cloudflare's new vector database offering, Vectorize, is something you need to check out. With Vectorize, you can leverage the power of Cloudflare's global network and start building AI applications right away. And the best part? Vectorize is currently in open beta and available to any developer using Cloudflare Workers.

But what exactly is a vector database and why do you need one? Well, machine learning models can't remember anything beyond what they were trained on. That's where vector databases come in. They capture how an ML model represents data and store it in a way that allows you to compare against future inputs. This means you can use existing ML models and Large Language Models (LLMs) for content they haven't been trained on. And let's face it, training models can be expensive, so being able to leverage existing models is extremely powerful.

To illustrate the need for a vector database like Vectorize, let's imagine a scenario where we don't have one. We want to give context to an ML model or LLM for a semantic search or recommendation task. Without a vector database, we would have to load up our entire dataset every time a query comes in, which is not only time-consuming but also impractical. With Vectorize, we only need to perform this step once and store the resulting vector embeddings in the database. Then, for each user query, we simply retrieve a vector representation and query the vector database for the closest matches. It's much more efficient and practical.

But what makes Vectorize different from a regular database? Vectors are the model's representation of an input, and they play a crucial role in determining similarity between inputs. Vector databases use algorithms like k-nearest neighbors (kNN) to determine vector similarity. This allows for efficient searching across thousands or even hundreds of thousands of vectors with multiple dimensions.

Vectorize not only excels in AI and machine learning use-cases but can also be used for classification and anomaly detection tasks. Whether you need to power content moderation or security alerting, Vectorize has got you covered.

To demonstrate the power of Vectorize, let's take a look at an example of building a recommendation engine for an e-commerce store. By using vector search, we can show relevant products on each product listing page. The code snippet provided in the blog post shows how you can achieve this using Vectorize and Cloudflare Workers AI. It's a simple yet powerful example of the capabilities of Vectorize.

And if you're already using other embedding APIs like OpenAI's Embedding API or Cohere's multilingual model, you can easily bring your own vectors to Vectorize. Just generate your embeddings, insert them into Vectorize, and pass your queries through the model before querying the index.

One of the great things about Vectorize is its pricing model. It's designed to be predictable and cost-effective. You're charged based on the total number of vector dimensions you store and the number of queries against them each month. This makes it easy to estimate costs and scale up as needed.

In conclusion, if you're looking to build AI-powered applications and want a fast and efficient way to leverage existing models, Vectorize is the perfect tool for you. It's easy to use, scalable, and comes with a predictable pricing model.

Workers Free (coming soon)

Workers Paid ($5/month)

Queried vector dimensions included

30M total queried dimensions / month

50M total queried dimensions / month

Stored vector dimensions included

5M stored dimensions / month

10M stored dimensions / month

Additional cost

$0.04 / 1M vector dimensions queried or stored

$0.04 / 1M vector dimensions queried or stored

Pricing is based entirely on what you store and query: (total vector dimensions queried + stored) * dimensions_per_vector * price.

Source: Cloudflare

Links:
Cloudflare Announcement