pub struct OnnxEmbeddingProvider { /* private fields */ }Expand description
A MiniLM-class sentence-embedding model, in this process.
Implementations§
Source§impl OnnxEmbeddingProvider
impl OnnxEmbeddingProvider
Sourcepub async fn load(config: OnnxProviderConfig) -> Result<Self, OnnxLoadError>
pub async fn load(config: OnnxProviderConfig) -> Result<Self, OnnxLoadError>
Load the artifacts and open a session.
§The hang this guards against
ort 2.0.0-rc.12 hangs forever instead of erroring when the
library at ORT_DYLIB_PATH cannot be loaded — measured in this
repository against a nonexistent path, where neither Session::builder
nor ort::init_from returns in 45 seconds. No pre-flight validation
exists; every entry point funnels through the same lazy init. Since the
hang cannot be interrupted from inside, the blocked thread is
abandoned: a raw std::thread rather than spawn_blocking,
because Tokio joins blocking threads at shutdown and a wedged one would
hang that too. A caller receiving OnnxLoadError::RuntimeHung has
leaked one thread and must terminate the process rather than retry.
See gears/file-parser/file-parser/src/gear.rs for the same mitigation
and the measurements behind it.
§Errors
Unreadable artifacts, an unloadable tokenizer, a session that refuses to open, or the runtime hang above.
Trait Implementations§
Source§impl EmbeddingProviderV1 for OnnxEmbeddingProvider
impl EmbeddingProviderV1 for OnnxEmbeddingProvider
Source§fn embedding_space(&self) -> &EmbeddingSpaceId
fn embedding_space(&self) -> &EmbeddingSpaceId
fn dimension(&self) -> u32
fn embed<'life0, 'async_trait>(
&'life0 self,
req: EmbedRequest,
) -> Pin<Box<dyn Future<Output = Result<EmbedResponse, EmbeddingProviderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), EmbeddingProviderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !Freeze for OnnxEmbeddingProvider
impl !RefUnwindSafe for OnnxEmbeddingProvider
impl !UnwindSafe for OnnxEmbeddingProvider
impl Send for OnnxEmbeddingProvider
impl Sync for OnnxEmbeddingProvider
impl Unpin for OnnxEmbeddingProvider
impl UnsafeUnpin for OnnxEmbeddingProvider
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