Class: Noiseless::AST::Hybrid
Overview
Hybrid search node combining text and vector search Supports weighted combination of BM25 text scores and kNN vector scores
Instance Attribute Summary collapse
-
#text_query ⇒ Object
readonly
Returns the value of attribute text_query.
-
#text_weight ⇒ Object
readonly
Returns the value of attribute text_weight.
-
#vector ⇒ Object
readonly
Returns the value of attribute vector.
-
#vector_weight ⇒ Object
readonly
Returns the value of attribute vector_weight.
Instance Method Summary collapse
- #balanced? ⇒ Boolean
-
#initialize(text_query, vector, text_weight: 0.5, vector_weight: 0.5) ⇒ Hybrid
constructor
A new instance of Hybrid.
- #text_dominant? ⇒ Boolean
- #vector_dominant? ⇒ Boolean
Methods inherited from Node
Constructor Details
#initialize(text_query, vector, text_weight: 0.5, vector_weight: 0.5) ⇒ Hybrid
Returns a new instance of Hybrid.
14 15 16 17 18 19 20 |
# File 'lib/noiseless/ast/hybrid.rb', line 14 def initialize(text_query, vector, text_weight: 0.5, vector_weight: 0.5) super() @text_query = text_query @vector = vector @text_weight = text_weight @vector_weight = vector_weight end |
Instance Attribute Details
#text_query ⇒ Object (readonly)
Returns the value of attribute text_query.
8 9 10 |
# File 'lib/noiseless/ast/hybrid.rb', line 8 def text_query @text_query end |
#text_weight ⇒ Object (readonly)
Returns the value of attribute text_weight.
8 9 10 |
# File 'lib/noiseless/ast/hybrid.rb', line 8 def text_weight @text_weight end |
#vector ⇒ Object (readonly)
Returns the value of attribute vector.
8 9 10 |
# File 'lib/noiseless/ast/hybrid.rb', line 8 def vector @vector end |
#vector_weight ⇒ Object (readonly)
Returns the value of attribute vector_weight.
8 9 10 |
# File 'lib/noiseless/ast/hybrid.rb', line 8 def vector_weight @vector_weight end |
Instance Method Details
#balanced? ⇒ Boolean
22 23 24 |
# File 'lib/noiseless/ast/hybrid.rb', line 22 def balanced? @text_weight == @vector_weight end |
#text_dominant? ⇒ Boolean
26 27 28 |
# File 'lib/noiseless/ast/hybrid.rb', line 26 def text_dominant? @text_weight > @vector_weight end |
#vector_dominant? ⇒ Boolean
30 31 32 |
# File 'lib/noiseless/ast/hybrid.rb', line 30 def vector_dominant? @vector_weight > @text_weight end |