pub enum Embedder {
HuggingFace(Embedder),
OpenAi(Embedder),
UserProvided(Embedder),
Ollama(Embedder),
Rest(Embedder),
Composite(Embedder),
}
Expand description
An embedder can be used to transform text into embeddings.
Variants§
HuggingFace(Embedder)
An embedder based on running local models, fetched from the Hugging Face Hub.
OpenAi(Embedder)
An embedder based on making embedding queries against the OpenAI API.
UserProvided(Embedder)
An embedder based on the user providing the embeddings in the documents and queries.
Ollama(Embedder)
An embedder based on making embedding queries against an https://ollama.com embedding server.
Rest(Embedder)
An embedder based on making embedding queries against a generic JSON/REST embedding server.
Composite(Embedder)
An embedder composed of an embedder at search time and an embedder at indexing time.
Implementations§
Source§impl Embedder
impl Embedder
Sourcepub fn new(
options: EmbedderOptions,
cache_cap: usize,
) -> Result<Self, NewEmbedderError>
pub fn new( options: EmbedderOptions, cache_cap: usize, ) -> Result<Self, NewEmbedderError>
Spawns a new embedder built from its options.
Sourcepub fn embed_search(
&self,
text: &str,
deadline: Option<Instant>,
) -> Result<Embedding, EmbedError>
pub fn embed_search( &self, text: &str, deadline: Option<Instant>, ) -> Result<Embedding, EmbedError>
Embed in search context
Sourcepub fn embed_index(
&self,
text_chunks: Vec<Vec<String>>,
threads: &ThreadPoolNoAbort,
) -> Result<Vec<Vec<Embedding>>, EmbedError>
pub fn embed_index( &self, text_chunks: Vec<Vec<String>>, threads: &ThreadPoolNoAbort, ) -> Result<Vec<Vec<Embedding>>, EmbedError>
Embed multiple chunks of texts.
Each chunk is composed of one or multiple texts.
Sourcepub fn embed_index_ref(
&self,
texts: &[&str],
threads: &ThreadPoolNoAbort,
) -> Result<Vec<Embedding>, EmbedError>
pub fn embed_index_ref( &self, texts: &[&str], threads: &ThreadPoolNoAbort, ) -> Result<Vec<Embedding>, EmbedError>
Non-owning variant of Self::embed_index
.
Sourcepub fn chunk_count_hint(&self) -> usize
pub fn chunk_count_hint(&self) -> usize
Indicates the preferred number of chunks to pass to [Self::embed_chunks
]
Sourcepub fn prompt_count_in_chunk_hint(&self) -> usize
pub fn prompt_count_in_chunk_hint(&self) -> usize
Indicates the preferred number of texts in a single chunk passed to [Self::embed
]
Sourcepub fn dimensions(&self) -> usize
pub fn dimensions(&self) -> usize
Indicates the dimensions of a single embedding produced by the embedder.
Sourcepub fn distribution(&self) -> Option<DistributionShift>
pub fn distribution(&self) -> Option<DistributionShift>
An optional distribution used to apply an affine transformation to the similarity score of a document.
pub fn uses_document_template(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Embedder
impl !RefUnwindSafe for Embedder
impl Send for Embedder
impl Sync for Embedder
impl Unpin for Embedder
impl !UnwindSafe for Embedder
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more