{"by":"andyk","descendants":66,"id":35234276,"kids":[35239371,35238391,35238881,35239225,35238597,35238592,35240027,35238925,35242719,35246915,35239715,35248700,35239391,35239309,35238677,35238636,35238634,35238605,35242754,35234670,35234277],"score":97,"text":"I&#x27;ve been playing with the idea of an LLM prompt that causes the model to generate and return a new prompt. <a href=\"https:&#x2F;&#x2F;github.com&#x2F;andyk&#x2F;recursive_llm\">https:&#x2F;&#x2F;github.com&#x2F;andyk&#x2F;recursive_llm</a><p>The idea I&#x27;m starting with is to implement recursion using English as the programming language and GPT as the runtime.<p>It’s kind of like traditional 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.<p>Here is a prompt for infinitely generating Fibonacci numbers:<p>&gt; 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 Fibbonaci sequence.<p>Interestingly, I found that to get a base case to work I had to add quite a bit more text (i.e. the prompt I arrived at is more than twice as long <a href=\"https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;andyk&#x2F;recursive_llm&#x2F;main&#x2F;prompt_fibonnaci_include_math.txt\" rel=\"nofollow\">https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;andyk&#x2F;recursive_llm&#x2F;main&#x2F;p...</a>)","time":1679330335,"title":"Show HN: Recursive LLM Prompts","type":"story","url":"https://github.com/andyk/recursive_llm"}