RRF(Reciprocal Rank Fusion)란?
RRF(Reciprocal Rank Fusion)는 문자 그대로 역수(Reciprocal)를 이용해 순위(Rank)를 혼합(Fusion)하는 알고리즘입니다. 구글에서 만든 알고리즘인데1, 다른 알고리즘보다 낫다고 알려져 있습니다. 구체적으로는 아래와 같은 수식을 이용해 계산하게 됩니다. $$ \text{score}^d_\text{RRF} = \sum_{r \in R} \frac{1}{k+\text{rank}^d_{r}} $$ 수식이 복잡하다면 아래와 같은 파이썬 예제 코드로 생각하셔도 무방합니다. def get_document_rank(ranking_list, target_document): # ranking_list is a list of documents in ranked order # e.g. ['A', 'B', 'C'] return ranking_list.index(target_document) + 1 def calculate_rrf_score(ranking_lists, target_document): # K is a constant factor K = 3 # find rank of document in ranks return sum( [ 1 / (K + get_document_rank(ranking_list, target_document)) for ranking_list in ranking_lists ] ) 예를 들어, A, B, C 세 문서에 대해 다음과 같이 점수를 매겨보았다고 가정해봅시다....