Skip to contents

Embeds the model's fake answer and retrieves the top-k by cosine.

Usage

morie_kamath_hyde_hypothetical_doc(
  query,
  model,
  embeddings,
  embed = NULL,
  k = 3
)

Arguments

query

Query.

model

Function query -> hypothetical text.

embeddings

Named list or matrix of document embeddings.

embed

Optional text embedder.

k

Depth.

Value

List with retrieved, similarities, hypothetical, estimate.

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"
#>