
Top-K few-shot exemplar selection (Kamath Ch 3)
Source:R/kamath_llm2_native.R
morie_kamath_few_shot_exemplar_selection.RdRanks the exemplar pool by cosine or dot similarity to the query;
selected is 0-BASED and the order is STABLE.
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"
#>