mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-25 17:10:51 +00:00
optional space letters, default true since it seems to perform slightly better
This commit is contained in:
parent
cbf5087887
commit
d0bda3878d
2 changed files with 12 additions and 4 deletions
|
|
@ -13,6 +13,7 @@ class FigletFontConfig:
|
||||||
|
|
||||||
static_word: Optional[str] = None
|
static_word: Optional[str] = None
|
||||||
static_font: Optional[str] = None
|
static_font: Optional[str] = None
|
||||||
|
space_letters: bool = True
|
||||||
|
|
||||||
class FigletFontDataset(ProceduralDataset):
|
class FigletFontDataset(ProceduralDataset):
|
||||||
"""Generates FigletFont tasks"""
|
"""Generates FigletFont tasks"""
|
||||||
|
|
@ -35,6 +36,11 @@ class FigletFontDataset(ProceduralDataset):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
word = self.config.static_word if self.config.static_word is not None else random.choice(wordle_words).upper()
|
word = self.config.static_word if self.config.static_word is not None else random.choice(wordle_words).upper()
|
||||||
|
if(self.config.space_letters):
|
||||||
|
render_word = ' '.join(word)
|
||||||
|
else:
|
||||||
|
render_word = word
|
||||||
|
|
||||||
# These ones are funky and probably aren't good for train/testing
|
# These ones are funky and probably aren't good for train/testing
|
||||||
bad_fonts = [
|
bad_fonts = [
|
||||||
'pyramid', 'runyc', 'assalt_m', 'term', 'tengwar', 'heart_right', 'faces_of', 'heroboti', 'hieroglyphs', 'rainbow_',
|
'pyramid', 'runyc', 'assalt_m', 'term', 'tengwar', 'heart_right', 'faces_of', 'heroboti', 'hieroglyphs', 'rainbow_',
|
||||||
|
|
@ -47,13 +53,14 @@ class FigletFontDataset(ProceduralDataset):
|
||||||
all_fonts = pyfiglet.FigletFont.getFonts()
|
all_fonts = pyfiglet.FigletFont.getFonts()
|
||||||
ok_fonts = list(filter(lambda x: x not in bad_fonts, all_fonts))
|
ok_fonts = list(filter(lambda x: x not in bad_fonts, all_fonts))
|
||||||
chosen_font = self.config.static_font if self.config.static_font is not None else random.choice(ok_fonts)
|
chosen_font = self.config.static_font if self.config.static_font is not None else random.choice(ok_fonts)
|
||||||
figlet_render = pyfiglet.figlet_format(word, font=chosen_font)
|
figlet_render = pyfiglet.figlet_format(render_word, font=chosen_font)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"question": random.choice(self._prompt_templates).format(figlet_render=figlet_render),
|
"question": random.choice(self._prompt_templates).format(figlet_render=figlet_render),
|
||||||
"answer": word,
|
"answer": word,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"font": chosen_font
|
"font": chosen_font,
|
||||||
|
"space_letters": self.config.space_letters
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,7 +83,7 @@ class FigletFontDataset(ProceduralDataset):
|
||||||
return 0.0 # No answer given
|
return 0.0 # No answer given
|
||||||
|
|
||||||
# Normalize case
|
# Normalize case
|
||||||
answer = answer.strip().lower()
|
answer = answer.replace(' ', '').strip().lower()
|
||||||
correct_word = correct_word.strip().lower()
|
correct_word = correct_word.strip().lower()
|
||||||
|
|
||||||
if answer == correct_word:
|
if answer == correct_word:
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ def test_static_figlet():
|
||||||
"""Test basic properties and solution of generated items"""
|
"""Test basic properties and solution of generated items"""
|
||||||
config = FigletFontConfig(
|
config = FigletFontConfig(
|
||||||
static_word="TESTY",
|
static_word="TESTY",
|
||||||
static_font="caligraphy"
|
static_font="caligraphy",
|
||||||
|
space_letters=False
|
||||||
)
|
)
|
||||||
dataset = FigletFontDataset(config)
|
dataset = FigletFontDataset(config)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue