Class: Kreuzberg::Config::Embedding

Inherits:
Object
  • Object
show all
Defined in:
lib/kreuzberg/config.rb

Overview

Embedding model configuration for document chunking

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model: { type: :preset, name: 'balanced' }, normalize: true, batch_size: 32, show_download_progress: false, cache_dir: nil) ⇒ Embedding

Returns a new instance of Embedding.



255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/kreuzberg/config.rb', line 255

def initialize(
  model: { type: :preset, name: 'balanced' },
  normalize: true,
  batch_size: 32,
  show_download_progress: false,
  cache_dir: nil
)
  @model = normalize_model(model)
  @normalize = boolean_or_nil(normalize)
  @batch_size = batch_size&.to_i
  @show_download_progress = boolean_or_nil(show_download_progress)
  @cache_dir = cache_dir&.to_s
end

Instance Attribute Details

#batch_sizeObject (readonly)

Returns the value of attribute batch_size.



253
254
255
# File 'lib/kreuzberg/config.rb', line 253

def batch_size
  @batch_size
end

#cache_dirObject (readonly)

Returns the value of attribute cache_dir.



253
254
255
# File 'lib/kreuzberg/config.rb', line 253

def cache_dir
  @cache_dir
end

#modelObject (readonly)

Returns the value of attribute model.



253
254
255
# File 'lib/kreuzberg/config.rb', line 253

def model
  @model
end

#normalizeObject (readonly)

Returns the value of attribute normalize.



253
254
255
# File 'lib/kreuzberg/config.rb', line 253

def normalize
  @normalize
end

#show_download_progressObject (readonly)

Returns the value of attribute show_download_progress.



253
254
255
# File 'lib/kreuzberg/config.rb', line 253

def show_download_progress
  @show_download_progress
end

Instance Method Details

#to_hObject



269
270
271
272
273
274
275
276
277
# File 'lib/kreuzberg/config.rb', line 269

def to_h
  {
    model: @model,
    normalize: @normalize,
    batch_size: @batch_size,
    show_download_progress: @show_download_progress,
    cache_dir: @cache_dir
  }.compact
end