How to Choose an Open-Source LLM: Architecture, Evaluation, and Deployment Checks
A practical guide to selecting open-source large language models. This article compares dense, Mixture-of-Experts (MoE), and on-device architectures, explains how to build reproducible evaluations for quality, long-context, and function calling, and provides deployment checklists for quantization and load testing before going to production.
How to Choose an Open-Source LLM: Architecture, Evaluation, and Deployment Checks
1. Why Model Size Families Have Become Standard Practice
Offering only a single flagship model creates tension between capability ceilings and deployment costs. Online services, desktop workstations, mobile devices, and IoT hardware differ widely in compute budgets, power consumption, memory bandwidth, and latency requirements—no single model fits all of these scenarios well.
Size families solve this by letting models of different scales share the same training methodology, tokenizer, instruction format, and safety policies. The same prompt structure and interface can move across hardware. A team can validate a business workflow on a large model first, then migrate it to a smaller one—an effort usually far smaller than rewriting the system.
Shared interfaces do not mean equal capability. Smaller models still lag in complex reasoning, long-context consistency, and multi-step tool use, so real testing before migration is mandatory.
2. Trade-offs Across Three Architecture Types
2.1 Dense Models: Stable Quality, Higher Deployment Cost
Dense models use all parameters on every inference. The computation path is fixed, latency is predictable, and output consistency tends to be good. They suit quality-sensitive, low-concurrency tasks such as contract review, long report summarization, and complex code changes.
VRAM is the main barrier. With weights stored in BF16, each parameter takes 2 bytes, so a 30B-parameter model needs roughly 60GB of VRAM for weights alone. Add the KV cache, activations, and framework overhead, and a single 80GB accelerator may barely suffice—or not. With 4-bit quantization, weight usage drops to roughly the 15GB range (excluding extra storage for quantization parameters), but accuracy loss must be validated separately.
2.2 Mixture-of-Experts Models: Less Compute per Token, But No VRAM Savings
MoE models use a routing mechanism so only a subset of experts participates in each token’s computation. Total parameters are large, but the parameters activated per token are relatively few. In theory, this yields higher throughput and lower first-token latency on the same hardware.
A commonly overlooked point: the weights of all experts typically must stay resident in VRAM, so MoE VRAM requirements remain close to the total parameter scale. MoE saves computation per token, not memory.
MoE performance depends on several engineering conditions:
- Routing balance. When certain experts are selected too often, load skews and tail latency rises.
- Batch size. Larger batches increase expert scheduling overhead and memory bandwidth pressure; throughput may not scale linearly.
- Expert parallelism strategy. Cross-device communication can become a bottleneck.
- Post-quantization accuracy. The routing layer is relatively sensitive to numerical error and needs separate evaluation.
2.3 On-Device Effective-Parameter Models: From “Runs” to “Runs Well”
On-device models target phones, IoT devices, and edge computing boxes. These often use techniques such as Per-Layer Embedding (PLE): each decoding layer carries its own small embedding table. The tables may be large in total, but inference is mostly table lookup, so the parameters actually involved in matrix computation are far fewer than the total parameter count in the model file.
Before selecting a model, distinguish these concepts:
- Total parameters: all stored weights in the model, including embedding tables.
- Effective parameters: the parameter scale actually participating in matrix computation per token during inference.
- Activated parameters: for MoE models, the expert parameters actually activated per token.
- File size: the size of the model file on disk, determined by quantization method and storage format.
“Effective parameters” typically come from the vendor’s model card or architecture documentation. To verify independently, read the model config file, then use the framework’s profiler or per-layer statistics of weights involved in forward computation. Parameter counts on leaderboards without a stated methodology cannot be compared directly.
For on-device selection, measure the following:
- Model file size and download time.
- Cold-start time, i.e., from process launch to first output.
- Resident memory and peak memory.
- First-token latency and sustained generation speed.
- Power consumption and temperature during continuous operation.
- Task accuracy after quantization.
- Preprocessing time for audio, image, and other inputs.
Thermal constraints on mobile devices often matter more than peak performance. After several minutes of continuous generation, devices throttle, and the speed users perceive may be far below benchmark results.
2.4 Comparison and Decision Tree
| Dimension | Dense Model | MoE Model | On-Device Small Model |
|---|---|---|---|
| Typical scenarios | Contract review, long report summarization, complex code changes | Online Q&A, batch classification, high-concurrency function calling | Phone assistants, offline voice, edge devices |
| VRAM needs | High—all parameters participate and stay resident | High—total parameters resident, but compute per token is low | Low, but confirm peak memory |
| Per-request latency | Predictable; slower with more parameters | Usually lower first-token latency, depending on routing and batching | Depends on device compute and throttling |
| Throughput | Limited by VRAM and compute | Advantages at high concurrency, but not necessarily linear | Low per device |
| Cost | High hardware or cloud cost | Low per-token compute, but VRAM cost stays high | Low cloud cost, high on-device adaptation and testing effort |
| Capability ceiling | High; better long-context consistency | Close to large models; verify routing stability | Weaker at complex reasoning and multi-step tool use; test it |
| Main risks | KV cache grows with context | Routing skew, communication bottlenecks, quantization sensitivity | Thermal throttling, slow cold start, peak memory overrun |
Use this decision tree:
- Does the task require stable, reproducible offline output? If yes, and VRAM on one card or machine is sufficient, evaluate dense models first.
- Is it a high-concurrency online service sensitive to first-token latency? If yes, evaluate MoE models—and run routing balance tests first.
- Will it run on phones, single-board computers, or embedded devices? If yes, evaluate on-device models and trust only on-device measurements.
- If none of the above apply, choose a size within the same model family based on available VRAM and budget, then compare candidates on your own evaluation set.
3. How to Design Evaluations
Leaderboards are useful for initial screening, not for final selection decisions. Benchmarks run on specific datasets, prompts, and inference settings, and only indicate relative position.
Evaluate at least three categories of metrics:
- General quality, including general conversation, text understanding, and instruction following. When using public leaderboards for screening, verify the benchmark name, model version, evaluation date, whether reasoning mode was enabled, and the reasoning budget.
- Task quality, measured with your own business data.
- Cost metrics, mainly token consumption and elapsed time per task.
3.1 Small Evaluation Set Template
Each sample should include the following fields:
| Field | Description | Example |
|---|---|---|
| sample_id | Unique sample ID | ctr-0012 |
| task_type | Task type | Clause extraction, summarization, function calling |
| input | Real input or sanitized input | Selected clauses from a 40-page contract |
| context_length | Estimated input length | ~12k tokens |
| expected | Ground-truth answer or expected structure | JSON containing party_a, party_b, amount |
| rubric_id | Scoring rubric ID | rubric-extract-v1 |
| tags | Labels such as long text, abnormal input | long-text, missing-field |
The set doesn’t need to be large, but it must cover your real input distribution. Include normal samples, long-text samples, format-strict structured-output samples, and abnormal samples such as empty input, overly long input, garbled text, and out-of-scope instructions.
3.2 Example Scoring Rubric
For a clause extraction task, a rubric might look like this:
- Field completeness: all required fields present scores 1 point; deduct 1 point per missing required field, minimum 0.
- Field correctness: extracted value matches ground truth exactly scores 1 point; numerically or date-format equivalent scores 1 point; otherwise 0.
- Structural validity: output passes JSON parsing and field-type validation scores 1 point; otherwise 0.
Fix the rubric before evaluation and do not change it midway. If reviewer disagreement on the same sample exceeds an agreed threshold, revise the rubric first, then re-score.
3.3 Recording Reproducibility Conditions
Record the following for every evaluation run; otherwise scores cannot be reproduced or compared later:
- Model name, version, weight file hash or download source.
- Inference framework and version, plus CUDA or other acceleration library versions.
- Full text of system prompts, evaluation prompts, and few-shot examples.
- Decoding parameters: temperature, top_p, top_k, max output length, random seed.
- Whether reasoning mode was enabled, and the reasoning budget setting.
- Evaluation date, hardware model, and driver versions.
3.4 Input and Output Token Accounting
Use the same tokenizer throughout, and record per request:
- Input tokens: including system prompt, conversation history, tool definitions, and retrieved documents.
- Output tokens: all tokens generated by the model. If the model outputs reasoning traces, count those too.
Report both mean and P95. Input tokens drive first-token latency and prefill cost; output tokens drive generation time and usage-based billing. Keep the two separate.
4. Long Context and Function Calling
4.1 Estimating Long-Context Costs
Supporting long context doesn’t mean you should fill it. Longer context raises first-token latency, increases KV cache usage, and may degrade the model’s use of information in the middle of the context.
Estimate per-token KV cache usage with:
Bytes per token of KV cache = 2 × num_layers × num_KV_heads × head_dim × bytes_per_element
The factor of 2 accounts for K and V caches. For a model with 48 layers, 8 KV heads, head dim 128, and BF16 storage (2 bytes per element), each token takes about 196,608 bytes—192 KiB. At a 32k-token context, a single sequence needs roughly 6 GiB; at batch size 8, the KV cache alone needs about 48 GiB. These numbers illustrate the calculation method; use the actual model’s config file for real parameters.
Safer approaches include:
- Chunked summarization: split long documents into chunks, summarize, then answer questions over the summaries.
- Retrieval-augmented generation (RAG): put only relevant passages into context.
- Sliding window: keep only the most recent turns of dialogue or document fragments.
Long-context testing should use multiple length tiers—for example, 4k, 16k, and 32k—and record first-token latency, generation speed, peak VRAM, and task accuracy at each.
4.2 Function Calling in Practice
The hard part of function calling is keeping parameter names, types, required fields, and value ranges stable. A model producing plausible-looking JSON does not mean the call will succeed.
Recommended steps:
- Define every function with a JSON Schema, specifying name, description, parameter types, the required list, enum values, and defaults.
- Add a validation layer between model output and the actual call. On validation failure, return the error to the model for a retry, capped at a maximum number of attempts—e.g., 2.
- Whitelist function names and reject unregistered ones.
- Apply business-level parameter validation, e.g., amounts cannot be negative and dates must fall within a reasonable range.
- Truncate and format-check tool return values to prevent oversized responses from filling the context.
A function calling test set should include:
- Normal requests that should trigger a function call.
- Requests that should trigger a call but miss required parameters.
- Requests with out-of-range values or wrong types.
- Ordinary questions that should not trigger any call.
- Composite requests requiring two functions.
Track three metrics: function selection accuracy, parameter validity rate, and required-field completeness rate. Keep the same test set consistent across candidate models.
5. Quantization, Load Testing, and Deployment Checklists
The following checklists apply to the full path from test environment to production. Thresholds shown are examples; set them according to your acceptable quality degradation and latency targets.
5.1 Quantization Checklist
- Record weight precision before and after quantization, e.g., BF16, INT8, INT4.
- Compare task metrics before and after quantization on your own evaluation set, with an acceptable degradation threshold.
- For MoE models, check that routing distributions remain close to pre-quantization behavior.
- Measure first-token latency, throughput, and peak VRAM after quantization.
- For on-device models, measure cold-start time and sustained operating temperature on the target device.
5.2 Load Testing Checklist
- Design the request distribution: input length distribution, output length distribution, and concurrency levels.
- Warm up for at least 5 minutes before formal sampling to avoid unwarmed caches skewing results.
- Record P50, P95, and P99 latency at multiple concurrency tiers (e.g., 1, 8, 32).
- Run each tier long enough—recommend at least 30 minutes—to observe VRAM growth and fragmentation.
- Record error rate, timeout rate, and out-of-memory (OOM) counts.
- For MoE models, monitor per-expert load share. For example, trigger an alert when one expert’s request share exceeds 3× the average; calibrate the threshold against your actual distribution.
