llm_custom | R Documentation |
Use a Large Language Model (LLM) to process the provided text using the
instructions from prompt
llm_custom(.data, col, prompt = "", pred_name = ".pred", valid_resps = "")
llm_vec_custom(x, prompt = "", valid_resps = NULL)
.data |
A |
col |
The name of the field to analyze, supports |
prompt |
The prompt to append to each record sent to the LLM |
pred_name |
A character vector with the name of the new column where the prediction will be placed |
valid_resps |
If the response from the LLM is not open, but
deterministic, provide the options in a vector. This function will set to
|
x |
A vector that contains the text to be analyzed |
llm_custom
returns a data.frame
or tbl
object.
llm_vec_custom
returns a vector that is the same length as x
.
library(mall)
data("reviews")
llm_use("ollama", "llama3.2", seed = 100, .silent = TRUE)
my_prompt <- paste(
"Answer a question.",
"Return only the answer, no explanation",
"Acceptable answers are 'yes', 'no'",
"Answer this about the following text, is this a happy customer?:"
)
reviews |>
llm_custom(review, my_prompt)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.