Class: Phronomy::Embeddings::Base
- Inherits:
-
Object
- Object
- Phronomy::Embeddings::Base
- Defined in:
- lib/phronomy/embeddings/base.rb
Overview
Abstract interface for embedding adapters.
Concrete implementations must override #embed and return a vector
as an +Array
Direct Known Subclasses
Instance Method Summary collapse
-
#embed(text, cancellation_token = nil) ⇒ Array<Float>
Embed the given text and return a vector representation.
-
#embed_async(text, cancellation_token = nil, timeout: nil) ⇒ BlockingAdapterPool::PendingOperation
Submits an #embed call to BlockingAdapterPool and returns a BlockingAdapterPool::PendingOperation.
Instance Method Details
#embed(text, cancellation_token = nil) ⇒ Array<Float>
Embed the given text and return a vector representation.
16 17 18 19 |
# File 'lib/phronomy/embeddings/base.rb', line 16 def (text, cancellation_token = nil) cancellation_token&.raise_if_cancelled! raise NotImplementedError, "#{self.class}#embed is not implemented" end |
#embed_async(text, cancellation_token = nil, timeout: nil) ⇒ BlockingAdapterPool::PendingOperation
Submits an #embed call to BlockingAdapterPool and returns a BlockingAdapterPool::PendingOperation.
29 30 31 32 33 34 35 36 |
# File 'lib/phronomy/embeddings/base.rb', line 29 def (text, cancellation_token = nil, timeout: nil) Phronomy::Runtime.instance.blocking_io.submit( timeout: timeout, cancellation_token: cancellation_token ) do (text, cancellation_token) end end |