Skip to contents

Ranks the exemplar pool by cosine or dot similarity to the query; selected is 0-BASED and the order is STABLE.

Usage

morie_kamath_few_shot_exemplar_selection(D, query_embed, K, metric = "cosine")

Arguments

D

Exemplar embedding rows.

query_embed

Query.

K

How many to keep.

metric

"cosine" or "dot".

Value

List with selected, similarities, estimate.

Examples

morie_kamath_few_shot_exemplar_selection(D = c(1, 2, 3, 4, 5, 6, 7, 8), query_embed = 5L, K = 5L)
#> $selected
#> [1] 0 1 2 3 4
#> 
#> $similarities
#> [1] 1 1 1 1 1
#> 
#> $all_similarities
#> [1] 1 1 1 1 1 1 1 1
#> 
#> $estimate
#> [1] 1
#> 
#> $K
#> [1] 5
#> 
#> $metric
#> [1] "cosine"
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "Top-K few-shot exemplar selection by similarity"
#>