Selecting and Deploying Open-Source LLMs: Cost, Deployment, and Risk Verification

    As open-source large language models (LLMs) see rapid growth in downloads, enterprises must evaluate three core aspects before adoption: keeping data on-premises, managing per-request inference costs, and ensuring stable operations. This article explores why companies choose open-source models, provides a practical cost calculation example, compares dense and Mixture of Experts (MoE) architectures, and addresses function calling and long-context verification. It also offers a comprehensive selection checklist and a hands-on guide for deploying models on Kubernetes using vLLM.

    Public data indicates that downloads of open-source large language models (LLMs) are growing rapidly. While specific figures vary depending on the tracking platform and methodology, the overall trend is clear.

    For enterprises, the real decision comes down to three questions: Can the data stay on the intranet? Is the per-request cost acceptable? Can the team run the model stably? Below, we will break down these three aspects and provide actionable checklists.

    1. Why More Enterprises Choose Open-Source Models

    1.1 Data Stays Local

    In an API-based model, the service provider dictates the model version, rate limiting rules, and data retention policies. By obtaining the full model weights, enterprises can run the model on private clouds or edge devices, ensuring raw data never leaves the intranet. Industries with strict data sovereignty requirements—such as finance, government, and manufacturing—often find local deployment to be the mandatory first step.

    Model version control is also handled by the user. Before upgrading, teams can run regression testing on their proprietary datasets to ensure the new version does not degrade performance on critical tasks.

    1.2 Cost Depends on Utilization

    The per-request cost of an open-source model is not a fixed value. It is determined by hardware or rental costs, effective throughput, and the degree of optimization. The calculation is as follows:

    Per-request cost = Hardware cost per hour / Effective requests per hour

    “Effective requests” here refers to requests completed within the agreed-upon latency and that pass output format validation. Failed or timed-out requests should not be counted.

    There are three common optimization techniques:

    • Quantization: Compressing weights from FP16 to INT8 or INT4 reduces VRAM usage. However, precision may degrade, requiring testing on your own data.
    • Continuous Batching: Dynamically merging requests to increase GPU utilization.
    • KV Cache Reuse: Requests sharing the same prefix can reuse previously computed cache, reducing redundant calculations.

    2. Inference Cost Calculation Example

    Suppose a team rents two 80GB VRAM GPUs for a total of 24 CNY per hour. Benchmark testing shows that, under the condition of P95 latency not exceeding 3 seconds and passing output format validation, the system can handle 1,800 effective requests per hour. The calculation would be:

    Per-request cost = 24 / 1800 ≈ 0.0133 CNY

    These numbers are merely examples; in practice, you should substitute them with your actual rental prices and benchmark results.

    Traffic volume significantly impacts the results. If there are only 200 requests per hour, the same hardware cost spread across each request would be 24 / 200 = 0.12 CNY, which might be higher than the unit price of a cloud API. Before opting for local deployment, estimate the costs of both approaches using real traffic and compare the unit costs for the same tasks.

    When stress testing, use real request lengths. The longer the input and output, the higher the unit cost typically is.

    3. How to Choose the Technical Route

    3.1 Dense Models vs. MoE Models

    Dense models utilize all parameters during every inference step. Their structure is simple, and their behavior is relatively easy to predict.

    Mixture of Experts (MoE) models use a routing mechanism to activate only a portion of the expert modules, reducing the computation required for a single token. However, MoE models usually require all expert parameters to reside in VRAM. When VRAM is insufficient, you can use parameter offloading or quantization to reduce the footprint, though actual usage depends on the inference framework and parallelization strategy. Therefore, lower computation in MoE models does not equate to lower VRAM demands.

    VRAM can be estimated using this empirical formula:

    VRAM ≈ Parameter count × bytes per parameter + KV cache + runtime overhead

    For example, a 70B parameter model at FP16 precision requires about 140GB of VRAM just for the weights. When selecting a model, evaluate the total parameter count, active parameter count, and VRAM usage simultaneously.

    3.2 Function Calling and Tool Permissions

    A new generation of open-source models typically supports function calling. The model outputs the tool name and parameters in JSON format, which the program executes before returning the result to the model—enabling connections to search engines, calculators, and databases.

    Tool selection capabilities should be tested on your specific tasks. Public leaderboard scores do not directly translate to business outcomes. Tool calling should follow the principle of least privilege, exposing only necessary tools. Write operations—such as modifying a database or sending messages—should require manual confirmation before execution.

    3.3 Long Context Requires Separate Verification

    Some models claim to support context windows of 128K tokens or more. The window length only indicates the maximum input the model can receive; it does not guarantee that the model can accurately retrieve information from every position in a long text. Furthermore, longer contexts consume more VRAM for KV caching.

    Before going live, conduct a position recall test:

    1. Construct 20 business documents of approximately 32K tokens each.
    2. In each document, sequentially place the same fact at the beginning, the one-quarter mark, the middle, the three-quarter mark, and the end.
    3. Query each position 20 times and record the percentage of correct answers.
    4. Have the team set a pass criteria, such as no less than 95% recall at any position.

    If a specific position shows significantly lower recall, shorten the business input length or switch models and retest.

    4. Selection Checklist

    During selection, verify each item according to the table below and record the results in a selection document.

    Dimension Focus Verification Method
    Task Adaptability Model performance on target tasks Conduct offline evaluation with business samples; record accuracy and format error rate
    Inference Efficiency Latency and throughput at the same precision Stress test on target hardware with real request lengths; record P95 latency
    Community Activity Issue response speed, number of adapters and tutorials Check closed Issues over the past three months; confirm framework-supported versions
    License Commercial use and redistribution terms Check Apache-2.0, MIT, or community licenses for commercial restrictions, user scale caps, and redistribution obligations

    Licenses need to be recorded separately. Community licenses often include user scale caps or specific use case restrictions, and must be confirmed by the legal team before launch. Below is a recording template:

    • Model name and version:
    • License name and link:
    • Commercial use allowed:
    • User scale or revenue cap:
    • Redistribution or SaaS provision allowed:
    • Legal approver and date:

    5. Deployment: Running vLLM on Kubernetes

    The following checklist includes PVC, Deployment, and Service. It can be saved directly as llm-inference.yaml. Before use, replace the following:

    • storageClassName: Change to a storage class in your cluster that supports ReadWriteMany. If unavailable, use ReadWriteOnce, but ensure only one Pod mounts it.
    • /models/your-model: Change to the actual path of the model directory in the PVC, and ensure --served-model-name matches it.
    • image: Confirm the image tag exists and is compatible with the model version.
    • nvidia.com/gpu and --tensor-parallel-size: These should match and be set to the actual number of GPUs in use.
    1. apiVersion: v1
    2. kind: PersistentVolumeClaim
    3. metadata:
    4. name: model-pvc
    5. spec:
    6. accessModes:
    7. - ReadWriteMany
    8. storageClassName: <your-storage-class>
    9. resources:
    10. requests:
    11. storage: 200Gi
    12. ---
    13. apiVersion: apps/v1
    14. kind: Deployment
    15. metadata:
    16. name: llm-inference
    17. spec:
    18. replicas: 1
    19. selector:
    20. matchLabels:
    21. app: llm-inference
    22. template:
    23. metadata:
    24. labels:
    25. app: llm-inference
    26. spec:
    27. containers:
    28. - name: vllm
    29. image: vllm/vllm-openai:v0.6.0
    30. args:
    31. - "--model"
    32. - "/models/your-model"
    33. - "--served-model-name"
    34. - "your-model"
    35. - "--tensor-parallel-size"
    36. - "2"
    37. - "--max-model-len"
    38. - "8192"
    39. ports:
    40. - containerPort: 8000
    41. resources:
    42. limits:
    43. nvidia.com/gpu: "2"
    44. readinessProbe:
    45. httpGet:
    46. path: /health
    47. port: 8000
    48. initialDelaySeconds: 60
    49. periodSeconds: 10
    50. volumeMounts:
    51. - name: model
    52. mountPath: /models
    53. readOnly: true
    54. - name: dshm
    55. mountPath: /dev/shm
    56. volumes:
    57. - name: model
    58. persistentVolumeClaim:
    59. claimName: model-pvc
    60. - name: dshm
    61. emptyDir:
    62. medium: Memory