LitBench-UI / src /tasks /intro_2_abs.py
Andreas99's picture
Upload 22 files
908351f verified
"""
Generate the abstract of a paper based on its introduction section.
Args:
usr_prompt (str): The user-provided prompt containing the introduction section of the paper.
template (dict): A dictionary containing the template for generating the abstract.
context_window (int): The maximum length of the context window for the prompt input.
Returns:
str: The generated abstract based on the introduction section.
"""
def intro_2_abs(usr_prompt, template, context_window, has_predefined_template=False):
instruction = "Please generate the abstract of paper based on its introduction section."
# Reduce it to make it fit
prompt_input = usr_prompt[:int(context_window*2)]
if has_predefined_template:
res = [
{"role": "system", "content": instruction},
{"role": "user", "content": prompt_input},
]
else:
res = template["prompt_input"].format(instruction=instruction, input=prompt_input)
return res