Hybrid Search

This page describes the parameters for hybrid search as part of AI libs.

.ai.hybrid.rrf

The .ai.hybrid.rrf function applies reciprocal ranked fusion on search results.

Parameters

Name

Type(s)

Description

results

(real[]; long[])[] | int[][] | long[][]

The list of nearest neighbor results from bm25 or dense search

const

int | long | real | float

The constant term for RRF (typically 60)

Returns

Type

Description

long[]

Re-ranked IDs

Example

q

Copy
 a:101 102 103 104 105;
 b:103 106 101 107 108;
 .ai.hybrid.rrf[(a;b);60];

 101 103 102 106 104 107 105 108

.ai.hybrid.wrrf

The .ai.hybrid.wrrf function applies weighted reciprocal ranked fusion on search results.

Parameters

Name

Type(s)

Description

results

(real[]; long[])[] | int[][] | long[][]

The list of nearest neighbor results from bm25 or dense search

weights

long[]

The list of weightings, same length as results

const

int | long | real | float

The constant term for RRF (typically 60)

Returns

Type

Description

long[]

Re-ranked IDs

Example

q

Copy
 a:101 102 103 104 105;
 b:103 106 101 107 108;
 .ai.hybrid.wrrf[(a;b);1 2;60];

 103 101 106 107 108 102 104 105