Chain‑of‑Thought prompting adds ~15‑20 % token latency but can boost accuracy on multi‑step logical benchmarks by 8‑12 %.
1. Enable CoT – prepend the prompt with “Let’s think step‑by‑step.” or use the cot system‑message flag (vLLM v0.5+ supports --cot).
2. Measure baseline – run 1,000 inference calls with max_tokens=0 to capture pure prompt latency. Example (Python, OpenAI SDK):
import openai, time
def latency(prompt):
t0=time.time()
openai.ChatCompletion.create(
model="gpt-4o-mini",
messages=[{"role":"user","content":prompt}],
temperature=0,
max_tokens=0,
logprobs=0)
return time.time()-t03. Add CoT – append the CoT cue and re‑measure. Expected increase ≈ 0.12 s per 100 tokens (≈ 0.0012 s/token) on an 8 A100 node.
4. Accuracy test – use GSM8K, MATH, or BIG‑Bench “Logical Reasoning” split. Compute accuracy = correct / total. Typical lift: 0.78 → 0.86 on GSM8K with CoT.
5. Latency‑accuracy trade‑off – decide threshold. If latency budget ≤ 0.5 s per query, limit CoT to ≤ 150 tokens; otherwise allow full reasoning.
Quick comparison
| Metric | Standard Prompt | CoT Prompt |
|--------|----------------|------------|
| Avg. tokens | 120 | 150 |
| Latency (s) | 0.38 | 0.45 |
| GSM8K accuracy | 78 % | 86 % |
| MATH pass@1 | 22 % | 31 % |
Checklist before shipping
- [ ] Baseline latency < 0.4 s?
- [ ] CoT token count ≤ 150 tokens?
- [ ] Accuracy gain ≥ 5 % on target benchmark?
- [ ] Cost impact ≤ 10 % (price per 1k tokens unchanged, extra tokens add ~0.02 $ per 1k on gpt‑4o‑mini).
Adjust max_tokens, temperature=0, and presence_penalty=0 to keep deterministic outputs.