Usage
The#[model] macro specifies which embedding model to use for Embed() calls within a query. This allows you to optimize embeddings for different use cases—such as storing documents versus searching them.
The
#[model] macro overrides the default embedding model configured in your helix.toml file for that specific query.Syntax Reference
The model string follows the format"provider:model-name:task-type":
providerThe embedding service providermodel-nameThe specific model identifiertask-typeTask optimization hint
Supported models
| Provider | Model | Task Type | Notes |
|---|---|---|---|
gemini | gemini-embedding-001 | RETRIEVAL_DOCUMENT OR RETRIEVAL_QUERY | RETRIEVAL_DOCUMENT is the default if no task type is included |
openai | text-embedding-ada-002 | Not Supported | Not recommended |
openai | text-embedding-small | Not Supported | |
openai | text-embedding-large | Not Supported |
Why use different models for storage vs. search?
Many embedding providers offer task-specific optimizations. For example, Gemini’s embedding models support task types that hint whether the text being embedded is a document (to be stored and searched) or a query (used to search documents).RETRIEVAL_DOCUMENT- Optimized for embedding documents that will be stored and retrieved laterRETRIEVAL_QUERY- Optimized for embedding search queries that find relevant documents
Example: Document Storage vs. Search
This example shows how to use different task types for storing clinical notes versus searching them.Best Practices
Use consistent models for the same vector type
Use consistent models for the same vector type
Always use the same embedding model for all queries that operate on the same vector type. Different models produce vectors with different dimensions, which will cause errors.
Match task types to operations
Match task types to operations
Use
RETRIEVAL_DOCUMENT for operations that store data and RETRIEVAL_QUERY for operations that search data.Consider using the default model for simple cases
Consider using the default model for simple cases
If you don’t need task-specific optimization, you can skip the
#[model] macro and use the default model from your config.hx.json.