Local LLM Deployment: A Practical Selection and Benchmarking Guide

    Running a large language model (LLM) locally has moved from experimentation into daily development, yet models that score well on leaderboards often disappoint on your own machine. This guide explains which stages determine locally deployed LLM performance—model loading (cold start), first-token latency (prefill), token-by-token generation (decode), and resident VRAM—and how their metrics constrain one another. It clarifies why disk size, VRAM usage, and generation speed do not scale linearly; why cold start, TTFT, and decode speed must be measured separately; and how to estimate KV Cache VRAM under concurrency and long context. It provides selection strategies for five scenarios (lightweight high-frequency tasks, everyday conversation and writing, multimodal understanding, batch offline processing, and local-first with cloud fallback), a reproducible benchmarking method with a sample streaming-measurement script, a troubleshooting checklist of common misconceptions, and a four-step selection method.

    Introduction: What Matters in Selection Isn’t “Which Is Stronger” but “What Fits”

    Running an LLM locally—one capable of conversation, summarization, code assistance, and even image understanding—has moved from experimentation into everyday development. Yet when developers actually get hands-on, many run into an awkward situation: a model that scores highly on benchmark leaderboards either takes ages to load on their own machine, generates too slowly to be usable interactively, or runs out of VRAM as soon as the context grows a little longer.

    Horizontal model comparisons are abundant online. The common approach is to lay out a table of “parameter count, disk size, generation speed” and tag each model with a one-line “best for X” label. This is useful as a preliminary reference, but it usually answers a simplified question: on the author’s machine, with the author’s prompts, under the author’s concurrency settings, which model’s test numbers look better. Once you move to your own environment, any single change—CPU model, memory capacity, VRAM bandwidth, quantization format, inference framework version, even the OS’s memory reclamation policy—can flip the conclusion.

    So instead of debating “which of two models is stronger,” this article answers three more practical questions:

    1. Which stages jointly determine the performance of a locally deployed model, and how do the metrics constrain one another?
    2. Across scenarios like lightweight tasks, everyday conversation, multimodal understanding, and batch processing, in what order should trade-offs be made?
    3. How can you use a reproducible method to get trustworthy benchmark results on your own hardware?

    1. A Simplified Observation and Its Limits

    First, look at a simplified set of local benchmark observations (used only to illustrate the analysis; actual numbers vary widely with hardware, quantization format, and inference implementation):

    Model positioning Model file size Cold-start load Warm-start latency Generation speed VRAM (warm run) Subjective impression
    ~4B compact model ~2.5GB ~12s ~0.15s ~40 tok/s ~2.7GB Snappy, good for light tasks
    ~8B general model ~5.2GB ~17s ~0.25s ~24 tok/s ~4.9GB Well-balanced, good for everyday conversation
    ~12B multimodal model ~9.6GB ~14s ~0.7s ~55 tok/s ~3.1GB Understands images, excellent value

    At least two things in these numbers are worth pausing on.

    First, the ~12B model uses less VRAM than the ~8B model, yet generates more than twice as fast. This isn’t unusual with integer quantization (storing weights as 4-bit or 8-bit integers). Generation speed is approximately “VRAM bandwidth ÷ bytes read per token.” With bandwidth fixed, halving the per-token read roughly doubles the speed. A 12B model with 4-bit weights loads about 6GB into VRAM; an 8B model with 8-bit weights loads about 8GB. From this alone, the former’s theoretical generation speed is about 1.3× the latter’s. Multimodal models also sometimes use heterogeneous precision (different precision on the vision and language sides) or fall back to CPU for some operators, so VRAM usage and disk size no longer keep a fixed ratio. The takeaway: disk size, VRAM usage, and generation speed do not correspond linearly—you can’t infer any two from the third.

    Second, these “cold start” numbers probably aren’t measuring the model itself. One model cold-starts in ~12s and another in ~14s, yet the larger one is faster. A more plausible explanation is that after the file is first read from disk, it is cached in memory, so the second “cold start” actually reads from RAM. A true first read of 2.5GB, 5.2GB, or 9.6GB files from disk typically takes tens of seconds, depending on whether the disk is an HDD or SSD. If the test doesn’t clear the file cache first, “cold start” ends up measuring only the copy time from memory to VRAM.

    The practical criterion follows: every number in a report is only useful if the measurement conditions and definitions are stated clearly.

    2. Breaking Down the Inference Pipeline: Four Stages, Four Bottlenecks

    For a locally deployed LLM, the path from “the user hits Enter” to “the answer appears on screen, word by word” roughly involves four stages. Each is constrained by different resources, and the optimization approaches differ entirely.

    Stage 1: Model loading (cold start). The inference process reads the weight files, dequantizes them (low-bit weights are restored to floating point before computation), and moves the weights into VRAM. This stage is constrained by storage I/O and memory bandwidth. A common consequence is waiting tens of seconds on the first query, easily mistaken for “the model is too slow.”

    Stage 2: First-token latency (prefill). Once the weights are in place, the model processes all input tokens in parallel and computes the first output token. Users usually perceive this wait as “thinking time.” Prefill is compute-intensive and mainly consumes compute. Longer inputs mean longer waits, especially in multimodal scenarios.

    Stage 3: Token-by-token generation (decode). For each new token, the model reads all weights and the existing context cache (KV Cache) once. This stage is constrained by VRAM and memory bandwidth and determines the “typing speed” users see.

    Stage 4: Resident VRAM. While the service runs, VRAM continuously holds the weights, the KV Cache, the inference framework’s own overhead, and some VRAM headroom. This determines how many instances the machine can run simultaneously and how long the context can be.

    Different bottlenecks in the four stages mean that “optimizing cold start” and “optimizing generation speed” often require opposite configurations.

    Stage Primary bottleneck Typical symptom Common optimizations
    Model loading Storage I/O, memory bandwidth Tens of seconds wait on first query Choose a more compact quantization format, keep the process warm, use memory-mapped reads
    First-token latency Compute, input length Longer inputs mean longer waits Shorten prompts, compress image resolution, enable prompt caching
    Token-by-token generation VRAM/memory bandwidth Slow output, poor typing feel Lower weight precision, reduce model size, increase bandwidth
    Resident VRAM Capacity Insufficient concurrency, long-context overflow Limit context length and concurrency, use low-rank cache compression

    3. Understanding the Key Metrics Correctly

    1. Disk size ≠ VRAM usage

    A model file’s size is mainly determined by the storage precision of its weights. Common mixed-precision quantization formats keep higher precision for sensitive modules such as attention computation and word embeddings, so the same model may exist in several versions ranging between 5GB and 9GB. VRAM usage, on the other hand, is the sum of “weights + KV Cache + runtime overhead,” and the runtime dynamically adjusts the compute split between CPU and GPU based on the VRAM-to-memory ratio. Using more VRAM is not automatically better.

    The right judgment is: whether it delivers smooth interaction given your input/output length and concurrency, while leaving headroom for the OS and other programs—not “the card is only being used well when VRAM is maxed out.”

    2. Cold start and warm start must be measured separately

    Metric Measurement definition Recommendation
    Cold start After clearing the file cache, the time from process launch to readiness Reflects the first-use experience for interactive users; usually “measured only the first time”
    Warm start With the process resident, the interval from a service restart or model reload to receiving the first request Reflects “whether VRAM is being wasted,” not “how fast the model is”

    Warm start usually only loads the inference framework’s own runtime (such as the Python interpreter) and restores the session, without moving weights, so it is one to two orders of magnitude faster than cold start. In production, a third metric matters more: time to first token (TTFT), from request to first token returned, which includes request queueing time and is decoupled from the model itself.

    In service deployment, models generally stay resident and are rarely reloaded, so the impact of cold start is amortized. If your setup spins up on demand and tears down after use, or is deployed on cold-start-sensitive edge devices, load time needs to be evaluated as a first-class metric.

    3. Generation speed is about bandwidth, not compute

    Beyond hardware bandwidth differences, generation speed measured on the same machine is also affected by:

    • Context length: longer contexts mean more KV Cache read per generated token, gradually slowing generation;
    • Quantization format: lower-bit weights read less data and are often faster, but precision and instruction-following ability may drop;
    • Inference framework: different batching, operator implementations, and CPU/GPU split strategies can produce noticeably different results.

    So “X tok/s” only means something when accompanied by the model version, quantization format, context length, and hardware model. From an experience standpoint, rough reference ranges are:

    • Below ~10 tok/s: barely readable, hard to sustain a conversation;
    • ~15–30 tok/s: close to human reading speed, suitable for most interactive scenarios;
    • ~40 tok/s and above: smooth and natural, suitable for long-form generation.

    These ranges are relative: reading fast and writing slowly are not contradictory.

    4. VRAM needs to be calculated, not eyeballed as “probably enough”

    Beyond weights, the most commonly underestimated item in long-context scenarios is KV Cache VRAM. The rough estimation formula is:

    1. KVCache(GB) ≈ 2 × layers × KV heads × head dim × bytes × context length × concurrency ÷ 1024³

    Note: the 2 accounts for one copy each of Key and Value; bytes is 2 for FP16 and 1 for INT8.

    For an “8B, 32-layer, 8 KV heads, head dim 128” model:

    • With 4-bit weights, about 5GB;
    • Single-stream 8K context KV Cache, about 1GB;
    • With 4 concurrent streams at 32K context each, the KV Cache balloons to about 16GB.

    Here weights take only a fraction of VRAM. If you plan capacity as “the model file is 5GB, so an 8GB card is enough,” you will almost certainly overflow after launch. Engineering should shift from “single-stream, single-request” capacity planning to “concurrency × context” capacity planning.

    4. Scenario-Based Selection Strategies

    Scenario 1: Lightweight, high-frequency tasks (text classification, information extraction, format conversion, intent recognition)

    Core tension: the tasks are simple, but they are called frequently, so latency and cost are multiplied.

    Recommendation: favor compact models of 4B parameters or below, with a resident service. These tasks produce short, fixed-format outputs, so decode time is minimal and TTFT plus queueing become the bottleneck. If the label taxonomy is stable, lightweight fine-tuning (such as parameter-efficient fine-tuning) with a few hundred labeled samples is often more cost-effective than switching to a larger model.

    Engineering notes:

    • Prefer constrained decoding (generating under a given grammar or JSON structure) for structured output, reducing post-processing parse failures;
    • Set timeouts and a fallback chain; on timeout, automatically hand off to a rules engine or a human;
    • Enable prompt prefix caching to reuse fixed system instructions.

    Scenario 2: Everyday conversation and long-form writing (summarization, polishing, customer-service assistants)

    Core tension: quality requirements are higher than speed, and contexts tend to be long.

    Recommendation: an 8B-class general model is usually the balance point between experience and resources. When evaluating, don’t look only at general leaderboards; use your own business corpus for small-scale human evaluation covering typical tasks such as multi-turn coreference, long-document summarization, and format adherence.

    Engineering notes:

    • Use the KV Cache VRAM formula to calculate the “concurrency × context” ceiling and set rate-limiting parameters accordingly;
    • Manage long conversation history with sliding windows, summary compression, and similar techniques;
    • The longer the context, the slower the speed; prefer context compression over piling on long contexts.

    Scenario 3: Multimodal understanding (image Q&A, receipt/invoice recognition, chart interpretation)

    Core tension: visual inputs can bring token overhead far exceeding expectations.

    Recommendation: choose a model with vision encoding capability and test with real business images, not just text. Also note:

    • Resolution translates to compute: many models split an image into tiles, each encoded into a fixed number of visual tokens. A high-resolution photo can expand into thousands of tokens, multiplying prefill time;
    • Text-first pipelines: for text-based receipts and forms, prefer a two-stage pipeline of “traditional optical character recognition (OCR) + text-model understanding,” which is usually faster, more accurate, and more VRAM-efficient, with multimodal models as a supplement for complex layouts or charts;
    • Matching precision: low-bit quantization can hurt fine-grained tasks such as OCR and digit recognition more than pure text tasks, so compare results before and after quantization.

    Scenario 4: Batch offline processing (data labeling, content moderation, knowledge base construction)

    Core tension: there is no interactive latency constraint, but the total volume is huge.

    Recommendation: prioritize throughput over single-item speed. You can choose a slightly larger model for quality and use larger batches to fully exploit compute; or split summarization, extraction, and rewriting into a pipeline—simple steps to small models, hard steps to large ones.

    Engineering notes: build in checkpoint/resume, retry, and idempotency. After a batch of data is written to persistent storage or a message queue, stateless consumers pull it in batches and write back results; if one batch fails, rerun only that batch rather than redoing everything.

    Scenario 5: Hybrid deployment with local-first and cloud fallback

    Core tension: sensitive data must stay local, while complex requests need stronger capability; both must be accommodated.

    Recommendation: use tiered routing—a local small model handles high-frequency, low-sensitivity routine requests; requests that exceed local capability or touch sensitive-data boundaries are forwarded to a cloud LLM service; both share one interface protocol, making canary releases and rollback easier.

    Engineering notes:

    • Use a model gateway to unify authentication, rate limiting, logging, and billing;
    • On the cloud side, general-purpose LLM inference services and model development platforms can quickly stand up fallback capability;
    • Metrics can be collected centrally into logging services and monitoring/alerting systems, and capacity planning can use elastic container platforms for on-demand scaling.

    5. A Reproducible Benchmarking Method

    Selection can’t rest on someone else’s data. Design a standardized load-testing process around your target scenario.

    1. Fix the experimental environment. Same machine, same power mode, same inference framework version. Restart the inference service before each test and record VRAM and memory usage.

    2. Design a representative test set. Prepare inputs per scenario: short texts of 50–100 characters for lightweight tasks, 3–5 rounds of multi-turn conversation for everyday dialogue, 5–10 real business images for multimodal. Fix the random seed and set temperature to 0 for each case to ensure reproducibility.

    3. Collect complete metrics. At least: cold-start time after clearing the file cache, TTFT (first-token time), generation speed, peak VRAM and memory, and the speed-decay curve under long context.

    The example script below precisely measures first-token time and end-to-end generation speed through a streaming interface. Replace the endpoint address and request body fields with the definitions of your actual inference service:

    1. import json
    2. import statistics
    3. import time
    4. import urllib.request
    5. ENDPOINT = "http://127.0.0.1:8000/infer" # Replace with your actual inference service address
    6. PROMPT = "Please briefly explain how to evaluate the performance of a locally deployed LLM."
    7. RUNS = 5
    8. def timed_call():
    9. """Run one streaming inference request; return first-token time and generation speed."""
    10. body = json.dumps({
    11. "prompt": PROMPT,
    12. "max_tokens": 128,
    13. "stream": True, # Stream the response for precise timing
    14. "temperature": 0, # Fix the output to ensure reproducibility
    15. }).encode()
    16. req = urllib.request.Request(
    17. ENDPOINT, data=body, headers={"Content-Type": "application/json"}
    18. )
    19. start = time.perf_counter()
    20. first_token_at = None
    21. token_count = 0
    22. with urllib.request.urlopen(req) as resp:
    23. for raw_line in resp: # Read the stream block by block
    24. if not raw_line.strip():
    25. continue
    26. # Inference services usually push incremental content line by line with a data: prefix
    27. payload = raw_line.decode().removeprefix("data:").strip()
    28. if payload in ("", "[DONE]"):
    29. continue
    30. if first_token_at is None:
    31. first_token_at = time.perf_counter() - start
    32. token_count += 1
    33. total = time.perf_counter() - start
    34. tokens_per_sec = token_count / (total - first_token_at)
    35. return first_token_at, tokens_per_sec
    36. # Warm up once to exclude extra overhead from the first run
    37. timed_call()
    38. results = [timed_call() for _ in range(RUNS)]
    39. ttft = [r[0] for r in results]
    40. speed = [r[1] for r in results]
    41. print("First-token time median: %.0f ms | P95: %.0f ms"
    42. % (statistics.median(ttft) * 1000, sorted(ttft)[int(0.95 * RUNS) - 1] * 1000))
    43. print("Generation speed median: %.1f tok/s | variance: %.1f%%"
    44. % (statistics.median(speed),
    45. (max(speed) - min(speed)) / statistics.median(speed) * 100))

    4. Run multiple rounds and take the median; focus on stability. Single results are highly variable, so run at least 3–5 rounds per case type, take the median, and watch the fluctuation. For interactive applications, the P95 of first-token time better reflects user experience than the average.

    5. Record qualitative metrics. Beyond numbers, human scoring matters equally: format adherence, naturalness of the output language, hallucination rate, and refusal rate. You can organize 3–5 business colleagues to blind-rate the same batch of inputs.

    6. Establish a reusable evaluation baseline. Archive the test set, scripts, and results; rerun when you change the model version, adjust the quantization format, or tweak inference parameters, ensuring every adjustment is quantifiable and traceable.

    6. Common Misconceptions and a Troubleshooting Checklist

    Common misconception Reality How to check
    Bigger file means a stronger model Size is determined by quantization precision; a lower-precision large model can be both fast and efficient Run a precision comparison test on the target task
    VRAM not fully used means the model isn’t fully utilized The runtime dynamically adjusts the CPU/GPU split Watch GPU utilization and CPU usage, not just VRAM
    Higher tok/s is always better Speed drops significantly under high concurrency and long context Load-test at peak concurrency and maximum context
    More parameters always means better results Quantization loss, context length, and prompt quality all affect output Use a unified test set and compare results across model sizes
    Multimodal models can fully replace OCR Recognition accuracy and speed may not win on complex layouts Compare “OCR + text model” against multimodal on business images
    Looking only at first-test results File caching and VRAM fragmentation can distort later tests Restart the service before each test and record cache state

    7. Summary: A Four-Step Selection Method

    Selecting a locally deployed LLM is essentially a constrained optimization problem—finding the best solution under limited resources. It boils down to four steps:

    1. Define the scenario: first determine the task’s output length, latency requirement, concurrency scale, and input form (text-only or with images), then talk about model size;
    2. Calculate resources: estimate VRAM needs with “weights + KV Cache + runtime overhead,” combine with memory and storage to judge whether partial offloading is needed, and plan the concurrency and context ceilings accordingly;
    3. Verify with benchmarks: in a fixed environment, measure cold start, TTFT, generation speed, and peak VRAM separately with your own test set, and judge across multiple metrics;
    4. Iterate continuously: lock in the evaluation baseline, and base any change to model version, quantization format, or inference parameters on data.

    Returning to that simplified observation at the start, what is truly worth remembering isn’t how many tok/s a particular model hit on a particular machine, but the three lessons hidden behind the numbers:

    • There is no fixed proportional relationship among disk size, VRAM usage, and generation speed;
    • Cold start, first-token latency, and decode speed are determined by different resources and must be measured separately;
    • Parameter count is only one of many variables—quantization precision, context length, and input form often decide the final experience.

    For most teams, a more pragmatic path is “start with a small model and scale as needed”: a local compact model handles high-frequency routine requests, with cloud capability as fallback for complex tasks. This controls resource costs while leaving room for future upgrades. Toward this goal, Baidu AI Cloud’s related products can be factored into overall architecture design. For example, its model development and deployment platform can support the full workflow of fine-tuning and deployment, cloud inference services can handle complex requests, and logging services and monitoring/alerting provide unified observability. There is no single correct answer in technology selection—only the one that best matches your own scenario, data, and resource constraints.