High-Speed LLM Inference in Practice: How Speed Shapes Interactive Experience
This article explains why inference speed is critical for interactive LLM applications. It covers the two key latency dimensions—time to first token and generation rate—along with practical conversions, promising use cases, streaming and caching techniques, measurement methods, speed-quality trade-offs, and deployment recommendations.
Large language models generate text token by token. The number of tokens output per second (tok/s) determines how long users wait for results and whether the model can participate in real-time interaction. In the past, the industry generally assumed that inference speed was inversely proportional to model size: the fewer parameters, the faster the response, but usually the weaker the capability. This assumption is being challenged, so it is necessary to revisit speed metrics from an engineering perspective.
1. Why Speed Becomes a Dividing Line for Interactive Experience
Whether speed is sufficient cannot be judged by averages alone. It should be split into two dimensions:
- Time To First Token (TTFT): the time from sending a request to receiving the first token. It affects whether users perceive the system as “stuck.”
- Generation rate (tokens per second): the sustained output speed after the first token. It affects the delivery time of the complete result.
Both are essential. If the first token is fast but generation is slow, users see text appear line by line while waiting for a long time. If generation is fast but the first token is slow, users stare at a blank interface and pause.
2. Putting Speed Numbers into Perspective
Take 400 tokens per second as an example. A simple set of conversions helps illustrate the difference:
- A single token takes about 2.5 milliseconds on average.
- A human blink takes about 0.3 seconds, during which about 120 tokens can be produced.
- A piece of code or a document of about 4,000 tokens takes about 10 seconds at 400 tok/s. At 50 tok/s, it takes about 80 seconds.
This shows that for the same output length, an eightfold increase in rate reduces generation time to about one eighth. The longer the output, the more obvious this gap becomes.
3. Application Scenarios Worth Watching
Low-latency inference makes some product forms feasible that were previously difficult to implement.
- Real-time page prototypes: users describe an interface in natural language, and the model outputs a front-end page that can be rendered directly within tens of seconds. Designers can adjust instructions while viewing the result.
- Iterative creative tools: in graphics, shader, or animation scenarios, the model modifies code immediately based on each instruction, and the preview window updates in sync, forming an “edit while speaking” workflow.
- Sketch to code: a hand-drawn wireframe is used as input, and the model outputs structured page code, shortening the path from design to a runnable prototype.
- Dynamic content and scene switching: themes, color schemes, and assets are adjusted immediately based on user input. The generated result must be completed within the time window in which users maintain attention.
- Multi-stream concurrency: multiple agents answer questions simultaneously in the same batch. The system needs to focus on aggregate throughput, not only per-stream rate.
To judge whether a scenario is suitable for high-speed inference, ask two questions: Are users waiting for the result and interrupting their work because of it? Does the result require multiple rounds of iteration? When both answers are “yes,” the benefits of speed improvements are most obvious.
4. Key Elements of Low-Latency Inference Services
4.1 Streaming Output
A non-streaming API returns only after all content has been generated, so perceived latency equals total generation time. Streaming output uses server push (such as Server-Sent Events or WebSocket chunked transfer) to let the client render chunks as they arrive, reducing perceived latency to the time to first token. This is one of the lowest-cost changes for improving experience.
4.2 Front-End Incremental Rendering
The client should avoid triggering a full reflow for every token. A common approach is to batch refreshes by sentence or by a fixed time window, for example, updating the DOM in batches every 50 milliseconds. Code preview scenarios also need to keep rendering stable when syntax is not yet closed, preventing interface flicker.
4.3 Concurrency and Throughput
Single-stream rate and overall service throughput are two different metrics. The server needs to balance them through batching, request queues, and capacity planning. As concurrency increases, per-stream rate usually decreases, so load testing should cover realistic concurrency levels rather than only idle-load data.
4.4 Caching and Reuse
For repeated prompts, template content, and common prefixes, caching can reduce repeated computation. Cache keys should include the model version and key parameters to avoid returning stale results after a version switch.
5. Measurement: Comparing Speed with a Consistent Methodology
The following example shows how to measure TTFT and generation rate on the client. The iterator in the example is a placeholder implementation. When integrating, replace it with the streaming call of the service in use.
import timedef measure_stream(token_iter):start = time.perf_counter()first_token_at = Nonecount = 0for _ in token_iter:now = time.perf_counter()if first_token_at is None:first_token_at = nowcount += 1end = time.perf_counter()if first_token_at is None:return {"ttft_s": None, "tokens": 0, "tokens_per_s": 0.0, "total_s": end - start}gen_time = end - first_token_attps = count / gen_time if gen_time > 0 else 0.0return {"ttft_s": first_token_at - start,"tokens": count,"tokens_per_s": tps,"total_s": end - start,}
When measuring, note three points:
- Fix the prompt, output length, and sampling parameters to ensure a fair comparison.
- Repeat each group multiple times and report the median and percentiles rather than a single result.
- Record output quality at the same time. Speed data must be viewed together with task completion rate.
6. Trade-offs Between Speed and Quality
Speed is not the only metric. Teams should also consider the following when selecting models or services:
- Output quality: whether code compiles and passes tests, and whether pages render correctly.
- Cost: faster services may come with a higher unit price or a lower concurrency quota, so costs need to be calculated based on business volume.
- Stability: pay attention to error rates, timeout rates, and rate-limiting policies under high load.
- Safety and compliance: content review processes cannot be omitted in pursuit of speed.
A common approach is tiered routing. Simple, highly interactive tasks use a high-speed channel, while complex, one-off tasks use a high-quality channel. Both channels share the same set of evaluation metrics for horizontal comparison.
7. Deployment Recommendations
- Define user-perceivable latency goals first, such as returning the first token within 1 second and delivering the complete result within 30 seconds.
- Build a unified benchmark set covering typical tasks such as code generation, text rewriting, and structured output.
- Enable streaming rendering on the front end and properly handle mid-stream cancellation and network disconnection.
- Set up a fallback strategy: when the high-speed channel is unavailable, automatically switch to the regular channel and indicate the current mode to users.
- Rerun the benchmark whenever the model version changes, so that speed improvements do not mask quality regressions.
The value of speed lies in the fact that it changes what interaction patterns are possible. Once waiting time drops to a level where users do not lose focus, product designers can reconsider which features are worth building.
