Recursive Prompts: Implementing Recursion with LLMs
This article explores a novel approach to implementing recursion using Large Language Models (LLMs). By crafting a recursive prompt that iteratively updates its own internal state, the author demonstrates how an LLM can generate a sequence of prompts converging towards a solution, mirroring the behavior of recursive functions in code. The article uses the Fibonacci sequence as an example, showcasing how recursive prompting can perform calculations. It also discusses challenges like handling inaccuracies in the LLM's output and leveraging the LLM's existing knowledge base, drawing parallels to how humans perform mental arithmetic using memorized algebraic and atomic rules. The work is connected to related research like ReAct and ACT-R, and addresses strategies for mitigating errors in LLM-generated results.