Repository navigation
why llm latency grows with text length
A language model has to process every token of its input before it can answer, so a longer text takes longer, roughly in proportion to its length. On our reference laptop, jevos answered a request of about 30 tokens in 28 ms and one of about 190 tokens in 130 ms, reading each text from scratch: about 0.6 ms for each additional prompt token. Double the text and you should expect close to double the time, which is why the cheapest speed-up is usually sending less.
The counterintuitive part is where the tokens come from. The text you care about is only part of the input: the question, any rule written into it, JSON keys and punctuation are all tokens too. Trimming a noisy record often saves more than choosing a faster model.
This page is the measurement and what it implies, what counts as a token, what happens on long documents, how to trim the input, and why a hosted API does not show the same slope.
| Request | Input tokens | jevos, text read from scratch | jevos, same text asked again |
|---|---|---|---|
| short | about 30 | 28 ms | not published |
| long | about 190 | 130 ms | 22 ms |
The difference is about 102 ms for about 160 extra tokens, a little over half a millisecond each, which is where the "about 0.6 ms per prompt token" figure comes from. Measured on an Intel Core Ultra 7 255H with 16 threads and no GPU in use, median of 10 requests after 3 warm-up requests, with jevos-v3, which has the same size and speed as jevos-v4.
The last column is the same request sent again. jev keeps texts it has read (up to 16 of them, 8,192 tokens in all, by default), so a second question on the same text reads only the question, and length stops mattering.
Two readings of the table matter in practice. The slope is what you pay per token of state; the short request tells you there is also a base cost that does not go away however short the text. And both are specific to this CPU: on another machine the slope changes, the shape does not. The reasons the shape holds, prompt processing that touches every token, are on prefill vs decode: where LLM latency comes from.
Everything the model reads: the state, the instructions of every question, and whatever
wording the server adds around them. The README's one-line billing example, "I was charged
twice for the same order." with "Is this a billing problem?", comes to 27 input tokens. The
refund example, a three-field JSON object with three questions and a policy sentence, comes to
95.
Do not estimate from word counts. Every response reports usage.input_tokens, so the reliable
way to know what a record costs is to send a few real ones and read that field.
jevos accepts up to 8,192 tokens. If the slope stayed at 0.6 ms per token all the way, a full context would take on the order of 5 seconds on our laptop. We have not measured that, and the straight-line assumption is optimistic rather than safe: attention over a long prompt does more work per token as the prompt grows, so treat the extrapolation as a rough idea, not a figure.
The practical conclusion does not depend on the exact number. At a few hundred tokens the model fits an interactive loop; at thousands it fits a background job. For long documents, the options are to ask about the part that matters, or to split the document and ask per chunk, combining the answers in code; that approach is on yes/no questions about long documents.
- Send only the fields the questions need. A refund question needs the item, the delivery and the customer's message, not the full order history.
-
Compute in code, send the result.
"delivered": "5 days ago"is shorter than two timestamps, and it turns a date calculation, the model's weakest kind of question, into reading. The reasoning is on small LLMs and arithmetic. - Drop noise. Signatures, quoted reply chains, tracking footers and HTML carry tokens and rarely carry the answer.
-
Keep field names readable, not long.
customer_messageis worth its tokens because it tells the model what the text is; a nested wrapper object that only your database needed is not. - Ask several questions in one request. The state is read once, so three questions about one text cost about 66 ms against 49 ms for one alone; see many questions about one text.
A trimmed state looks like the README's own example:
{
"model": "jev-latest",
"state": {
"item": "wireless mouse",
"delivered": "5 days ago",
"customer_message": "The box arrived empty. This is the second time!"
},
"questions": {"upset": {"type": "noul", "instructions": "Is the customer upset?"}}
}More on choosing fields and names is on sending JSON as the text: designing the state.
On the same two requests, the hosted Jev API took 311 ms and 314 ms, network included. Its time barely changed while the local model's more than quadrupled. A hosted model reads every token too; the flat line only says that, from where we measured, the part that depends on length was small next to the fixed part, the network round trip and whatever happens before the model starts.
That has a consequence for choosing where to run: local wins by the widest margin on short texts, and the gap narrows as texts grow. On long enough documents a hosted model can be the faster option end to end. Where the fixed cost comes from is on why a hosted LLM API cannot answer in 50 ms, and the wider trade-off is on local vs hosted LLM decisions.
Why is my LLM slower on long prompts? Because it processes every input token before answering. On our laptop each extra token cost jevos about 0.6 ms.
Does the length of the question matter, or only the text? Both. Instructions are input tokens like any other, and a long policy written into each of several questions adds up.
How many tokens can jevos read? 8,192 per question, the text plus that question, by default.
Is latency exactly linear in length? Close to it over the range we measured, about 30 to 190 tokens. We have not measured the full context and would not assume it stays linear.
What is the fastest fix for a slow request? Send less: the fields the question needs, dates turned into durations, no quoted email history.
See also: what makes a local LLM fast on a CPU, latency budgets: where a 200 ms model fits and ask a local LLM a yes/no question.
- Latency of the short and long requests, the per-token figure, the three-question timing, the hosted Jev timings and the 8,192-token context: our own measurements and the jev README.
- Token counts of the two examples:
usage.input_tokensas shown in the README. - The 5-second figure is an extrapolation from the measured slope, not a measurement.
- Attention work growing with sequence length: Hugging Face Transformers, caching, fetched 2026-09-29.
From the notes of jev, where the quickest speed-up we know of is deleting the fields nobody asked about.
- Ask a local LLM a yes/no question and get P(yes)
- Zero-shot text classification with yes/no questions
- LLM policy decisions: put the rule in the question
- LLM as a judge on a CPU
- What is a decision model in AI?
- AI decision making with probabilities and thresholds
- Why a small LLM says yes when the answer is no
- Small LLMs and arithmetic in yes/no questions
- Our held-out benchmark said 0.855, new questions said 0.757
- Does an LLM know when a fact is missing?
- Snake AI: a local model vs a cloud API
- jevos vs Jev vs Laya for yes/no decisions
- An open-source alternative to Jev for yes/no decisions
- jevos vs the OpenAI API for yes/no classification
- jevos vs Ollama for yes/no decisions
- jevos vs bart-large-mnli for zero-shot classification
- A yes/no LLM vs a fine-tuned BERT classifier
- jevos vs SetFit: zero-shot vs few-shot classification
- jevos vs Llama Guard for content safety checks
- jev serve vs llama.cpp server for classification
- jevos vs LM Studio: a decision server, not a chat app
- Local vs hosted LLM decisions: latency, cost, privacy
- A yes/no LLM vs a business rules engine
- LLM decisions vs keyword rules and regex
- An open-source alternative to Microsoft-Decision-1
- Decision engine vs decision model
- The fastest AI model for yes/no decisions
- What makes a local LLM fast on a CPU
- Why one forward pass beats generating an answer
- Prefill vs decode: where LLM latency comes from
- Why LLM latency grows with the length of the text
- Why a hosted LLM API cannot answer in 50 ms
- Many questions about one text: why the extra ones are cheap
- CPU or GPU for a small LLM
- Latency budgets: where a 200 ms model fits
- Measuring LLM latency: median, p90 and warm-up
- Q4_K_M vs Q8_0: speed and size for a small model
- Throughput vs latency for a decision server
- OpenVINO for LLM inference on a CPU
- INT8 weight quantization explained
- What P(yes) means, and what it does not
- LLM calibration explained with yes/no answers
- Expected calibration error (ECE), explained
- Temperature scaling for LLM probabilities
- Platt scaling for a yes/no model
- Reading a reliability diagram
- How to choose a threshold for P(yes)
- Thresholds when a wrong yes costs more than a wrong no
- Human in the loop AI with a review band
- Precision and recall at a P(yes) threshold
- Base rates: why a 0.9 yes can still be wrong often
- Combining yes/no answers with AND, OR and NOT
- Logits, log-odds and P(yes)
- LLM confidence scores: probabilities vs self-reports
- How to write yes/no questions an LLM answers well
- Negation in yes/no questions for an LLM
- One condition per question: splitting compound questions
- Ask whether the text says it at all
- Scores as yes/no thresholds: is it at least high?
- Sending JSON as the text: designing the state
- Why wording changes an LLM's answer, and how to test it
- Mainly about: questions for messages with several topics
- Yes/no questions about tone and emotion
- Asking about intent: what does the writer want?
- Yes/no questions about long documents
- Using an English-only LLM with other languages
- Multi-class text classification with a choice question
- Content moderation with a local LLM
- A Discord moderation bot with a local LLM
- Spam detection with yes/no questions
- Review moderation with a local LLM
- Email triage with a local LLM
- Support ticket routing with yes/no questions
- Urgency detection in customer messages
- Sentiment analysis with yes/no questions
- Intent detection with a local LLM
- Lead qualification with yes/no questions
- Fraud case triage with a local LLM
- Phishing email screening with a local LLM
- Log and alert triage with a local LLM
- Checking text for personal data with yes/no questions
- Prompt injection screening with a small model
- Document classification with a local LLM
- Product categorization with yes/no questions
- Contract clause detection with a local LLM
- Refund request triage with a local LLM
- Detecting cancellation intent in customer messages
- Reranking search results with yes/no questions
- RAG evaluation with yes/no questions
- RAG faithfulness check with a local LLM
- Hallucination detection with a local LLM
- LLM regression tests in CI with yes/no checks
- Rubric design for an LLM judge
- Pairwise comparison with a yes/no judge
- LLM judge bias and how to control it
- Evaluation metrics for yes/no classifiers
- Building a yes/no test set for your own data
- Accuracy by kind of question: why one number hides failures
- Generating test questions with answers computed by code
- Benchmark contamination and truly held-out tests
- An LLM router with yes/no questions
- A model cascade: small model first, large model on doubt
- Semantic routing vs yes/no questions
- Gating AI agent tool calls with yes/no checks
- AI agent guardrails with yes/no questions
- Stop conditions for AI agents
- Logging LLM decisions for audit
- Reducing LLM cost with local yes/no decisions
- Replacing chat LLM calls with yes/no questions
- Structured output vs a probability
- A Python client for local LLM decisions
- Calling a local LLM decision server from JavaScript
- Local LLM yes/no decisions in n8n
- A Slack bot that uses local LLM decisions
- Home Assistant automations with local LLM decisions
- A LangChain tool for local yes/no decisions
- Batch decisions from files with jev decide
- Running LLM yes/no checks in GitHub Actions
- Securing a local LLM server with an API key
- curl examples for a local LLM decision API
- Self-hosted AI for decisions
- A private LLM for text classification
- On-premise LLM for business decisions
- GDPR and automated decision-making with an LLM
- Offline AI for decisions: no network needed
- Edge AI decisions on a CPU
- Run an LLM locally without a GPU
- Small language models explained
- When a small model is enough, and when it is not
- An LLM on a laptop: what it can do in real time
- What is GGUF, for someone deploying a classifier
- GGUF quantization types explained: Q4_K_M, Q8_0 and others
- GGUF vs safetensors
- llama.cpp vs Ollama for a classification service
- llama-cpp-python vs calling llama.cpp through ctypes
- llama.cpp on Windows without compiling
- Running llama.cpp CPU only
- Using llama.cpp prebuilt binaries instead of building
- Download a GGUF model from Hugging Face