Implementation:Princeton nlp Tree of thought llm Get Task
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Software_Design, NLP |
| Last Updated | 2026-02-14 03:30 GMT |
Overview
Concrete tool for instantiating benchmark task objects by name provided by the Tree of Thoughts framework.
Description
The get_task function is a factory that maps a string task name to the corresponding task class and returns a fully initialized instance. It uses lazy imports to avoid loading all task dependencies upfront.
Usage
Import and call this function at the start of any experiment run to convert the user-selected task name from CLI arguments into a usable task object. Called in run.py as the first step of the run() function.
Code Reference
Source Location
- Repository: tree-of-thought-llm
- File: src/tot/tasks/__init__.py
- Lines: 1-12
Signature
def get_task(name):
"""
Factory function that returns an instantiated Task object.
Args:
name (str): Task identifier. One of 'game24', 'text', 'crosswords'.
Returns:
Task: Instantiated task object (Game24Task, TextTask, or MiniCrosswordsTask).
Raises:
NotImplementedError: If name is not recognized.
"""
Import
from tot.tasks import get_task
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| name | str | Yes | Task identifier: 'game24', 'text', or 'crosswords' |
Outputs
| Name | Type | Description |
|---|---|---|
| return | Task | Instantiated task with loaded data, self.steps, self.stops, prompt wrap methods, and test_output() |
Usage Examples
Instantiating a Task
from tot.tasks import get_task
# Instantiate Game of 24 task
task = get_task('game24')
print(len(task)) # Number of puzzles in dataset
print(task.steps) # 4 (BFS depth levels)
print(task.stops) # ['\n', '\n', '\n', '\n']
# Get input for a specific puzzle
x = task.get_input(900) # e.g., "1 2 3 4"
# Instantiate Creative Writing task
text_task = get_task('text')
print(text_task.steps) # 2
# Instantiate Crosswords task
xword_task = get_task('crosswords')
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment