An AI embedding is a numerical vector representation of data (like text, images, or audio) that captures its meaning and context, allowing AI models to understand and work with complex, unstructured information. By converting diverse data types into numbers, embeddings place similar items close together in a high-dimensional space, making it easier for algorithms to find patterns, perform searches, and group information based on semantic relationships rather than just keyword matches. Dartantic has full support for creating embeddings using providers that expose embeddings models.Documentation Index
Fetch the complete documentation index at: https://docs.dartantic.ai/llms.txt
Use this file to discover all available pages before exploring further.
Basic Usage
You can turn a string into a embedding using one of theembedXxx methods. The
embedQuery method works on a single string and is generally meant for lookups
(which we’ll see later). The embedDocuments method works on a batch of
strings.
Similarity
There are several ways to do searches with embeddings, many of the advanced ones beyond the scope of this documentation, but one simple, built-in way is via cosine similarity. Cosine similarity is a metric that measures the angle between two non-zero vectors to determine their similarity, with a score of 1 meaning they point in the same direction, 0 meaning they are unrelated, and -1 meaning they point in opposite directions. What this means for embeddings is cosine similarity useful for doing searches: the higher the number, the closer the match.Search Example
It’s pretty typical to useembedDocuments to calculate embeddings for
documents to be searched against via embedQuery like so:
Configuration
Different embedding models from different providers have different options, e.g. it’s common to be able to change the default size of the calculated embeddings vector.Vectors are Provider-Specific
Even though the concept of embeddings and how to use them is the same across providers and many providers calculate embeddings that are the same size, an embedding calculated with one providers, e.g. Google, is NOT compatible with an embedding calcuated with another providers, e.g. OpenAI. You’ll need to track the source and maintain integrity yourself per the requirements of your applications.Examples
Next Steps
- Providers - Embeddings support by provider

