Chain-of-Thought Extractor
Extract the final answer from a chain-of-thought response.
Given an LLM response that contains reasoning steps followed by a final answer, extract just the answer. The final answer is always on the last line that starts with "Answer:" or "Therefore:" or "The answer is".
Input: Multi-line LLM response (read until EOF)
Output: The extracted answer (text after the marker, stripped).
If no answer marker is found, output "NO_ANSWER".
Example
Let me think step by step. First, 2 + 3 = 5. Then, 5 * 2 = 10. Answer: 10
10
- The input is read line by line until the end of the file (EOF) is reached.
- Each line is checked for the presence of answer markers ("Answer:", "Therefore:", or "The answer is") at the start of the line.
- The last line that starts with an answer marker is identified as "Answer: 10", so the text after the marker is extracted and stripped of any leading/trailing whitespace.
- The extracted text, , is then output as the final answer.
Constraints
- Answer markers (case-insensitive): "Answer:", "Therefore:", "The answer is"
- Use the LAST matching line if multiple exist
- Strip whitespace from the extracted answer
- Output NO_ANSWER if no marker found