Loading...
const res = await llm.generate({ prompt: `${question}\nThink step by step.` });
const answer = Number(res.text);const res = await llm.generate({
prompt: `${question}\nThink step by step, then give the result in <answer></answer>.`,
});
const match = res.text.match(/<answer>(.*?)<\/answer>/s);
const answer = match ? Number(match[1]) : null;Tags separate the reasoning from the result, so code parses only the final answer.
Usually not much. Reasoning models already think before answering, so explicit step-by-step prompts mostly add tokens.
No. The written steps may not match how the model reached the answer, so check the result, not only the reasoning.
For multi-step tasks like math, logic or planning, with models that do not reason by default.