File size: 1,076 Bytes
b6d5136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import re

from agents.variants.base import TeacherVariant

_BOX = re.compile(r"\\boxed\{(.+?)\}", re.S)


class P4(TeacherVariant):
    """Answer-only extreme (lower bracket): the reference slot is a single answer line
    built from the reference's boxed answer. Maker-free (no endpoint), no thinking,
    no accept gate. P4 vs P2 prices whether branch-(b) localization pays."""
    name = "p4_answer_only"
    description = "reference slot = one answer line; maker-free, no thinking"
    thinking = False
    uses_maker = False

    def _answer(self, solution):
        found = _BOX.findall(solution or "")
        return found[-1].strip() if found else (solution or "").strip()

    def resolve_prefix(self, problem, solution, rollout, maker_client):
        tmpl = self.prompts.get("answer_only_template",
                                "The correct final answer is \\boxed{<ANSWER>}.")
        return tmpl.replace("<ANSWER>", self._answer(solution))

    def accepts(self, prefix, reference):
        return True     # a maker-free line; nothing to gate


VARIANT = P4