merge main (INIT hidden-preconditions prompt) into research/semantic-kg

This commit is contained in:
2026-10-23 13:38:07 +02:00
+20 -9
View File
@@ -31,20 +31,31 @@ class Subquestion(BaseModel):
answer_type: AnswerType = dspy.OutputField( answer_type: AnswerType = dspy.OutputField(
desc="OPEN for a single value, FUNCTION for a formula, INTERVAL for a range, " desc="OPEN for a single value, FUNCTION for a formula, INTERVAL for a range, "
"CONSTANT for a universal constant, LIST for an enumeration of things, " "CONSTANT for a universal constant, LIST for an enumeration of things, "
"DATE for a specific date (a day, month and year — '15' alone is NOT a date)") "DATE for a specific date")
class InitSignature(dspy.Signature): class InitSignature(dspy.Signature):
"""You are the INIT step of a reasoning machine. Using ONLY concepts literally """You are the INIT step of a reasoning machine. Your job is to make the
present in the question plus a generic planning scaffold (number, method, final answer a direct lookup. Follow this procedure:
machine, resources, dependencies), ask: what information or knowledge do I 1. Re-read the question and:
need to answer this? Write 1-4 open subquestions in dependency order. 1.1. List every word or phrase that could refer to more than one
Masked entities like PERSON_1 or ORGANIZATION_1 are ALREADY-RESOLVED real thing or moment.
named entities from the question — treat each as a known specific entity; 1.2. Think: what information or knowledge do I need to answer this?
do not ask what or who the placeholder is.""" 2. HIDDEN PRECONDITIONS: for every entity, relation, or value that the
question assumes but does not state and that is required to answer
it (an implicit owner, role, time window, or intermediate fact),
write an explicit subquestion that resolves it. NEVER collapse a
hidden precondition into the final subquestion. Always use the most
generic term to ask about them.
3. Write the subquestion that produces the final answer, with
depends_on pointing at the preconditions it needs.
Order the subquestions by dependency (1-4 in total).
Masked entities like PERSON_1 or ORGANIZATION_1 are ALREADY-RESOLVED named
entities from the question — treat each as a known specific entity; do not
ask what or who the placeholder is."""
question: str = dspy.InputField() question: str = dspy.InputField()
subquestions: list[Subquestion] = dspy.OutputField( subquestions: list[Subquestion] = dspy.OutputField(
desc="1-4 subquestions in dependency order; empty when the question is atomic") desc="1-4 subquestions in dependency order; never empty")
class Attendant(str, Enum): class Attendant(str, Enum):