Skip to contents

This function generates concise summaries for each article in a given data frame, using the specified language model (LLM). The summaries are generated based on the prompts previously added to the data frame.

Usage

add_summary(article, model = "llama3.1", host = NULL)

Arguments

article

A data frame or tibble containing at least a "prompt" column, which is created using build_prompt() or add_prompt().

model

Character string. The name of the LLM model to use for generating summaries. Default is "llama3.1".

host

Character string or NULL. The host to be used for the ollamar::generate function. Default is NULL.

Value

A modified data frame of class article_summary, including an additional column "summary" containing the generated summaries.

Details

The function iterates over each article and generates a summary using the specified LLM model. A progress bar is shown to track the summarization process. Any newlines within the text fields are removed to ensure clean formatting. This function is typically used after applying add_prompt() to prepare a dataset for summarization.

The progress bar updates for each article as the summaries are being generated. The final summary column will contain the output of the summarization process, ready for further processing or analysis.

Examples

if (FALSE) { # \dontrun{
papers <- get_article(journal = "Nature Medicine")
papers_with_prompts <- add_prompt(papers, nsentences = 3)
summarized_papers <- add_summary(papers_with_prompts)
} # }