nikolas-rauscher / ARDI-Scholarly-QALD

Advanced Research Data Infrastructure project template
GNU General Public License v3.0
2 stars 0 forks source link

Prompt Templates #18

Closed nikolas-rauscher closed 2 weeks ago

sefeoglu commented 1 month ago

Some pics from the conference: https://drive.google.com/drive/folders/1EuWR3hkqY9W38Z4VNPyCkLNTRLdrMFFg?usp=drive_link

sefeoglu commented 1 month ago

You should change the following parameters:

prompt-> prompt_template formatted_text -> prompt_text formatted_texts - > prompt_dataset

prompt = {"prompt": prompt_text, "answer":example["answer']}

prompt_dataset.append(prompt)

def formatting_prompts_func(prompt, example):
    """Create a list to store the formatted texts for each item in the example

    Args:
        example (list of dataset): one batch from dataset. each line might consist of prompt context and question
    Returns:
        formatted_texts: formated prompts
    """

    formatted_texts = []

    # Iterate through each example in the batch
    for context, question in zip(example['context'], example['question']):
        # Format each example as a prompt-response pair
        formatted_text = prompt.replace('[question]', question)
        formatted_text = prompt.replace('[context]', "Context: "+context)
        formatted_texts.append(formatted_text)
    # Return the list of formatted texts
    return formatted_texts