How to Choose and Run Large Language Models Locally on a Personal Computer

    A practical guide to local LLM deployment on personal computers, covering model selection across parameter size, quantization, model type, and language fit, plus memory estimation, scenario-based hardware recommendations, inference runtime practices, and building your own evaluation baseline.

    1. Why Local Deployment Is Viable Again

    Over the past two years, the feasibility of on-device inference has changed structurally. The shift is not driven by a single factor but by three curves moving at once: on the model side, sparse designs have decoupled “total parameter count” from “parameters activated per token”; on the quantization side, integer-based schemes have matured, compressing weight size to half the original or less with almost no loss of usable accuracy; on the hardware side, a common configuration has emerged with ample system memory but limited VRAM.

    For developers, local deployment offers three clear benefits: compliance and privacy advantages because data never leaves the machine; stable latency with no network dependency; and zero marginal call cost, which leaves room for repeated trial and error. The trade-offs are equally clear — context length, concurrency, and model ceiling are all constrained by a single machine’s resources. So the first principle of selection is not “pick the strongest model” but “pick the model that matches task difficulty and available hardware headroom.”

    2. Four Dimensions of Model Selection

    2.1 Parameter Count and Activated Parameters

    In dense models, parameter count is roughly linearly related to compute and memory cost. Sparse (mixture-of-experts) models tie inference cost to the portion actually activated, producing a shape with “large total parameters but small per-pass compute.” On personal computers, such models often deliver better language quality than dense models with the same activated count, but note this: VRAM or memory must still hold all expert weights, and insufficient capacity will not automatically make things faster.

    2.2 Quantization Precision

    The common approach is 4-bit weight quantization, with 8-bit and mixed precision also in use. The practical rule of thumb: 4-bit has limited impact on general capabilities for generation tasks, but a relatively more noticeable impact on long-chain reasoning tasks such as math and code. If a task is sensitive to numerical stability, preserve higher precision rather than compressing size at all costs.

    2.3 Instruction-Tuned vs. Reasoning Models

    The same model generation often ships in two forms: “output directly” and “reason first, then output.” The former has low time-to-first-token and consumes fewer tokens, making it suitable for summarization, rewriting, extraction, and classification. The latter is more reliable on tasks requiring multi-step verification, but it generates additional reasoning tokens, raising both speed and cost. The recommended engineering practice is to run both and dispatch by task type through a lightweight router.

    2.4 Chinese and Domain Corpus Fit

    At equal scale, models with a higher proportion of Chinese and specialized text in their training data usually handle Chinese long-form processing, official documents, and report writing more smoothly. This cannot be inferred from parameter count and must be measured with your own evaluation set.

    3. Resource Estimation: Do the Math Before Downloading

    A reusable rough calculation:

    1. Weight size (GB) ≈ parameters (B) × bytes per parameter
    2. 4-bit ≈ 0.5 bytes/parameter
    3. 8-bit ≈ 1 byte/parameter
    4. Runtime memory ≈ weight size + KV Cache + runtime overhead (~1–2GB)

    KV Cache grows linearly with context length and concurrency, and in long-document scenarios it is often the overlooked second bottleneck. If VRAM cannot hold all weights, some layers can reside in memory: speed drops but usability is unaffected. If memory is below the weight size, it is basically not viable.

    A typical reference point: a sparse model with about 30B total parameters and about 3B activated parameters has 4-bit weights in the ~16GB range and runs on 24GB of memory; paired with an entry-level 8GB VRAM GPU for partial offloading, measured throughput is roughly in the low teens of tokens per second. A 4B-class dense model is about 2–3GB after 4-bit quantization and interacts smoothly on CPU alone, reaching tens of tokens per second with discrete GPU acceleration.

    4. Configuration by Scenario

    Scenario Suggested Scale Form Reference Configuration
    High-quality long-form generation, complex rewriting Mid-to-large sparse model One reasoning and one instruction model 24GB memory + 8GB VRAM
    Everyday Q&A, scripting assistance 4B-class dense Instruction-tuned 16GB memory, CPU-only works
    Image content understanding 4B–8B multimodal Vision-language model 16–32GB memory + 8GB VRAM
    Local knowledge base retrieval Small embedding model Embedding model 8GB memory is enough

    On the multimodal side, small vision-language models already cover common tasks such as receipt recognition, UI screenshot understanding, and chart reading. When running locally, first reduce input image resolution and the number of visual tokens — this is the most direct speedup. For embedding models, 0.6B-class models offer outstanding cost-performance for Chinese retrieval, while 4B/8B-class models suit scenarios with higher recall-quality requirements; if VRAM is tight, use a two-stage approach of “small model for coarse filtering + large model for reranking.”

    5. General Practices for the Inference Runtime

    • Sampling parameters: use low temperature and nucleus sampling for general generation; push temperature close to 0 for extraction tasks to improve stability.
    • Context management: use a fixed template with explicit separators; summarize long documents in segments first, then aggregate, instead of filling the window in one shot.
    • Structured output: when strict JSON is required, use constraint decoding or grammar restrictions supported by the runtime rather than relying on the prompt alone.
    • Prompt caching: place invariant system instructions in the prefix and reuse their computation, which significantly reduces repeated overhead.
    • Observability: log time-to-first-token, output tokens per second, and peak VRAM and memory usage as a basis for later tuning.

    Illustrative call logic:

    1. def route(prompt: str, task: str) -> str:
    2. # Simple tasks go to the low-latency model; complex reasoning goes to the reasoning model
    3. model = "fast" if task in {"summary", "extract", "rewrite"} else "reason"
    4. return runtime.generate(model=model, prompt=prompt, temperature=0.2)

    6. Evaluation and Iteration: Build Your Own Baseline

    Do not rely on a single leaderboard. Build 30–100 real task samples covering five categories — summarization, extraction, multi-turn Q&A, code snippets, and image understanding — and record three metrics: human usability score, time-to-first-token, and output tokens per second. Change only one variable at a time (scale, quantization, form) so you can tell where the gain comes from.

    7. Common Pitfalls

    1. Looking only at parameter count: activated parameters determine speed in sparse models.
    2. Ignoring KV Cache: under long context it can exceed the weights themselves.
    3. Using a reasoning model for simple tasks: wasted latency and token cost.
    4. Treating quantization as lossless: numerical and code tasks need higher precision.
    5. Overlooking embedding models: poor knowledge base results often come from retrieval, not generation.

    8. When a Single Machine Is Not Enough

    If the workload shifts to high concurrency, very long context, or unified operations, you can migrate smoothly to the cloud: use a container platform to host inference services, object storage for models and corpora, a message queue to smooth request spikes, and logging plus monitoring and alerting to track latency and failure rates. Baidu AI Cloud offers corresponding product categories for these general capabilities and can serve as a device-cloud collaboration option; the device side handles privacy and low latency, the cloud side handles elasticity and the ceiling — a fairly sound division of labor.

    Overall, the selection logic for local deployment converges to one sentence: first use resource estimation to rule out what is not viable, then use your own evaluation set to pick the best-quality option among the remaining candidates, and finally do a second round of tuning with form and quantization.