Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Iamhankai Forest of Thought Answer Extraction

From Leeroopedia
Revision as of 18:25, 16 February 2026 by Admin (talk | contribs) (Auto-imported from principles/Iamhankai_Forest_of_Thought_Answer_Extraction.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains NLP, Evaluation
Last Updated 2026-02-14 03:00 GMT

Overview

A pattern for extracting structured answer labels from unstructured LLM reasoning output, handling diverse answer formats across math benchmarks.

Description

Answer Extraction transforms free-form LLM output (which may contain reasoning steps, explanations, and formatting artifacts) into a clean answer label suitable for comparison. Different benchmarks use different answer formats: GSM8K uses #### delimiters, MATH uses \\boxed{} LaTeX formatting, and AIME uses plain numeric answers. The extraction pipeline must handle all these formats and clean LaTeX artifacts (dollar signs, \\text{}, etc.).

This is a critical preprocessing step because LLM outputs are verbose and inconsistently formatted. Without proper extraction, even correct answers would fail validation.

Usage

Used throughout FoT whenever LLM output needs to be converted to a comparable answer label. Applied in tree-level answer tracking, forest consensus voting, and CGDM post-processing.

Theoretical Basis

The extraction follows a priority-based pattern matching approach:

# Abstract extraction logic
def extract(text, dataset):
    if dataset == "gsm8k":
        return extract_after_delimiter(text, "####")
    else:
        boxed = extract_boxed(text)
        if boxed:
            return clean_latex(boxed)
        return extract_last_number(text)

Format priority:

  1. \\boxed{} content (highest priority, most explicit)
  2. Delimiter-based extraction (####, The answer is)
  3. Last numeric value in the text (fallback)

Related Pages

Implemented By

Page Connections

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