Class: Noiseless::AST::Vector
Overview
Vector search node for semantic/embedding-based search Used with pgvector in PostgreSQL or knn in OpenSearch
Instance Attribute Summary collapse
-
#distance_metric ⇒ Object
readonly
Returns the value of attribute distance_metric.
-
#embedding ⇒ Object
readonly
Returns the value of attribute embedding.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#k ⇒ Object
readonly
Returns the value of attribute k.
Instance Method Summary collapse
- #dimension ⇒ Object
-
#initialize(field, embedding, k: 10, distance_metric: :cosine) ⇒ Vector
constructor
A new instance of Vector.
Methods inherited from Node
Constructor Details
#initialize(field, embedding, k: 10, distance_metric: :cosine) ⇒ Vector
Returns a new instance of Vector.
14 15 16 17 18 19 20 |
# File 'lib/noiseless/ast/vector.rb', line 14 def initialize(field, , k: 10, distance_metric: :cosine) super() @field = field @embedding = @k = k @distance_metric = distance_metric end |
Instance Attribute Details
#distance_metric ⇒ Object (readonly)
Returns the value of attribute distance_metric.
8 9 10 |
# File 'lib/noiseless/ast/vector.rb', line 8 def distance_metric @distance_metric end |
#embedding ⇒ Object (readonly)
Returns the value of attribute embedding.
8 9 10 |
# File 'lib/noiseless/ast/vector.rb', line 8 def @embedding end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
8 9 10 |
# File 'lib/noiseless/ast/vector.rb', line 8 def field @field end |
#k ⇒ Object (readonly)
Returns the value of attribute k.
8 9 10 |
# File 'lib/noiseless/ast/vector.rb', line 8 def k @k end |
Instance Method Details
#dimension ⇒ Object
22 23 24 |
# File 'lib/noiseless/ast/vector.rb', line 22 def dimension @embedding&.size || 0 end |