Open-Source LLM Selection and Private Deployment: A Practical Engineering Checklist

    Selecting and deploying open-source Large Language Models (LLMs) requires rigorous evaluation and engineering practices. This article provides a practical checklist for LLM selection and private deployment, covering metrics for model popularity, capability boundary testing (instruction following, long context, reasoning), task-based model routing, deployment strategies (quantization, inference engines, prefill/decode separation), RAG optimization, data security, and multi-agent collaboration.

    1. Defining the Metrics: What Constitutes Model Popularity?

    Model download counts are often cited to show a growing ecosystem, but this number is rarely a reliable metric for judgment. Different platforms have varying statistical calibers; some count every pull, while others deduplicate by unique accounts. Mirror sites, CI pipelines, and automated scripts also repeatedly pull the same weights, inflating the numbers.

    Therefore, before citing download counts, record four pieces of information: the statistical platform, time range, included model versions, and deduplication rules. If this information is unavailable, do not treat the download count as factual evidence. Instead, use more controllable metrics, such as your team’s performance on evaluation sets, inference costs, and maintenance activity.

    2. Capability Boundaries: What Works Out-of-the-Box vs. What Needs Testing

    Over the past two years, open-source models have shown significant progress in instruction following, code generation, and multi-step reasoning. However, “improved capabilities” does not mean “ready for your business.” To determine if a model fits your business needs, you must test it on your own data.

    2.1 Instruction Following: Build a Small Evaluation Set

    Prepare 50 to 100 samples for each task type, covering both normal and edge-case inputs. For output formatting, track the following three metrics:

    • JSON Valid Rate: Whether the output can be directly parsed by a standard parser.
    • Word Count Constraint Pass Rate: Whether the length limits are respected.
    • Factual Error Rate: The proportion of outputs containing erroneous information, verified by manual or rule-based spot checks.

    Compare different models using the same prompt template. If a model’s JSON valid rate falls below business requirements, try adjusting the prompt or adding structured output constraints before deciding to switch models.

    2.2 Long Context: Verify the Window, Then Test Recall

    The context window size in a model card is a theoretical upper limit; the actual reliable range is usually smaller. Testing methods include:

    • Place key information at the beginning, middle, and end of documents of varying lengths (e.g., 8K, 32K, 64K tokens) and check if the model can answer accurately.
    • Record the Time to First Token (TTFT) and total latency for each request. Long inputs significantly increase computational load, and costs usually grow with input length.
    • Compare the answer accuracy and per-request cost between inputting the full document versus using RAG chunking.

    Direct full-text input is suitable for scenarios where the total document volume is small, update frequency is low, or a single task requires reading the entire text (e.g., summarizing a full technical manual). RAG should still be used when the document volume exceeds the model’s window, the knowledge base is updated frequently, documents need to be filtered by user permissions, or per-query costs must be kept low.

    2.3 Reasoning Capability: Evaluate with Task Results, Not Subjective Feelings

    Reasoning capability evaluation should be based on verifiable tasks, such as unit test pass rates, SQL execution success rates, and standard answer matching rates for math problems. If a model’s pass rate on the evaluation set is close to others, prioritize the solution with lower cost and latency.

    3. Selection: Tiering by Task Complexity

    Using a single large model to handle all requests is costly and leads to unstable latency. A more common approach is to build a model routing gateway to dispatch requests to models of different tiers. The table below serves as a starting point; specific thresholds should be adjusted based on your evaluation results.

    Task Type Example Suggested Model Tier Latency Target (p95) Quality Metric Fallback Handling
    Classification, Keyword Extraction Ticket classification, sensitive word tagging Quantized small model < 300ms Accuracy not below business baseline Upgrade to medium model if confidence is low
    Dialogue generation, Format conversion Customer service reply templates, JSON conversion Medium-sized model < 1s JSON valid rate > 99% Retry once on validation failure, then upgrade
    Multi-step reasoning, Code modification Complex Q&A, code review Larger dense model < 5s Test case pass rate Upgrade to a stronger model or escalate to human
    Long document understanding Contract review, long report summarization Model supporting long context Depends on document length Key information recall rate Process in segments and then summarize

    Routing gateway design key points:

    1. Use rules to determine the request type first, such as keywords, input length, or API source. If rules cannot decide, use a small model for classification.
    2. Set confidence levels or validation conditions for each tier. Automatically upgrade on validation failure and log the reason for subsequent optimization of routing rules.
    3. Weekly statistics on cost per 1,000 requests, p95 latency, and evaluation pass rate. If the pass rate of a tier continues to decline, check if the input distribution has shifted.

    4. Deployment: Quantization, Inference, and Resources

    4.1 Evaluation Steps for Weight Quantization

    For scenarios with limited VRAM, weight-only quantization can be used to reduce memory footprint. AWQ and GPTQ fall into this category, compressing model weights to 4-bit while keeping activations at higher precision. Quantization introduces precision loss, which varies depending on the model and task, making evaluation mandatory.

    Recommended steps:

    1. Run the original model in FP16 (or BF16) precision, record baseline scores on the evaluation set, and note VRAM usage and throughput.
    2. Use a fixed version of the quantization tool to generate 4-bit weights, and log the tool version, calibration dataset, and quantization parameters.
    3. Run the quantized model on the same evaluation set and compare task score changes. If scores on critical tasks drop by more than 1 to 2 percentage points, re-evaluate the quantization scheme or switch to a higher-precision version.
    4. Stress test at the target concurrency level, recording throughput (tokens/s) and p95 latency.
    5. Set rollback conditions: switch back to the original version if task scores drop beyond the threshold or if p95 latency exceeds the go-live standard.

    All version numbers, dependency libraries, and model hashes should be documented in the deployment guide for reproducibility and rollback.

    4.2 Choosing an Inference Engine

    When selecting an inference engine, prioritize open-source engines that support PagedAttention. These engines manage the KV Cache by pages, reducing memory fragmentation and improving concurrency. The specific choice should depend on hardware, framework compatibility, and the team’s maintenance capabilities, rather than just benchmark rankings.

    4.3 Prefill and Decode Separation

    The Prefill stage processes the input and is computationally intensive. The Decode stage generates output token by token and is primarily limited by memory bandwidth. When a business has both long-input requests and real-time conversational requests with short outputs, the two types of requests can block each other.

    Some inference frameworks support deploying these two stages to different resource pools. Whether to adopt this architecture depends on traffic characteristics: if long requests account for less than 10% and p95 latency already meets the target, splitting is usually unnecessary. If long requests are frequent and TTFT for short requests degrades noticeably, consider splitting and validate the benefits with stress test data.

    5. RAG: Cleaning, Chunking, and Reranking

    In private knowledge base scenarios, RAG based on chunked embeddings and vector retrieval remains a common practice. Effectiveness issues usually arise in the data cleaning and chunking stages, not the model itself.

    5.1 Data Cleaning

    • Remove repetitive content like headers, footers, page numbers, and tables of contents.
    • Convert tables into text with headers to avoid losing row and column information.
    • Add metadata to each chunk, including document title, section name, update time, and access permissions.

    5.2 Chunking Parameters

    The following are starting parameters that need adjustment on your evaluation set:

    • Splitting method: Recursive character text splitter, segmenting by paragraph, sentence, then character.
    • Chunk length: 300 to 800 tokens. Larger values for technical documents, smaller values for Q&A short texts.
    • Overlap ratio: 10% to 20% of the chunk length.

    5.3 Retrieval and Reranking

    • Recall stage: Vector retrieval fetches Top-K, where K is 20 to 50.
    • Reranking stage: A reranker model scores the recalled results, passing only the Top 3 to 5 chunks to the generation model.

    This two-stage design improves factual accuracy of answers but adds latency for an extra model call. Whether to keep reranking should be based on evaluation results.

    5.4 Acceptance Metrics

    • Recall@K: The proportion of questions in the evaluation set where the document containing the standard answer is recalled. It is recommended to be no less than 0.85 before launch; this is a starting point and should be adjusted based on business risk.
    • Answer Faithfulness: Whether every fact in the answer is supported by the retrieved chunks. Can be manually spot-checked, at least 50 cases per week.
    • Citation Accuracy: Whether the sources provided in the answer correctly point to the original text paragraphs.

    5.5 Troubleshooting Checklist

    • Answer cannot find relevant content: Check if chunking scattered key information, try adjusting chunk length, or add query rewriting.
    • Relevant content ranks low: Check if the reranker matches the business corpus, or increase the recall quantity.
    • Answer hallucinates information: Instruct the prompt to only answer based on the given chunks and explicitly refuse to answer when there is no supporting evidence.

    6. Data Security, Licensing, and Go-Live Acceptance

    The primary benefit of private deployment is keeping data within your domain. To ensure this, note the following:

    • Vector indices also require access control. Retrieval results must be filtered by user permissions before being sent to the model.
    • Do not log complete sensitive inputs and outputs; only retain desensitized request IDs and statistical fields.
    • Check the model license before launch to confirm if commercial use is allowed, and if there are restrictions on attribution, redistribution, or use cases.

    Pre-launch acceptance checklist:

    1. Task scores on the evaluation set meet baseline requirements.
    2. p95 latency and cost per 1,000 requests are within budget.
    3. Stress test passes the target concurrency.
    4. Rollback plan has been rehearsed, and switch time is acceptable.
    5. Monitoring covers request volume, error rate, escalation ratio, and user feedback.

    7. Multi-Agent Collaboration: Start with Two Agents

    A multi-agent system is an architecture where multiple models collaborate based on task division. Its benefits rely on clear interfaces; otherwise, errors will amplify across agents. It is recommended to start with two agents: one for execution and one for validation.

    When delegating tasks, each message should contain at least the following fields:

    • task_id: Task identifier for tracking.
    • goal: Task objective, described in one sentence.
    • input: Input data or reference location.
    • constraints: Constraints, such as word limits or banned words.
    • output_schema: Output structure, typically a JSON Schema.
    • timeout and retry_limit: Timeout duration and maximum retry count.
    • fallback: Fallback model or manual handling entry on failure.

    Result confirmation is handled by the validation agent. It first checks if the output conforms to the Schema, then verifies if key facts are supported. On validation failure, a retry is executed; if it still fails, it escalates to a larger model or routes to human handling, logging the failure reason.

    Only after both agents’ success rate and cost meet expectations should you consider adding new roles. Every additional agent adds an extra model call and another layer of potential failure.