| docling_embed | R Documentation |
Embed a chunk tibble's text with a user-supplied embedding function and
return the tibble with an embedding list-column. doclingr stays
provider-agnostic: you bring the embedder (an OpenAI/Cohere/Ollama API
call, a local sentence-transformers model via reticulate, anything), and this
helper handles batching, validation and tidy assembly.
docling_embed(chunks, embedder, text_column = "text", batch_size = NULL)
chunks |
A tibble of chunks, typically from |
embedder |
A function taking a character vector and returning either a numeric matrix with one row per input, or a list of equal-length numeric vectors. |
text_column |
Name of the column to embed. Defaults to |
batch_size |
Optional integer; if set, |
chunks with an added embedding list-column of numeric vectors,
and an n_dim integer column giving each embedding's length.
docling_chunk()
## Not run:
chunks <- docling_chunk(docling_convert("paper.pdf"), max_tokens = 512)
# Any embedder: here a toy one
embed_fn <- function(txt) matrix(stats::runif(length(txt) * 8), nrow = length(txt))
docling_embed(chunks, embed_fn)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.