Skip to the solution
MediumAI Engineering7 min read

What are reasoning models and when should you use them?

912 views

The problem

Question presented to candidate: "Most providers now offer 'reasoning' or 'thinking' models next to their regular ones. What actually makes a model a reasoning model, and how do you decide when it is worth using one in a product?"

What a strong answer should cover:

  • A reasoning model is trained (largely with reinforcement learning) to generate a long internal chain of thought before its final answer; it is still the same next-token loop, spending more tokens at inference time
  • Test-time compute: accuracy on hard multi-step problems improves with more thinking tokens or more samples, which is why there are effort or budget controls; OpenAI o1 (September 2024) and DeepSeek-R1 (January 2025, open weights) are the reference points
  • Costs: thinking tokens are billed as output tokens even when hidden or summarised, they count toward the output cap, and they add latency before the first visible token
  • When it pays off: multi-step maths, planning, hard debugging, complex constraint-following and agent planning; when it does not: extraction, classification, short chat, latency-critical paths
  • How usage changes: give goals and constraints rather than "think step by step" scaffolding, set a generous output cap, many sampling parameters are not supported, and route only the hard traffic to it

Code / implementation expected: Optional β€” a cost and latency calculation with reasoning tokens, or majority-vote arithmetic, shows the trade-off; no model call is needed.

  • reasoning
  • models

Try it yourself

Sketch your approach before you read the solution. That is what the interview tests.

Stuck? Get a hint.

A short nudge toward the approach. It will not give the answer away.

Solution

The solution is hidden so you can try first

7 min read Β· 11 sections

Read the code

Reasoning tokens: a trick question, majority-vote maths, and the cost and latency bill
// What a reasoning model buys and costs. Three parts, all deterministic:
// 1) a stub "fast" answer vs a stub "think first" answer on a trick question,
// 2) exact maths for majority voting over N samples (test-time compute),
// 3) the bill and the latency when hidden reasoning tokens are added.
const words = (s) => s.split(/\s+/).filter(Boolean).length;

// 1) Bat and ball: together $1.10, the bat costs $1.00 more than the ball.
const fast = { thinking: "", answer: "0.10" };            // the intuitive answer
const steps = [
  "let ball = b, bat = b + 1.00",
  "b + (b + 1.00) = 1.10 so 2b = 0.10 so b = 0.05",
  "check: ball 0.05 + bat 1.05 = 1.10 and 1.05 - 0.05 = 1.00, consistent",
];
const slow = { thinking: steps.join(" ; "), answer: "0.05" };
const check = (b) => Math.abs(b + (b + 1.0) - 1.1) < 1e-9;
for (const [name, r] of [["fast model", fast], ["reasoning model", slow]]) {
  console.log(name.padEnd(16) + "answer=" + r.answer + " correct=" + check(Number(r.answer)) +
    " thinking words=" + words(r.thinking));
}

// 2) Self-consistency: sample N independent answers, return the majority.
// P(majority correct) when each sample is right with probability p (N odd).
function choose(n, k) { let c = 1; for (let i = 1; i <= k; i++) c = (c * (n - k + i)) / i; return c; }
function majority(p, n) {
  let s = 0;
  for (let k = (n + 1) / 2; k <= n; k++) s += choose(n, k) * p ** k * (1 - p) ** (n - k);
  return s;
}
console.log("majority vote accuracy (binary right/wrong answers):");
console.log("  N      p=0.60   p=0.80   p=0.40");
for (const n of [1, 3, 5, 9, 15]) {
  console.log("  " + String(n).padEnd(7) + [0.6, 0.8, 0.4].map((p) => majority(p, n).toFixed(3).padEnd(9)).join("").trimEnd());
}

// 3) Reasoning tokens are generated (and billed) as output tokens before the
// first visible token. Prices and speeds are illustrative assumptions.
const price = { in: 2.0, out: 10.0 };                     // $ per 1M tokens
const speed = 80;                                         // output tokens per second
const req = { inTok: 2000, visible: 400 };
const effort = [["none", 0], ["low", 1000], ["medium", 4000], ["high", 16000]];
console.log("effort  reasoning  $/request  first visible token  total time  $/100k requests");
for (const [name, think] of effort) {
  const cost = (req.inTok * price.in + (think + req.visible) * price.out) / 1e6;
  console.log(name.padEnd(8) + String(think).padEnd(11) + ("$" + cost.toFixed(4)).padEnd(11) +
    ((think / speed).toFixed(1) + " s").padEnd(21) + (((think + req.visible) / speed).toFixed(1) + " s").padEnd(12) +
    "$" + Math.round(cost * 100000));
}

// The max_tokens trap: the cap covers reasoning AND the visible answer.
for (const maxTokens of [8000, 20000]) {
  const think = 16000;
  const used = Math.min(maxTokens, think + req.visible);
  const visible = Math.max(0, used - think);
  console.log("high effort, max_tokens=" + maxTokens + ": billed output=" + used + " visible answer tokens=" + visible +
    " stop=" + (used < think + req.visible ? "hit max_tokens (answer missing)" : "finished"));
}

Discussion

Other approaches, follow-ups and how it went in real interviews.

Sign in to join the discussion.

No comments yet. Share how you would answer it.

Question 24 of 83 in AI engineering

Keep your momentum going.

Mark this question solved to track your progress, then take the next one while it is fresh.

Up nextMedium

How do multimodal models handle images, audio and other non-text inputs?

Continue