embed_ollama {ragnar} | R Documentation |
Embed Text
Description
Embed Text
Usage
embed_ollama(
x,
base_url = "http://localhost:11434",
model = "snowflake-arctic-embed2:568m",
batch_size = 10L
)
embed_openai(
x,
model = "text-embedding-3-small",
base_url = "https://api.openai.com/v1",
api_key = get_envvar("OPENAI_API_KEY"),
dims = NULL,
user = get_user(),
batch_size = 20L
)
Arguments
x |
x can be:
|
base_url |
string, url where the service is available. |
model |
string; model name |
batch_size |
split |
api_key |
resolved using env var |
dims |
An integer, can be used to truncate the embedding to a specific size. |
user |
User name passed via the API. |
Value
If x
is a character vector, then a numeric matrix is returned,
where nrow = length(x)
and ncol = <model-embedding-size>
. If x
is a
data.frame, then a new embedding
matrix "column" is added, containing the
matrix described in the previous sentence.
A matrix of embeddings with 1 row per input string, or a dataframe with an 'embedding' column.
Examples
text <- c("a chunk of text", "another chunk of text", "one more chunk of text")
## Not run:
text |>
embed_ollama() |>
str()
text |>
embed_openai() |>
str()
## End(Not run)