Recursive amplification
Subquestions can have subquestions
Now we’d like to generalize the recipe above so that we can run it at different depths:
- Depth 0: Just answer the question, no subquestions.
- Depth 1: One layer of subquestions.
- Depth 2: Use subquestions when answering subquestions.
- Etc.
To do this, we add a
depth
parameter to answer_by_amplification
and get_subs
and only get subquestions if we’re at depth > 0. This simplifies the amplification recipe to:amplify.py
from fvalues import F
from ice.recipe import recipe
from ice.recipes.primer.subquestions import ask_subquestions
from ice.utils import map_async
Question = str
Answer = str
Subs = list[tuple[Question, Answer]]
def render_background(subs: Subs) -> str:
if not subs:
return ""
subs_text = F("\n\n").join(F(f"Q: {q}\nA: {a}") for (q, a) in subs)
return F(f"Here is relevant background information:\n\n{subs_text}\n\n")