Skip to contents

Projects query into the same vector space produced by embed_nodes(), using the vocabulary and TF-IDF transformer stored in model. For the "ollama" and "openai" backends the same API call is made for the query as for the document nodes.

Usage

embed_query(query, model, method = c("tfidf", "ollama", "openai"))

Arguments

query

Character(1). The free-text query string.

model

The model element returned by embed_nodes().

method

Character(1). Must match the method used when building the model. One of "tfidf", "ollama", or "openai".

Value

A numeric vector in the same vector space as the stored node embeddings. Returns a zero-length numeric if model is NULL.

Examples

if (FALSE) { # \dontrun{
result <- embed_nodes(nodes)
qvec   <- embed_query("how are models evaluated?", result$model)
} # }