Principle:Princeton nlp Tree of thought llm Task Instantiation
| Knowledge Sources | |
|---|---|
| Domains | Software_Design, NLP |
| Last Updated | 2026-02-14 03:30 GMT |
Overview
A factory pattern that maps a string task identifier to a fully initialized task object with loaded data, configured search depth, and prompt wrapping methods.
Description
Task Instantiation is the process of resolving a user-provided task name (e.g., game24, text, crosswords) into a concrete task object ready for use by the search algorithm. This addresses the need for a clean separation between experiment configuration (which task to run) and the task-specific logic (how to load data, format prompts, validate outputs). The factory pattern ensures that all downstream code operates on a uniform Task interface regardless of which specific benchmark is selected.
Usage
Use this principle whenever a new experiment run begins and needs to convert the user's task selection string into a functional task object. It is the first substantive step after CLI argument parsing in both ToT BFS and baseline experiments.
Theoretical Basis
The Factory Method pattern delegates object creation to a factory function, decoupling the client from concrete class constructors:
# Abstract pattern
def create_task(name: str) -> Task:
registry = {
'task_a': TaskA,
'task_b': TaskB,
}
return registry[name]()
Each instantiated task object encapsulates:
- Data loading: reads benchmark dataset from disk
- Search configuration: sets steps (BFS depth) and stops (stop tokens per step)
- Prompt wrapping: methods that format input/partial output into LLM prompts
- Output validation: test_output() method for correctness checking