Class: Leann::Embedding::Base
- Inherits:
-
Object
- Object
- Leann::Embedding::Base
- Defined in:
- lib/leann/embedding/base.rb
Overview
Base class for embedding providers
Subclasses must implement:
-
#compute(texts) -> Array<Array<Float>>
Instance Attribute Summary collapse
-
#dimensions ⇒ Integer?
readonly
Embedding dimensions.
-
#model ⇒ String
readonly
Model name.
Instance Method Summary collapse
-
#compute(texts) ⇒ Array<Array<Float>>
Compute embeddings for a list of texts.
-
#compute_one(text) ⇒ Array<Float>
Compute embedding for a single text.
-
#initialize(model:) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(model:) ⇒ Base
Returns a new instance of Base.
18 19 20 21 |
# File 'lib/leann/embedding/base.rb', line 18 def initialize(model:) @model = model @dimensions = nil end |
Instance Attribute Details
#dimensions ⇒ Integer? (readonly)
Returns Embedding dimensions.
15 16 17 |
# File 'lib/leann/embedding/base.rb', line 15 def dimensions @dimensions end |
#model ⇒ String (readonly)
Returns Model name.
12 13 14 |
# File 'lib/leann/embedding/base.rb', line 12 def model @model end |
Instance Method Details
#compute(texts) ⇒ Array<Array<Float>>
Compute embeddings for a list of texts
28 29 30 |
# File 'lib/leann/embedding/base.rb', line 28 def compute(texts) raise NotImplementedError, "Subclasses must implement #compute" end |
#compute_one(text) ⇒ Array<Float>
Compute embedding for a single text
36 37 38 |
# File 'lib/leann/embedding/base.rb', line 36 def compute_one(text) compute([text]).first end |