Find Related products on Amazon

Shop on Amazon

Recursive LLM prompts

Published on: 2025-04-17 19:46:01

Recursive LLM prompts The idea here is to implement recursion using English as the programming language and an LLM (e.g., GPT-3.5) as the runtime. Basically we come up with an LLM prompt which causes the model to return another slightly updated prompt. More specifically, the prompts contain state and each recursively generated prompt updates that state to be closer to an end goal (i.e., a base case). It’s kind of like recursion in code, but instead of having a function that calls itself with a different set of arguments, there is a prompt that returns itself with specific parts updated to reflect the new arguments. For simplicity, let's start without a base case; here is an infinitely recursive fibonacci prompt: You are a recursive function. Instead of being written in a programming language, you are written in English. You have variables FIB_INDEX = 2, MINUS_TWO = 0, MINUS_ONE = 1, CURR_VALUE = 1. Output this paragraph but with updated variables to compute the next step of the Fi ... Read full article.