Class: RubyLLM::Voyage::Reranking
- Inherits:
-
Struct
- Object
- Struct
- RubyLLM::Voyage::Reranking
- Defined in:
- lib/ruby_llm/voyage/results.rb
Overview
Typed result returned by rerank.
Instance Attribute Summary collapse
-
#input_tokens ⇒ Object
Returns the value of attribute input_tokens.
-
#model ⇒ Object
Returns the value of attribute model.
-
#results ⇒ Object
Returns the value of attribute results.
Instance Method Summary collapse
-
#reorder(collection) ⇒ Array
Reorders the original candidate collection by relevance.
Instance Attribute Details
#input_tokens ⇒ Object
Returns the value of attribute input_tokens
9 10 11 |
# File 'lib/ruby_llm/voyage/results.rb', line 9 def input_tokens @input_tokens end |
#model ⇒ Object
Returns the value of attribute model
9 10 11 |
# File 'lib/ruby_llm/voyage/results.rb', line 9 def model @model end |
#results ⇒ Object
Returns the value of attribute results
9 10 11 |
# File 'lib/ruby_llm/voyage/results.rb', line 9 def results @results end |
Instance Method Details
#reorder(collection) ⇒ Array
Reorders the original candidate collection by relevance.
Pass the same collection whose contents were sent as documents:.
Returns the matching items in reranked order, truncated to top_k
when one was requested.
26 27 28 29 |
# File 'lib/ruby_llm/voyage/results.rb', line 26 def reorder(collection) items = collection.to_a results.map { |result| items.fetch(result.index) } end |