LLM Long Chain Reasoning: Thinking Budget and Efficiency Optimization Practices
This article is designed for engineering teams deploying or evaluating large language models (LLMs), addressing three core questions: how to measure Token consumption in reasoning modes, how to set thinking budgets, and how to handle limits when they are exceeded. It covers practical strategies for measuring implicit reasoning, configuring two-tier budgets, implementing Chain-of-Thought (CoT) pruning, ensuring completeness in multi-solution tasks, and managing degradation and retry processes.
This article targets engineering teams deploying or evaluating large language models (LLMs) and focuses on three key questions: How do you measure Token consumption in reasoning modes? How do you set a thinking budget? And how do you handle limits when they are exceeded? Note that all numerical values provided are examples and must be re-evaluated on your own evaluation sets.
1. Measure First, Set Budgets Later
Non-reasoning modes do not always end with “a few hundred Tokens.” Some newer models perform implicit reasoning before outputting when encountering complex problems, causing the output length to increase. This behavior is hard to judge empirically and requires actual measurement.
Recommended steps:
- Fix the model version, sampling parameters (temperature, top_p), and tokenizer. If any of these change, the Token counts become incomparable.
- Bucket evaluation questions by difficulty or task type, such as easy, medium, and complex.
- Calculate the output Token distribution for each bucket, recording P50, P90, and P99.
- Record the truncation rate, which is the percentage of requests that hit the output limit and were forced to stop.
To determine if implicit reasoning is occurring, observe whether the output length in non-reasoning mode increases significantly with difficulty for the same set of questions. If the model does not return visible reasoning content, but the billed Tokens increase with difficulty, it indicates that internal reasoning has already been billed.
2. Methods for Setting a Thinking Budget
The budget should be divided into two tiers:
- Base Budget: Covers most requests. Use the P90 of historical outputs as a starting point, e.g., 8K.
- Extended Budget: Enabled only when the first round is truncated or routing determines it is a complex task, e.g., 32K.
Routing decisions can be made using lightweight rules or a small model. One approach is to score the question:
- Score features like question length, number of constraints, and required steps from 0 to 1.
- Sum them with weights to get a complexity score.
- Enable reasoning mode and extended budget if the score exceeds a threshold (e.g., 0.6).
The threshold must be tuned on a validation set. The goal is typically to keep the mis-routing rate below an agreed value (e.g., 5%) while keeping the average Token count within budget. Conduct A/B testing before launch, comparing three metrics: accuracy, average Tokens, and P95 latency. Focusing only on accuracy can easily cause costs to spiral out of control.
3. Chain-of-Thought Pruning: How to Do It and Prevent Mis-pruning
Borrowing from search algorithms, you can score each step during generation and prune obviously invalid branches. Implementation steps:
- Define step boundaries, such as line breaks, numbering, or fixed delimiters.
- Prioritize programmatic validation of intermediate results, such as arithmetic checks, constraint checks, or code execution. Do not rely solely on model self-evaluation for scoring if it is unreliable.
- If scores fall below the threshold for N consecutive steps (e.g., 3 steps), roll back to the last branch or truncate it.
- Record three metrics: proportion of valid steps, number of rollbacks, and accuracy change before and after pruning.
The main risk of pruning is accidentally deleting correct solutions. This risk is higher in tasks that require finding all solutions. You can retain a completeness check step: perform reverse validation on the found solutions one by one, and set a fixed budget for rollbacks.
When rewarding “conciseness” in post-training, you must also monitor accuracy. Otherwise, the model might learn to skip derivation steps, resulting in fewer Tokens on the surface but actually lower accuracy.
4. Completeness Checks for Multi-Solution Tasks
Some tasks require listing all solutions that meet the conditions, such as scheduling or combination counting. Models often stop after finding the first viable solution. You can handle this as follows:
- Require the model to declare the number of solutions at the beginning of the output and provide justification at the end.
- Use a program to verify the solution set one by one, removing solutions that do not meet the constraints.
- Set an upper limit for search branches and record which branches were not covered.
- If the declared number does not match the verification result, mark the question for manual review.
5. Degradation and Retry Process After Exceeding Limits
Truncated results should not be scored directly or displayed as complete answers. Recommended process:
- Detect the truncation flag, e.g.,
finish_reasonislength. - If the task supports continuation, continue writing once using the already generated content as a prefix, and set a new limit. Check for repeated paragraphs after continuation.
- If continuation is not supported, retry once with the extended budget. Set retry attempts to 1 to avoid doubling costs.
- If it still fails, switch to non-reasoning mode, or return an “incomplete” status with partial results and reasons.
- Record every degradation event and track accuracy after degradation.
Degradation usually reduces accuracy. You need to explain this impact to business stakeholders, who should decide on an acceptable degradation ratio.
6. Monitoring and Alerting
The cost of long chain reasoning fluctuates greatly. It is recommended to monitor the following metrics:
- P50, P95, and P99 of output Tokens per request;
- Truncation rate and retry rate;
- Average cost per question;
- Daily budget consumption ratio (alert when exceeding 80%);
- Trends in accuracy and P95 latency.
At the infrastructure level, the container platform can automatically scale the GPU resource pool based on concurrent request volume. Auto-scaling must have an upper limit; otherwise, burst traffic will directly translate into costs.
7. Common Mistakes
- Directly comparing Token counts across different modes without confirming whether implicit reasoning is included.
- Determining budgets from a single test, ignoring sampling randomness. You should sample multiple times and take the mean and distribution.
- Looking only at accuracy without looking at unit cost.
- Scoring 0 directly after truncation or showing half-finished answers directly.
- Tuning pruning thresholds on only one dataset.
FAQ
Q: How should I set the thinking budget?
A: First use historical data to take P90 as the base budget, then set an extended budget for complex tasks. Adjust the threshold on a validation set.
Q: How do I evaluate thinking efficiency?
A: Use the Token cost per correct answer, i.e., total Tokens divided by the number of correct questions. Also report the distribution across multiple samples, not just a single number.
Q: Is long chain reasoning always better?
A: Not necessarily. Long chain reasoning on simple questions usually just adds cost. You should bucket by difficulty first, then decide which questions use reasoning mode.
Conclusion
Long chain reasoning can improve performance on multi-step logical tasks, but Token costs and truncation risks increase simultaneously. Teams should measure first, set budgets, and prepare degradation plans for out-of-limit situations.
