Skip to main content

llm_kernel/embedding/
mod.rs

1//! Embedding provider abstraction.
2//!
3//! Defines a trait for text embedding and provides common utilities.
4//! Concrete backends (local ONNX, candle, OpenAI) are feature-gated.
5//!
6//! ```
7//! use llm_kernel::embedding::{EmbeddingProvider, EmbeddingResult};
8//! ```
9
10pub mod catalog;
11pub mod types;
12
13#[cfg(feature = "embedding-openai")]
14pub mod openai;
15
16#[cfg(any(
17    feature = "embedding-fastembed",
18    feature = "embedding-fastembed-dynamic-linking"
19))]
20pub mod fastembed;
21
22#[cfg(any(
23    feature = "embedding-fastembed",
24    feature = "embedding-fastembed-dynamic-linking"
25))]
26pub mod lazy;
27
28#[cfg(feature = "embedding-fastembed-qwen3")]
29pub mod qwen3;
30
31#[cfg(feature = "embedding-fastembed-nomic-moe")]
32pub mod nomic_moe;
33
34/// Vector index trait and types (zero dependencies).
35pub mod vector_index;
36
37/// Async vector index trait for remote/shared backends (needs `async_trait`).
38pub mod async_vector_index;
39
40/// Qdrant `AsyncVectorIndex` (feature `qdrant`).
41#[cfg(feature = "qdrant")]
42pub mod qdrant;
43
44/// Elasticsearch `AsyncVectorIndex` (feature `elastic`).
45#[cfg(feature = "elastic")]
46pub mod elastic;
47
48#[cfg(feature = "vector-index")]
49pub mod turbovec;
50
51pub use catalog::EmbeddingModel;
52pub use types::{EmbeddingProvider, EmbeddingResult, chunk_batch, cosine_similarity};
53
54#[cfg(feature = "embedding-openai")]
55pub use openai::OpenAIEmbeddingClient;
56
57#[cfg(any(
58    feature = "embedding-fastembed",
59    feature = "embedding-fastembed-dynamic-linking"
60))]
61pub use fastembed::FastembedProvider;
62
63#[cfg(any(
64    feature = "embedding-fastembed",
65    feature = "embedding-fastembed-dynamic-linking"
66))]
67pub use lazy::{EmbeddingCache, LazyFastembedProvider, LazyOpts, ModelState, is_model_cached};
68
69#[cfg(feature = "embedding-fastembed-qwen3")]
70pub use qwen3::Qwen3Provider;
71
72#[cfg(feature = "embedding-fastembed-nomic-moe")]
73pub use nomic_moe::NomicMoeProvider;
74
75/// Re-export `ort` for DirectML execution provider configuration.
76///
77/// Consumers that need `DirectMLExecutionProvider` (e.g. to pass it to
78/// `fastembed::TextInitOptions::with_execution_providers`) should use this
79/// re-export rather than depending on `ort` directly — this ensures the
80/// pinned version stays compatible with fastembed's ONNX Runtime.
81#[cfg(feature = "embedding-fastembed-directml")]
82pub use ort;
83
84pub use async_vector_index::AsyncVectorIndex;
85pub use vector_index::{SearchHit, VectorIndex};
86
87#[cfg(feature = "qdrant")]
88pub use qdrant::QdrantVectorIndex;
89
90#[cfg(feature = "elastic")]
91pub use elastic::ElasticsearchVectorIndex;
92
93#[cfg(feature = "vector-index")]
94pub use turbovec::TurbovecIndex;