Skip to contents

Builds a structured prompt from an article's title and abstract, designed for input to a language model. The prompt emphasizes extracting key findings, methodology, and tone, and is customizable via instructions.

Usage

build_prompt(
  title,
  abstract,
  nsentences = 3L,
  instructions = c("You will receive a paper's title and abstract as input.",
    "Provide a concise summary with exactly the number of sentences specified.",
    "Do not include introductory phrases or preamble text.",
    "Start directly with the summary; avoid any framing statements.",
    "Focus on key findings, especially of last two sentences of the abstract.",
    "If the abstract is missing, reply explicitly with 'Abstract is not available.'",
    "Highlight any novel contributions, claims, or innovations in the abstract.",
    "Mention main methods or datasets only if explicitly stated in the abstract.", 
    
    "Indicate the strength and tone of evidence.",
    "Optionally,add a one-sentence lay summary for a non-specialist audience.")
)

Arguments

title

Character string. The title of the article.

abstract

Character string. The abstract of the article. If unavailable, include a default message.

nsentences

Integer. The number of sentences required in the summary. Default is 3. Must be a positive whole number.

instructions

Character vector. A set of instructions guiding the summarization. Defaults to a structured template emphasizing main findings, methods, novelty, and tone.

Value

A character string representing a structured prompt for use with a language model summarization tool.

Details

The generated prompt follows a structured format:

  • Lists the instructions (customizable via instructions).

  • States the number of summary sentences required (nsentences).

  • Embeds the article title and abstract.

  • If the abstract is missing or not available, the prompt explicitly states this.

The default instructions vector can be modified to adapt the tone or focus of the summary, such as prioritizing method, dataset, confidence tone, or accessibility for non-specialists.

Examples

title <- "Deep Learning for Genomic Data Analysis"
abstract <- "This study explores deep learning in diverse tasks highlighting predictive accuracy."
prompt <- build_prompt(title, abstract, nsentences = 3)
cat(prompt)
#> You will receive a paper's title and abstract as input. Provide a concise summary with exactly the number of sentences specified. Do not include introductory phrases or preamble text. Start directly with the summary; avoid any framing statements. Focus on key findings, especially of last two sentences of the abstract. If the abstract is missing, reply explicitly with 'Abstract is not available.' Highlight any novel contributions, claims, or innovations in the abstract. Mention main methods or datasets only if explicitly stated in the abstract. Indicate the strength and tone of evidence. Optionally,add a one-sentence lay summary for a non-specialist audience.
#> Number of sentences in summary: 3
#> Title: Deep Learning for Genomic Data Analysis
#> Abstract: This study explores deep learning in diverse tasks highlighting predictive accuracy.