Class: EvalRuby::Embedders::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/eval_ruby/embedders/base.rb

Overview

Abstract base class for text embedders. Subclasses must implement #call to convert a batch of strings into a batch of float vectors, and #model to surface the model identifier used (shown in metric details).

Direct Known Subclasses

OpenAI

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Base

Returns a new instance of Base.

Parameters:



11
12
13
# File 'lib/eval_ruby/embedders/base.rb', line 11

def initialize(config)
  @config = config
end

Instance Method Details

#call(texts) ⇒ Array<Array<Float>>

Embeds a batch of texts.

Parameters:

  • texts (Array<String>)

    inputs to embed

Returns:

  • (Array<Array<Float>>)

    one vector per input, in the same order

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/eval_ruby/embedders/base.rb', line 19

def call(texts)
  raise NotImplementedError, "#{self.class}#call must be implemented"
end

#modelString

Returns model identifier (e.g. "text-embedding-3-small").

Returns:

  • (String)

    model identifier (e.g. "text-embedding-3-small")

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/eval_ruby/embedders/base.rb', line 24

def model
  raise NotImplementedError, "#{self.class}#model must be implemented"
end