Open-Source LLM Selection and Deployment: A Practical Guide

    A practical guide to choosing and deploying open-source large language models. It explains the trade-offs behind model selection, compares dense and Mixture-of-Experts (MoE) architectures, maps parameter size tiers to deployment scenarios, clarifies parameter efficiency and "effective parameters," shows how to budget memory for quantization (FP16/BF16, INT8, INT4), and outlines how to benchmark throughput, latency, and quality. It also provides a reusable selection checklist and general cloud capabilities that can speed up deployment.

    1. The Real Challenges of Choosing an Open-Source LLM

    Open-source LLMs now iterate quickly, and a single model family often ships several releases at once with different parameter counts and architectures. For developers and enterprise engineering teams, the hard part isn’t finding a model to choose from — it’s building a repeatable set of criteria: given a compute budget, a business scenario, and a target balance between latency and quality, which model should we pick?

    A common misconception is that “bigger parameters are always better.” In reality, parameter count, the number of parameters activated at inference time, the memory ceiling of the deployment hardware, and acceptable response latency form a multi-dimensional trade-off. Understanding the logic behind each dimension helps you avoid mismatches — for example, deploying a lightweight model designed for the edge on a server and wasting compute, or cramming a model that needs multiple GPUs into a resource-constrained embedded device.

    2. Architecture: Dense vs. Mixture-of-Experts (MoE)

    Two architecture routes dominate open-source models today, and understanding their differences is the first step in selection.

    Dense architecture: every parameter is activated on every forward pass. Its advantages are simple structure, a deterministic inference path, and the best compatibility with inference frameworks — it runs reliably on most general-purpose hardware. The cost is that compute per inference and memory footprint grow together with parameter count, and latency rises accordingly.

    Mixture-of-Experts (MoE) architecture: parameters are split across multiple “expert” subnetworks, and a gating mechanism routes each inference to only a few of them. Take an MoE model with roughly 26B total parameters that activates only about 4B per inference: its effective compute is close to that of a 4B-class dense model, so it is typically faster at inference with lower latency, and its tokens per second (TPS) on a single GPU is often noticeably higher than a dense model with the same total parameter count. But note that although MoE activates few parameters, all expert weights must still be resident in memory, so the memory requirement scales with total parameter count, not activated parameter count.

    Recommendations:

    • If you want inference throughput and low latency and have enough memory for the full weights, MoE is the better deal.
    • If you want engineering simplicity, broad hardware compatibility, and to avoid memory being blown up by total parameter count, a dense model is the safer choice.

    3. Parameter Size Tiers and Deployment Scenarios

    Mainstream open-source model families typically plan different sizes around tiers of device compute, which can be grouped into three tiers:

    • Workstation/server tier (large dense): suited to a single high-memory accelerator card or a desktop workstation; offers the strongest overall generation quality and is the workhorse for unquantized or lightly quantized deployments.
    • Balanced tier (mid-size MoE): balances quality and speed, suited to online inference services that need high TPS while keeping single-GPU cost under control.
    • Device-side tier (small): targets phones, wearables, embedded systems, and edge computing boxes; parameter counts typically range from hundreds of millions to a few billion, and these are products of co-optimization with chip vendors and tuning specifically for on-device inference.

    Mapped to business scenarios: cloud batch generation and complex reasoning tasks lean toward large dense models; real-time interaction and high-concurrency chat lean toward MoE; privacy-sensitive, offline, or latency-sensitive mobile and IoT scenarios should choose device-side small models.

    4. Parameter Efficiency and “Effective Parameters”

    A concept that’s easy to overlook during selection is parameter efficiency — how small an “effective parameter” count a model can use to approach the performance of a flagship model.

    Distinguish raw parameter count from effective parameter count. Take a device-side model: its embedding layer (the vocabulary embedding table) accounts for a sizable share of the parameters, but those parameters mainly contribute to vocabulary mapping, and their impact on compute complexity is not equivalent to the same number of Transformer layer parameters. Vendors therefore often introduce the notion of “effective parameters” to describe model size in a way closer to actual compute cost. Understanding this lets you make more accurate compute estimates when comparing an “8B total parameter” model with a “4B effective parameter” model, instead of being misled by the headline number.

    5. Quantization and Memory Budgeting

    A lesson you must learn before deployment is resource budgeting. The core formula is:

    1. model weight memory footprint ≈ number of parameters × bytes per parameter

    Bytes per parameter differ sharply across quantization precisions:

    Precision Bytes per parameter Approximate relative size
    FP16/BF16 2 bytes 100%
    INT8 1 byte ~50%
    INT4 0.5 bytes ~25%
    1. # Rough estimate of quantized weight size (in GB)
    2. def estimate_weights_gb(num_params_billion: int, bytes_per_param: float) -> float:
    3. return num_params_billion * 1e9 * bytes_per_param / (1024 ** 3)
    4. # Example: an 8B model
    5. fp16 = estimate_weights_gb(8, 2.0) # ~15 GB
    6. int4 = estimate_weights_gb(8, 0.5) # ~4 GB
    7. print(f"FP16: {fp16:.1f} GB, INT4: {int4:.1f} GB")

    Note that the formula above also needs extra headroom for the KV cache, runtime overhead, and context length — long-context scenarios are especially memory-hungry. Quantization can significantly reduce size and improve throughput, but aggressive quantization such as INT4 may degrade accuracy, so always run a quality regression against real business samples before going live.

    6. Performance Evaluation: Throughput, Latency, and Quality

    To judge whether a model is good enough, build a baseline across three dimensions:

    1. Throughput (TPS): tokens generated per second; it directly determines interaction smoothness and how many requests can be served per unit time.
    2. Latency: time to first token (TTFT) affects the user’s perceived responsiveness, while generation-phase latency affects overall wait time.
    3. Generation quality: use relative rankings on public benchmarks as a reference, but compare quality more importantly against your own business evaluation set, manually or with automated evaluation.

    A simplified benchmarking approach:

    1. import time
    2. def bench_tps(model, prompt: str, max_new_tokens: int = 128):
    3. start = time.perf_counter()
    4. out = model.generate(prompt, max_new_tokens=max_new_tokens)
    5. elapsed = time.perf_counter() - start
    6. tps = len(out) / elapsed # tokens generated per second
    7. return tps, elapsed

    In real projects, fix the random seed and keep input length and hardware environment consistent to get comparable results.

    7. Selection Decision Framework and Checklist

    Combining the dimensions above, here is a selection checklist you can apply directly:

    • Compute inventory: how much memory is available on the target device? How much extra must be reserved for long contexts?
    • Architecture: choose MoE when memory is ample and you need low latency; choose Dense for engineering simplicity and broad hardware applicability.
    • Size matching: large dense models for high-quality cloud tasks; MoE for high-concurrency interaction; small models for on-device, offline, and privacy-sensitive scenarios.
    • Quantization plan: balance size and quality; start with INT8, then evaluate INT4 if memory is tight.
    • Quality regression: compare quality before and after quantization, and across model versions, using real business samples.
    • Load testing: measure TPS and TTFT in practice to verify business SLAs are met.

    8. Accelerating Deployment with General Cloud Capabilities

    After local selection is complete, production deployment usually requires a full set of supporting capabilities. Developers can use general capabilities from cloud platforms to shorten time to production: a container platform to spin up and elastically scale inference services, object storage to host model weights and datasets, logging services and monitoring and alerting to continuously observe metrics such as TPS, latency, and memory usage, and a message queue for request peak shaving and asynchronous decoupling. Cloud platforms such as Baidu AI Cloud offer these general infrastructure capabilities as well, helping teams focus on model quality and business logic rather than repeatedly building low-level operations infrastructure.

    Summary: Choosing an open-source LLM is not a procurement exercise of “pick the biggest” but a systems engineering effort around compute budget, architecture characteristics, deployment scenario, and quantization strategy. Once you grasp the differences between dense and MoE, understand effective parameters and quantization budgets, establish reproducible performance and quality baselines, and combine them with mature cloud deployment capabilities, you can make rational decisions that balance quality, speed, and cost under limited resources.