Concept · Builds on AIF-C01
Embedding models for text and image
Choose and use Titan, Cohere or SageMaker embedding models, with matching dimensions and one model for index and query.
You know from AI Practitioner
- An embedding turns meaning into a vector of numbers.
- Similar meanings give vectors that are close together.
- Vectors are stored in a vector database and searched by similarity.
Titan Text Embeddings V2
- Input
- Text, up to 8,192 tokens
- Note
- 1,024 dimensions by default
Titan Multimodal Embeddings
- Input
- Text and images
- Note
- One space for both
Cohere Embed
- Input
- Text, v3 short, v4 very long
- Note
- Set document or query type
Your SageMaker model
- Input
- Whatever it supports
- Note
- You host and scale it
| Model | Input | Note |
|---|---|---|
| Titan Text Embeddings V2 | Text, up to 8,192 tokens | 1,024 dimensions by default |
| Titan Multimodal Embeddings | Text and images | One space for both |
| Cohere Embed | Text, v3 short, v4 very long | Set document or query type |
| Your SageMaker model | Whatever it supports | You host and scale it |
1 / 2
Titan Text Embeddings V2
- Input
- Text, up to 8,192 tokens
- Note
- 1,024 dimensions by default
Titan Multimodal Embeddings
- Input
- Text and images
- Note
- One space for both
Cohere Embed
- Input
- Text, v3 short, v4 very long
- Note
- Set document or query type
| Model | Input | Note |
|---|---|---|
| Titan Text Embeddings V2 | Text, up to 8,192 tokens | 1,024 dimensions by default |
| Titan Multimodal Embeddings | Text and images | One space for both |
| Cohere Embed | Text, v3 short, v4 very long | Set document or query type |
2 / 2
Your SageMaker model
- Input
- Whatever it supports
- Note
- You host and scale it
| Model | Input | Note |
|---|---|---|
| Your SageMaker model | Whatever it supports | You host and scale it |
What it is
Amazon Bedrock offers embedding models. Amazon Titan Text Embeddings V2 takes up to 8,192 tokens and returns a 1,024-dimension vector by default, with smaller sizes available to save storage. Titan Multimodal Embeddings maps text and images into the same space, so a text query can find images. Cohere Embed v3 takes short text: up to 512 tokens, about 2,048 characters, per text. Cohere Embed v4 takes very long input, up to about 128,000 tokens, and images too. Both need an input type: search_document when you index, search_query when you search. Other types are classification and clustering. Each model has its own input limit and output size, so check both before you choose.
What it is
The same model must embed documents and queries. Vectors from two models are not comparable, and a vector index has one fixed dimension. Changing the model means re-embedding all data. You call the model with InvokeModel for one request at a time, which suits queries and small loads. For a large corpus, use batch inference or the ingestion job of a knowledge base, which is cheaper and avoids rate limits.
What it is
You can also host your own embedding model on a SageMaker endpoint, for example a sentence transformer from JumpStart or Hugging Face, when you need a specific language or domain model. Built-in algorithms such as BlazingText create word embeddings. Chunk text to fit the model input limit before you embed it.
Remember
- Titan Text Embeddings V2: up to 8,192 tokens, 1,024 dimensions by default.
- Titan Multimodal Embeddings: text and images in one space.
- Cohere Embed: set the input type to document when indexing and query when searching.
- Index and query need the same model. A new model needs new vectors.
Remember
- InvokeModel for real-time requests. Batch or ingestion jobs for big corpora.
- A SageMaker endpoint can host your own embedding model.
On the exam
- “Search images with a text query” points to a multimodal embedding model.
- “Search results are poor after changing the embedding model” points to re-embedding with the same model for index and query.
- “Embed millions of documents cheaply” points to batch inference or a knowledge base ingestion job.
In this task · 1.2
Glue ETL
DataBrew
EMR
Data Wrangler
SageMaker Processing
Athena
Feature Store
- Transforming streaming data
- Feature engineering techniques
- Embedding models for text and image
- Text pre-processing and tokenization
- Preparing documents for RAG
- Masking, redaction and anonymization
- Data for fine-tuning, continued pre-training and distillation