Class: RerankerRuby::RRF

Inherits:
Object
  • Object
show all
Defined in:
lib/reranker_ruby/rrf.rb

Class Method Summary collapse

Class Method Details

.fuse(*ranked_lists, k: 60) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/reranker_ruby/rrf.rb', line 5

def self.fuse(*ranked_lists, k: 60)
  scores = Hash.new(0.0)
  ranked_lists.each do |list|
    list.each_with_index do |id, rank|
      scores[id] += 1.0 / (k + rank + 1)
    end
  end
  scores.sort_by { |_, score| -score }.map(&:first)
end