Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Principle:Princeton nlp Tree of thought llm Prompt Engineering

From Leeroopedia
Knowledge Sources
Domains Prompt_Design, NLP, LLM_Reasoning
Last Updated 2026-02-14 03:30 GMT

Overview

The design of task-specific few-shot prompt templates that structure LLM interactions for thought generation, evaluation, and validation in the Tree of Thoughts framework.

Description

Prompt Engineering in the ToT framework involves crafting string templates with placeholder variables that are filled at runtime with the current problem input and partial solution. Each task requires multiple prompt types depending on its generation/evaluation strategy:

  • Standard prompt: Few-shot input-output examples for direct IO generation.
  • CoT prompt: Few-shot examples with step-by-step reasoning traces for Chain-of-Thought generation.
  • Propose prompt: A single-shot example showing how to enumerate possible next steps, used for structured proposal generation.
  • Value prompt: Few-shot examples of assessing whether partial solutions can lead to the goal (sure/likely/impossible).
  • Vote prompt: Instructions for comparing multiple candidate solutions and selecting the best.
  • Score prompt: Instructions for rating a generated output on a numeric scale (e.g., coherency 1-10).

The quality of these prompts directly determines the effectiveness of the tree search, as they control both the generation of candidates and the heuristic guidance of the search.

Usage

Use this principle when creating prompt templates for a new task. Each template is a module-level string variable in a dedicated prompts file (e.g., src/tot/prompts/game24.py) and is imported via wildcard import into the task class file.

Theoretical Basis

Few-shot prompting conditions the LLM on k input-output examples before presenting the actual query:

# Abstract: few-shot prompt template
template = """
Example 1: {example_1_input} -> {example_1_output}
Example 2: {example_2_input} -> {example_2_output}
...
Query: {input}
"""

The key design decisions for ToT prompts are:

  1. Number of shots: Game of 24 uses 5-shot for standard/CoT and 1-shot for propose; Text uses shorter prompts.
  2. Output format: Prompts must elicit structured output that can be parsed programmatically (e.g., "Possible next steps:" followed by newline-separated operations, or "best choice is X" for voting).
  3. Value granularity: Value prompts use categorical labels (sure/likely/impossible) rather than numeric scores, which the LLM maps more reliably.
  4. Placeholder convention: All templates use Python string formatting with Template:Input as the primary placeholder, sometimes with additional placeholders like Template:Answer for value-last-step prompts.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment