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/// pgvector `AsyncVectorIndex` (feature `pgvector`) — PostgreSQL + pgvector ext.
49#[cfg(feature = "pgvector")]
50pub mod pgvector;
51
52#[cfg(feature = "vector-index")]
53pub mod turbovec;
54
55pub use catalog::EmbeddingModel;
56pub use types::{EmbeddingProvider, EmbeddingResult, chunk_batch, cosine_similarity};
57
58#[cfg(feature = "embedding-openai")]
59pub use openai::OpenAIEmbeddingClient;
60
61#[cfg(any(
62    feature = "embedding-fastembed",
63    feature = "embedding-fastembed-dynamic-linking"
64))]
65pub use fastembed::FastembedProvider;
66
67#[cfg(any(
68    feature = "embedding-fastembed",
69    feature = "embedding-fastembed-dynamic-linking"
70))]
71pub use lazy::{EmbeddingCache, LazyFastembedProvider, LazyOpts, ModelState, is_model_cached};
72
73#[cfg(feature = "embedding-fastembed-qwen3")]
74pub use qwen3::Qwen3Provider;
75
76#[cfg(feature = "embedding-fastembed-nomic-moe")]
77pub use nomic_moe::NomicMoeProvider;
78
79/// Re-export `ort` for DirectML execution provider configuration.
80///
81/// Consumers that need `DirectMLExecutionProvider` (e.g. to pass it to
82/// `fastembed::TextInitOptions::with_execution_providers`) should use this
83/// re-export rather than depending on `ort` directly — this ensures the
84/// pinned version stays compatible with fastembed's ONNX Runtime.
85#[cfg(feature = "embedding-fastembed-directml")]
86pub use ort;
87
88pub use async_vector_index::AsyncVectorIndex;
89pub use vector_index::{SearchHit, VectorIndex};
90
91#[cfg(feature = "qdrant")]
92pub use qdrant::QdrantVectorIndex;
93
94#[cfg(feature = "elastic")]
95pub use elastic::ElasticsearchVectorIndex;
96
97#[cfg(feature = "pgvector")]
98pub use pgvector::PgVectorIndex;
99
100#[cfg(feature = "vector-index")]
101pub use turbovec::TurbovecIndex;