liveBook · Manning

Vectorization

As explained in MongoDB 8.0 in Action, Third Edition

An embedding model is a machine learning model that transforms text or other data into numerical vector representations.

Vectorization converts text or other data into numerical vectors using an embedding model. These vectors let a database retrieve items by similarity rather than exact matches. In semantic search, for example, a query can find relevant content even when matching words are not the basis of the search. section 12.1.2

A vector search workflow has four practical steps:

  • Convert the content into embeddings and store them in a vector database. section 12.1.2
  • Convert each query into a vector using the same model used for the stored data. section 12.8
  • Search for nearby vectors and return their associated results. Cosine similarity and Euclidean distance are ways to compare vectors. section 12.1.2
  • For retrieval-augmented generation, retrieve relevant text chunks and add them to the prompt supplied to a language model. section 14.1
Figure 12.2 Vector database operations. Data is processed by an embedding model, transforming it into vector embeddings such as [1.45, ..., 1.01, 0.89, 0.06]. These embeddings are stored in a vector database. Queries from the application are also transformed into embeddings before the database is searched. The most relevant results based on these query embeddings are then retrieved and returned as query results. (Image © MongoDB 2024 CC BY-NC-SA 3.0)
A diagram of embedding model

Description automatically generated

Follow the two paths through the diagram: content and queries are both vectorized before the database compares them and returns results. section 12.1.2

Vector size affects search cost. Atlas Vector Search supports up to 4,096 dimensions, but larger vectors require more comparisons. Consider fewer dimensions only after checking that the embedding-model change does not materially reduce query accuracy. If you change models, create a new index for the new vectors rather than reindexing the existing index during searches. Excluding large vector fields from returned documents can also reduce latency. section 12.7

How MongoDB 8.0 in Action, Third Edition covers it

How deep it goes
Explains the conversion-and-search workflow and gives performance guidance, but does not detail embedding-model internals.
Examples
Uses vector database operations and a document-chunk retrieval workflow that supplies context to a language model.
What you can do after
Apply it via Atlas Vector Search by embedding data and queries with the same model and checking dimension-related performance costs.
How it connects
Connects embedding models and vector databases to semantic search, vector indexes, and retrieval-augmented generation.

Also explained in

Compare how 18 books explain vectorization →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of MongoDB 8.0 in Action, Third Edition. The section links point to the parts of the book it draws on.