## Diagram: LLM-based Reasoning Extraction and Program Generation Workflow
### Overview
This image presents a two-stage workflow diagram illustrating how a Large Language Model (LLM) can be used for "Reasoning extraction" followed by "Program generation." The diagram details the specific prompts and instructions provided to the LLM at each stage, highlighting different types of prompt components using a color-coded legend. The overall flow demonstrates a process where an LLM first generates a reasoned answer to a question based on provided context, and then uses that reasoning to generate executable Python code.
### Components/Axes
The diagram is structured horizontally into two main phases, each with a distinct header:
* **Top-center-left header**: "Reasoning extraction" (light brown oval with black text).
* **Top-center-right header**: "Program generation" (light brown oval with black text).
Each phase contains:
* A **light blue rectangular box with rounded corners**: Represents the input prompt provided to the LLM.
* A **neural network icon labeled "LLM"**: Represents the Large Language Model processing the input.
* A **pink rectangular box with rounded corners**: Represents the output generated by the LLM.
* **Gray arrows**: Indicate the flow of information between components.
**Legend (bottom-center of the image):**
The legend defines the color coding used for different types of prompt elements within the input boxes:
* **Black square**: Signifier
* **Orange square**: Memetic proxy
* **Magenta square**: Constraining behavior
* **Dark Green square**: Meta prompt
* **Blue square**: Input
### Detailed Analysis
The workflow proceeds from left to right, detailing two sequential processes involving an LLM.
**Phase 1: Reasoning extraction**
* **Input Prompt (light blue box, left)**:
* "Read the following passage and then answer the questions:" (Black text - Signifier)
* "Passage: text + table" (Blue text - Input)
* "Questions: ask question?" (Black text - Signifier)
* "Answer the questions by finding the relevant values and performing step by step calculations." (Dark Green text - Meta prompt)
* "Answer:" (Orange text - Memetic proxy)
* **Processing**: A gray arrow points downwards from the input prompt box to the "LLM" component (neural network icon).
* **Output (pink box, bottom-left)**:
* "Answer with reasoning from LLM." (Black text)
**Phase 2: Program generation**
* **Input Flow**: A large, curved gray arrow originates from the output of the "Reasoning extraction" phase (the pink box) and points to the right, indicating that this output feeds into the input prompt for the "Program generation" phase.
* **Input Prompt (light blue box, right)**: This box combines new instructions with the output from the previous phase.
* "Questions: ask question?" (Black text - Signifier)
* "Answer: Answer with reasoning from LLM." (Orange text - Memetic proxy) - This text is identical to the output of the previous phase, indicating it's directly incorporated.
* "Task: Write a Python code to answer the last question by following the below instructions." (Black text - Signifier)
* "Instructions:" (Black text - Signifier)
* "Define the Python variable which must begin with a character." (Magenta text - Constraining behavior)
* "Assign values to variables required for the calculation." (Magenta text - Constraining behavior)
* "Create Python variable "ans" and assign the final answer (bool/float) to the variable "ans"." (Magenta text - Constraining behavior)
* "Don't include non-executable statements and include them as part of comments. #Comment: ..." (Magenta text - Constraining behavior)
* "Python executable code is:" (Black text - Signifier)
* "#Python" (Dark Green text - Meta prompt)
* **Processing**: A gray arrow points downwards from the input prompt box to the "LLM" component (neural network icon).
* **Output (pink box, bottom-right)**:
* "Python program generated by the LLM." (Black text)
### Key Observations
* The diagram clearly delineates two distinct stages of an LLM's application: first for generating human-readable reasoning, and second for translating that reasoning into executable code.
* The output of the first stage ("Answer with reasoning from LLM.") becomes a crucial part of the input for the second stage, demonstrating a chained prompting approach.
* The use of color-coding in the input prompts is critical for understanding the different roles of various prompt components:
* **Signifiers (Black)**: General instructions or labels.
* **Input (Blue)**: The raw data or context provided (e.g., "text + table").
* **Meta prompt (Dark Green)**: High-level instructions guiding the LLM's approach (e.g., "step by step calculations," "#Python" indicating the desired output language).
* **Memetic proxy (Orange)**: Placeholders or examples of the desired output format, or the actual output from a previous step that serves as context for the current step.
* **Constraining behavior (Magenta)**: Specific, detailed rules or constraints that the LLM must adhere to when generating its output (e.g., variable naming conventions, output variable name, comment requirements).
### Interpretation
This diagram illustrates a sophisticated prompting strategy designed to leverage the capabilities of Large Language Models for complex problem-solving.
The "Reasoning extraction" phase demonstrates how an LLM can be prompted to not just provide an answer, but to explicitly show its step-by-step reasoning. This is achieved by using a "Meta prompt" (dark green) that instructs the LLM to perform "step by step calculations" and a "Memetic proxy" (orange) that sets up the expectation for an "Answer:". This approach is valuable for transparency, debugging, and ensuring the LLM follows a logical path.
The "Program generation" phase then takes this extracted reasoning and uses it as context to generate executable code. The "Memetic proxy" (orange) carries the LLM's previous reasoning into this new prompt, allowing the LLM to build upon its prior understanding. Crucially, this phase heavily utilizes "Constraining behavior" (magenta) prompts. These detailed instructions guide the LLM to produce code that adheres to specific syntax, variable naming conventions, and output formats (e.g., defining `ans` as a `bool/float`). The "Meta prompt" (dark green) "#Python" explicitly signals the desired programming language.
The overall process suggests a method for enhancing the reliability and controllability of LLM outputs. By first extracting explicit reasoning and then using that reasoning, along with strict constraints, to generate code, the system aims to produce more accurate, verifiable, and usable programmatic solutions compared to a single-shot prompt for code generation. This two-step approach mitigates potential issues where an LLM might generate correct code without clear reasoning, or incorrect code due to misinterpreting implicit requirements. It highlights a pattern of using LLMs for both cognitive (reasoning) and generative (coding) tasks in a structured, interdependent manner.