#[non_exhaustive]pub enum EmbeddingModel {
BgeSmallEnV15,
BgeBaseEnV15,
BgeLargeEnV15,
MultilingualE5Small,
MultilingualE5Base,
Qwen3Embedding0_6B,
Qwen3Embedding4B,
AllMiniLmL6V2,
ParaphraseMultilingualMiniLmL12V2,
TextEmbedding3Small,
}Expand description
Stable: external consumers may depend on this; breaking changes require a SemVer bump.
Supported embedding models.
This enum represents the embedding models available for text vectorization. Models are categorized as either local (run on-device via lattice-inference) or remote (require API calls).
§Example
use lattice_embed::EmbeddingModel;
let model = EmbeddingModel::default();
assert_eq!(model.dimensions(), 384);
assert!(model.is_local());Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
BgeSmallEnV15
BGE small English v1.5 (384 dimensions) - fast and efficient.
BgeBaseEnV15
BGE base English v1.5 (768 dimensions) - balanced quality/speed.
BgeLargeEnV15
BGE large English v1.5 (1024 dimensions) - highest quality local.
MultilingualE5Small
Multilingual E5 small (384 dimensions) - multilingual, same arch as BGE.
MultilingualE5Base
Multilingual E5 base (768 dimensions) - best multilingual quality/speed.
Qwen3Embedding0_6B
Qwen3-Embedding-0.6B (1024 dimensions) - multilingual, decoder-only, GPU-accelerated.
Qwen3Embedding4B
Qwen3-Embedding-4B (2560 dimensions, MRL-capable) - multilingual, decoder-only, GPU-accelerated.
AllMiniLmL6V2
all-MiniLM-L6-v2 (384 dimensions) - BERT-class, WordPiece tokenizer, sentence-transformers.
ParaphraseMultilingualMiniLmL12V2
paraphrase-multilingual-MiniLM-L12-v2 (384 dimensions) - multilingual, XLM-R base, sentence-transformers.
TextEmbedding3Small
OpenAI text-embedding-3-small (1536 dimensions) - remote API.
Implementations§
Source§impl EmbeddingModel
impl EmbeddingModel
Sourcepub const fn native_dimensions(&self) -> usize
pub const fn native_dimensions(&self) -> usize
Stable: get the native (full-resolution) output dimension of this model’s embeddings.
Returns the model’s intrinsic dimension regardless of any MRL truncation.
For MRL-capable models with a configured truncation, use ModelConfig::dimensions().
Sourcepub const fn dimensions(&self) -> usize
pub const fn dimensions(&self) -> usize
Stable: get the output dimension of this model’s embeddings.
§Example
use lattice_embed::EmbeddingModel;
assert_eq!(EmbeddingModel::BgeSmallEnV15.dimensions(), 384);
assert_eq!(EmbeddingModel::BgeBaseEnV15.dimensions(), 768);
assert_eq!(EmbeddingModel::BgeLargeEnV15.dimensions(), 1024);Sourcepub const fn is_local(&self) -> bool
pub const fn is_local(&self) -> bool
Stable: check if this model can run locally (via lattice-inference).
Sourcepub const fn max_input_tokens(&self) -> usize
pub const fn max_input_tokens(&self) -> usize
Stable: maximum input tokens supported by this model.
Use this for chunking/truncation decisions. Values are conservative to leave room for special tokens.
Reference limits:
- BGE models: 512 tokens
- OpenAI text-embedding-3: 8191 tokens
- Gemini embedding-001: 20000 tokens
Sourcepub const fn query_instruction(&self) -> Option<&'static str>
pub const fn query_instruction(&self) -> Option<&'static str>
Stable: query instruction prefix for asymmetric retrieval.
Some models require different text for queries vs documents (asymmetric retrieval).
-
E5 models (
MultilingualE5Small,MultilingualE5Base): trained with “query: “ / “passage: “ asymmetric prefixes. Omitting the prefix degrades retrieval quality significantly — the model expects them during fine-tuning. -
Qwen3-Embedding models: require an instruction prompt to align the decoder embedding space for retrieval tasks.
-
BGE / MiniLM models: trained with contrastive objectives on raw text; no prefix needed.
Returns Some(prefix) if the query text should be wrapped as
"{prefix}{query}" before embedding. Returns None for models that
don’t need instruction prompting.
Sourcepub const fn document_instruction(&self) -> Option<&'static str>
pub const fn document_instruction(&self) -> Option<&'static str>
Stable: document instruction prefix for asymmetric retrieval.
Some models use different prompts for documents vs queries.
Returns Some(prefix) if the document text should be wrapped as
"{prefix}{text}" before embedding at storage time.
Sourcepub const fn model_id(&self) -> &'static str
pub const fn model_id(&self) -> &'static str
Stable: get the model identifier (HuggingFace ID or provider/model).
Sourcepub const fn supports_output_dim(&self) -> bool
pub const fn supports_output_dim(&self) -> bool
Stable: whether this model supports configurable output dimensions (MRL/Matryoshka).
Sourcepub const fn key_version(&self) -> &'static str
pub const fn key_version(&self) -> &'static str
Stable: embedding key revision string for this model family.
Trait Implementations§
Source§impl Clone for EmbeddingModel
impl Clone for EmbeddingModel
Source§fn clone(&self) -> EmbeddingModel
fn clone(&self) -> EmbeddingModel
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EmbeddingModel
impl Debug for EmbeddingModel
Source§impl Default for EmbeddingModel
impl Default for EmbeddingModel
Source§fn default() -> EmbeddingModel
fn default() -> EmbeddingModel
Source§impl<'de> Deserialize<'de> for EmbeddingModel
impl<'de> Deserialize<'de> for EmbeddingModel
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for EmbeddingModel
impl Display for EmbeddingModel
Source§impl FromStr for EmbeddingModel
impl FromStr for EmbeddingModel
Source§impl Hash for EmbeddingModel
impl Hash for EmbeddingModel
Source§impl PartialEq for EmbeddingModel
impl PartialEq for EmbeddingModel
Source§fn eq(&self, other: &EmbeddingModel) -> bool
fn eq(&self, other: &EmbeddingModel) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for EmbeddingModel
impl Serialize for EmbeddingModel
impl Copy for EmbeddingModel
impl Eq for EmbeddingModel
impl StructuralPartialEq for EmbeddingModel
Auto Trait Implementations§
impl Freeze for EmbeddingModel
impl RefUnwindSafe for EmbeddingModel
impl Send for EmbeddingModel
impl Sync for EmbeddingModel
impl Unpin for EmbeddingModel
impl UnsafeUnpin for EmbeddingModel
impl UnwindSafe for EmbeddingModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.