View source: R/llm-summarize.R
llm_summarize | R Documentation |
Use a Large Language Model (LLM) to summarize text
llm_summarize(
.data,
col,
max_words = 10,
pred_name = ".summary",
additional_prompt = ""
)
llm_vec_summarize(x, max_words = 10, additional_prompt = "", preview = FALSE)
.data |
A |
col |
The name of the field to analyze, supports |
max_words |
The maximum number of words that the LLM should use in the summary. Defaults to 10. |
pred_name |
A character vector with the name of the new column where the prediction will be placed |
additional_prompt |
Inserts this text into the prompt sent to the LLM |
x |
A vector that contains the text to be analyzed |
preview |
It returns the R call that would have been used to run the
prediction. It only returns the first record in |
llm_summarize
returns a data.frame
or tbl
object.
llm_vec_summarize
returns a vector that is the same length as x
.
library(mall)
data("reviews")
llm_use("ollama", "llama3.2", seed = 100, .silent = TRUE)
# Use max_words to set the maximum number of words to use for the summary
llm_summarize(reviews, review, max_words = 5)
# Use 'pred_name' to customize the new column's name
llm_summarize(reviews, review, 5, pred_name = "review_summary")
# For character vectors, instead of a data frame, use this function
llm_vec_summarize(
"This has been the best TV I've ever used. Great screen, and sound.",
max_words = 5
)
# To preview the first call that will be made to the downstream R function
llm_vec_summarize(
"This has been the best TV I've ever used. Great screen, and sound.",
max_words = 5,
preview = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.