Class: Pikuri::VectorDb::Reranker::Hit

Inherits:
Data
  • Object
show all
Defined in:
lib/pikuri/vector_db/reranker/hit.rb

Overview

A single rerank result: the position of the document in the input array + the cross-encoder’s relevance score for it. Returned in descending score order from any reranker’s #rerank method.

Fields

  • indexInteger, the position in the original documents array passed to #rerank. Callers use this to look up the document text + metadata they already hold.

  • scoreFloat, the model’s relevance score. Range is model-dependent: Cohere returns [0.0, 1.0] via a logistic head; raw cross-encoder logits can range further. Treat the absolute values as opaque — use them for ordering, not for thresholding (a “0.5 cutoff” rule means different things to different models).

Why a Data.define

Same convention as Backend::Result. A tuple [index, score] or a {index:, score:} Hash works at runtime, but hit.index / hit.score reads cleaner at call sites and value-equality is occasionally useful in specs.

Instance Attribute Summary collapse

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index

Returns:

  • (Object)

    the current value of index



32
33
34
# File 'lib/pikuri/vector_db/reranker/hit.rb', line 32

def index
  @index
end

#scoreObject (readonly)

Returns the value of attribute score

Returns:

  • (Object)

    the current value of score



32
33
34
# File 'lib/pikuri/vector_db/reranker/hit.rb', line 32

def score
  @score
end