ragnar_retrieve {ragnar} | R Documentation |
Retrieve chunks from a RagnarStore
Description
Combines both vss
and bm25
search and returns the
union of chunks retrieved by both methods.
Usage
ragnar_retrieve(store, text, top_k = 3L, ..., deoverlap = TRUE)
Arguments
store |
A |
text |
Character. Query string to match. |
top_k |
Integer. Number of nearest entries to find per method. |
... |
Additional arguments passed to the lower-level retrieval functions. |
deoverlap |
Logical. If |
Value
A tibble
of retrieved chunks. Each row
represents a chunk and always contains a text
column.
Note
The results are not re-ranked after identifying the unique values.
See Also
Other ragnar_retrieve:
ragnar_retrieve_bm25()
,
ragnar_retrieve_vss()
,
ragnar_retrieve_vss_and_bm25()
Examples
## Build a small store with categories
store <- ragnar_store_create(
embed = \(x) ragnar::embed_openai(x, model = "text-embedding-3-small"),
extra_cols = data.frame(category = character()),
version = 1 # store text chunks directly
)
ragnar_store_insert(
store,
data.frame(
category = c(rep("pets", 3), rep("dessert", 3)),
text = c("playful puppy", "sleepy kitten", "curious hamster",
"chocolate cake", "strawberry tart", "vanilla ice cream")
)
)
ragnar_store_build_index(store)
# Top 3 chunks without filtering
ragnar_retrieve(store, "sweet")
# Combine filter with similarity search
ragnar_retrieve(store, "sweet", filter = category == "dessert")
[Package ragnar version 0.2.0 Index]