From 2b3b1a280dcc762d04a4a391c68e7ae7293d1f02 Mon Sep 17 00:00:00 2001 From: "Andreas Koepf (aider)" Date: Fri, 24 Jan 2025 17:07:04 +0100 Subject: [PATCH] refactor: Prevent duplicate child descriptions in family story generation --- reasoning_gym/graphs/family_relationships.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/reasoning_gym/graphs/family_relationships.py b/reasoning_gym/graphs/family_relationships.py index 9a6ba7fa..7131b1fa 100644 --- a/reasoning_gym/graphs/family_relationships.py +++ b/reasoning_gym/graphs/family_relationships.py @@ -218,14 +218,17 @@ class FamilyRelationshipsDataset(ProceduralDataset): if person.spouse and (person.spouse, person) not in couples: couples.add((person, person.spouse)) - # Describe marriages + # Describe marriages and children for each couple + described_children = set() # Track which children have been described for person1, person2 in couples: story_parts.append(f"{person1.name} is married to {person2.name}.") - # Describe parent-child relationships - for person in family: - if person.children: - children_names = [c.name for c in person.children] + # Only describe children once per couple + children = [c for c in person1.children if c not in described_children] + if children: + children_names = [c.name for c in children] + described_children.update(children) # Mark these children as described + if len(children_names) == 1: story_parts.append( f"They have a child called {children_names[0]}."