
HyDE retrieval via a hypothetical document (Kamath Ch 7)
Source:R/kamath_llm2_native.R
morie_kamath_hyde_hypothetical_doc.RdEmbeds the model's fake answer and retrieves the top-k by cosine.
Examples
morie_kamath_hyde_hypothetical_doc("q", function(q) c(1, 0),
list(d1 = c(1, 0), d2 = c(0, 1)), k = 1)
#> $retrieved
#> [1] "d1"
#>
#> $similarities
#> [1] 1
#>
#> $hypothetical
#> [1] 1 0
#>
#> $estimate
#> [1] 1
#>
#> $k
#> [1] 1
#>
#> $n
#> [1] 2
#>
#> $method
#> [1] "HyDE retrieval via a hypothetical document"
#>