Sha256: e9a2f555cf798dd7495cf4136b6cabbfd0c1b4ae67a7244be66b91c621322ad9
Contents?: true
Size: 1.56 KB
Versions: 1
Compression:
Stored size: 1.56 KB
Contents
# frozen_string_literal: true require 'json' module Boxcars module VectorStores module Hnswlib class HnswlibConfig attr_reader :metric, :max_item, :dim, :ef_construction, :m # used for search index. # # @param max_item [Integer] The maximum number of items. # # @param metric [String] The distance metric between vectors ('l2', 'dot', or 'cosine'). # # @param ef_construction [Integer] The size of the dynamic list for the nearest neighbors. # It controls the index time/accuracy trade-off. # # @param max_outgoing_connection [Integer] The maximum number of outgoing connections in the graph # # reference: https://yoshoku.github.io/hnswlib.rb/doc/ def initialize( metric: "l2", max_item: 10000, dim: 2, ef_construction: 200, max_outgoing_connection: 16 ) @metric = metric @max_item = max_item @dim = dim @ef_construction = ef_construction @max_outgoing_connection = max_outgoing_connection end def space @metric == 'dot' ? 'ip' : 'l2' end def to_json(*args) JSON.pretty_generate( { metric: @metric, max_item: @max_item, dim: @dim, ef_construction: @ef_construction, max_outgoing_connection: @max_outgoing_connection }, *args ) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
boxcars-0.2.10 | lib/boxcars/boxcar/vector_stores/hnswlib/hnswlib_config.rb |