improve template

This commit is contained in:
Zafir Stojanovski 2025-02-16 11:02:51 +01:00
parent c893839954
commit 4b71eb2da9

View file

@ -5,6 +5,23 @@ from typing import Any, Dict, Optional
from ..factory import ProceduralDataset, register_dataset
QUESTION_TEMPALTE = """Your task is, given a list of letters, to form a valid palindrome.
A palindrome is a phrase that reads the same forwards and backwards.
If there are multiple possible answers, only respond with one of them. You must use all the letters provided.
Example:
- Input: Form a valid palindrome using the following letters: a, a, b
- Output: aba
- Explanation:
- The phrase aba reads the same forwards and backwards.
- The output answer is a valid palindrome using all the letters provided.
- The answer is a string, rather than a list of characters.
Now, form a valid palindrome using the following letters: {letters}
"""
@dataclass
class PalindromeConfig:
@ -51,16 +68,8 @@ class PalindromeDataset(ProceduralDataset):
letters = self._generate_palindrome_letters(rng, length)
scrambled_letters = rng.sample(letters, len(letters)) # Scramble the order
palindrome = self._assemble_palindrome(letters)
question_str = (
"Rearrange these letters to form a palindrome. A palindrome is a word, phrase, or sequence that reads the same forward and backward. If there are multiple answers, only respond with one of them.\n\n"
"For example, if the letters are: a, a, b — a valid palindrome is: aba.\n\n"
f"Your letters: {', '.join(scrambled_letters)}\n\n"
"What palindrome can you form from these letters?"
)
return {
"question": question_str,
"question": QUESTION_TEMPALTE.format(letters=", ".join(scrambled_letters)),
"answer": palindrome,
"metadata": {
"letters": scrambled_letters,