Implement typed evidence latent training and benchmarks
CI / test (push) Failing after 6s

This commit is contained in:
2026-10-01 22:44:07 +08:00
parent 1d798cb73f
commit b3774e783c
22 changed files with 747 additions and 119 deletions
+9 -5
View File
@@ -3,7 +3,7 @@ from __future__ import annotations
import random
from typing import Any
from data.schema import CLASSES, Fact
from data.schema import CLASSES, Fact, Rule
def add_rule(record: dict[str, Any], seed: int, held_out: bool = False) -> dict[str, Any]:
@@ -13,16 +13,20 @@ def add_rule(record: dict[str, Any], seed: int, held_out: bool = False) -> dict[
color_index = ("red", "blue", "green", "yellow").index(color)
class_index = (color_index + (1 if held_out else 0)) % len(CLASSES)
class_name = CLASSES[class_index]
rule = Fact(color, "implies_class", class_name)
text_fact = Fact(target["object_id"], "color", color)
rule = Rule("var_x", "color", color, "class", class_name)
result = dict(record)
result.update(
{
"rules_text": f"Every {color} object belongs to class {class_name}.",
"text_facts": [rule.to_dict()],
"rules_text": (
f"{target['object_id']} is {color}. "
f"Every {color} object belongs to class {class_name}."
),
"text_facts": [text_fact.to_dict()],
"text_rules": [rule.to_dict()],
"question": f"Which object belongs to class {class_name}?",
"answer": target["object_id"],
"combination": f"{color}->{class_name}",
}
)
return result