Three takeaways first: first, open weights are not open source in the OSI sense. Training data, training code, and commercial-use terms all depend on the specific license. Second, self-hosting only wins on cost when your call volume is high and steady, or when hard private-deployment requirements apply. Third, quantization and parameter-efficient fine-tuning are both measurable engineering trade-offs. Always validate accuracy regressions against the same evaluation set instead of shipping on gut feel.

    Open-weight model releases have made running LLMs on your own infrastructure a practical option. But "open weights" is not the same as open source, self-hosting does not automatically beat API costs, and private deployment does not guarantee compliance. This guide covers how to choose between an open-weight model and a closed API, how to estimate whether self-hosting pays off, how to evaluate instruction following, long-context handling, long-horizon tasks, and deep research, and how to deploy safely with quantization, PEFT or full fine-tuning, and a gradual rollout with clear rollback thresholds.

    Three takeaways first: First, open weights are not open source in the OSI sense. Training data, training code, and commercial-use terms all depend on the specific license. Second, self-hosting only wins on cost when your call volume is high and steady, or when hard private-deployment requirements apply. Third, quantization and parameter-efficient fine-tuning are both measurable engineering trade-offs. Always validate accuracy regressions against the same evaluation set instead of shipping on gut feel.

    1. Open-weight models or closed APIs?

    First, separate “open source” from “open weights.” What the industry usually calls open-source LLMs are mostly open-weight models: the vendor publishes the parameter files needed for inference, and developers can download and run them on their own infrastructure. This is not open source in the OSI sense. Training data, training code, and the data mix are often not released, and whether you can use the model commercially or redistribute it, and whether derivative works must also be open, all depend on the specific license. Apache-2.0 and MIT are relatively permissive; some community licenses add conditions on user scale, use cases, or attribution. The freedom that open weights provide is therefore more accurately described as the right to redistribute and build derivative works within the limits of the license.

    What open weights actually change is three things. First, control over data flow: inference runs in your own environment, so business data never has to be sent to a third-party API. That does not automatically satisfy compliance, though. You still need to classify data and enforce access controls, and to obtain weights from official sources and verify their origin and hashes. Second, deep customization: you can run continued pre-training on the base model or fine-tune it for your domain. Third, a different cost structure: pay-as-you-go becomes a budgetable compute and operations investment. Whether that pays off is covered in Section 2.

    How the community ecosystem forms. Once a generally capable open-weight model is released, the community builds quantized versions, fine-tunes, inference-framework support, benchmark results, and sample applications around it. That chain is the main way the ecosystem spreads. Download counts are a common popularity metric, but cite them carefully. Downloads counted on platforms such as Hugging Face are public figures, so state the model scope (parameter-size range, license type) and the time window. Ecosystem growth also depends on license friendliness, toolchain maturity, and the model’s own capabilities. It should not be attributed to open weights alone.

    Dimension Self-hosted (open weights) Closed API
    Data compliance Data stays inside your network, which makes privatization and auditing easier Requires assessing data-export rules and third-party processing terms
    Cost structure Mainly GPU instances, storage, and staff; high upfront investment Usually billed per token, with almost no upfront cost
    Ops burden You run inference services, scaling, and failure handling Handled by the provider
    Peak elasticity You must reserve capacity for peak load, leaving it idle at troughs Elasticity is provided by the provider and is usually smoother
    Capability updates You choose when to upgrade, but must validate each change yourself Follows the provider’s release cycle and may change without your control
    Lock-in risk Low, since you hold the weights and data Higher, because APIs, billing, and rate limits must be migrated

    2. Is self-hosting actually cheaper than the API? A rough calculation

    Most mainstream closed services bill by token usage. A rough model is: self-hosted monthly cost ≈ GPU instance cost × number of instances + storage cost + share of ops staff time. Self-hosting only has a chance of being cheaper when the self-hosted monthly cost is less than expected monthly token volume × API price per token.

    Three boundaries matter:

    • Low call volume: the API is clearly cheaper.
    • Piky load: self-hosting means provisioning for the peak, and idle capacity during troughs pushes up the unit cost.
    • Early stages: during cold start, while demand is still taking shape, or while model capabilities are still evolving quickly, the API is usually the better fit.

    Self-hosting tends to win when you have high and steady call volume, hard private-deployment requirements, or frequent domain fine-tuning. Run a load test with two weeks of real traffic before deciding on capacity and model choice.

    3. Four key capabilities to evaluate: methodology over leaderboard

    Instruction following: measure the constraint satisfaction rate

    For multi-constraint, multi-step instructions, use an IFEval-style benchmark or your own constraint set. Report a constraint satisfaction rate rather than a vague overall score.

    Long-context understanding: measure mid-document retrieval and multi-hop QA

    How much text fits in the context window matters less than stability across positions. Use RULER- or LongBench-style benchmarks, and pay particular attention to information retrieval from the middle of long inputs and synthesis across paragraphs.

    Long-horizon tasks: measure task completion and goal retention

    For multi-step planning, tool calling, and state maintenance, track the task completion rate and tool-call success rate. Also check whether the model drifts from its goal as the number of steps grows.

    Deep research: measure conclusion traceability and factual consistency

    For open-ended questions that require searching, filtering, and synthesizing information from multiple sources into structured conclusions, focus on how traceable the conclusions are and how factually consistent they are. Retrieved content such as web pages is untrusted input, so guard against prompt injection. Mark and isolate prompt instructions from external text, apply least privilege to tool calls, and require human confirmation for sensitive actions such as deletion, transfers, and publishing.

    4. Common pitfalls in deploying open-weight models: from selection to gradual rollout

    1) Selection checklist

    • Does the license allow commercial use and redistribution? Are there user-scale or use-case restrictions?
    • Do Chinese-language ability, long context, and tool calling meet your requirements (validated against your business data, not leaderboard rankings)?
    • Memory and throughput baseline: parameters × bytes per parameter at the target precision + KV cache + activation overhead
    • Quantization scheme and acceptable accuracy-regression threshold
    • Evaluation set and a reproducible offline evaluation pipeline
    • Clear upgrade and rollback paths

    2) Quantization: how much memory you save and how much accuracy you lose

    Quantization stores weights and activations at lower numerical precision. Relative to BF16 weights, W8A16 roughly halves weight memory, and W4A16 cuts it to about a quarter. Activations are still computed in FP16. The actual savings vary with the inference framework, its operators, and the share taken by the KV cache, which can become the main cost in long-context scenarios. Common options suit different use cases:

    • GPTQ and AWQ: post-training quantization, suitable for compressing an existing model to low bit widths.
    • GGUF: mostly used for on-device and CPU inference.
    • FP8: requires hardware support from newer GPUs.
    1. # Pseudocode: loading a low-bit quantized model and running inference
    2. quant_config = {
    3. "weight_bit": 8, # bit width of the weights
    4. "activation_bit": 16, # bit width of the activations
    5. "group_size": 128, # granularity of group-wise quantization
    6. }
    7. model = load_model(base_path)
    8. model = apply_quantization(model, quant_config) # convert weights to a low-bit representation
    9. prompt = "Summarize the main points of the following long document..."
    10. inputs = tokenize(prompt)
    11. output_tokens = model.generate(inputs, max_new_tokens=1024, temperature=0.7)
    12. print(detokenize(output_tokens))

    Lower bit widths are not automatically better. The right approach is to compare metrics before and after quantization on the same evaluation set: task accuracy, instruction constraint satisfaction rate, and long-document multi-hop QA. Then compare the results against your preset acceptable-regression threshold. If the threshold is exceeded, switch schemes or keep a higher-precision version.

    3) Full fine-tuning or PEFT?

    With a suitable rank, enough data, and a task of moderate complexity, PEFT methods such as LoRA and QLoRA can approach full fine-tuning results with much lower memory and storage requirements. Validate this with a small-scale A/B comparison. However, injecting substantial new domain knowledge or significantly changing the output distribution is usually more reliable with full fine-tuning.

    Also note that the memory and storage savings occur during training. At inference time, loading an adapter separately, or switching between multiple adapters, does not reduce memory use proportionally. The quality and mix of the fine-tuning data often matter more than its total volume.

    4) Evaluation and gradual rollout: when to scale up and when to roll back

    Before launch, complete offline evaluation and manual spot checks, and archive the baseline metrics. Roll out gradually at 5% → 20% → 50% → 100%, observing one full business cycle at each stage.

    Set explicit thresholds. Stop scaling up if error rate or P95 latency exceeds a defined margin, or if task success rate falls below the baseline by a defined amount. Trigger a rollback if you see data leakage, unauthorized actions caused by prompt injection, or a sustained decline in output quality.

    Full-chain logging and monitoring with alerting must cover quality metrics, latency, and error rates. If you offer generative AI services to the public, also fulfill any applicable regulatory filing and security assessment requirements.

    5. What cloud platforms can take on

    Building LLM infrastructure from scratch involves many pieces, and standard cloud products can handle the standardized parts, shortening time to launch:

    • Object storage for weights and training data, including multiple versions of quantized weights
    • Container platforms with auto-scaling to handle traffic peaks
    • Message queues to decouple data preprocessing from training jobs
    • Logging and monitoring services that provide the data behind the rollout thresholds and rollback decisions in the previous section

    Baidu AI Cloud offers general-purpose tooling for LLM training, inference, and application orchestration.

    6. Risk checklist: private deployment is not automatic compliance

    • Review the commercial-use boundaries of the license clause by clause, especially redistribution and derivative-model terms.
    • Private deployment only solves the data-flow question; data classification and access controls are still required.
    • Obtain weights and dependencies from official sources and verify their hashes to guard against supply-chain poisoning.
    • Protect against prompt injection and unauthorized tool calls at the architecture level.
    • If you provide generative AI services to the public within mainland China, you must fulfill the filing and security assessment requirements.

    7. FAQ

    Q: What should I do if accuracy drops after quantization?
    A: First, use your evaluation to pinpoint which capabilities degraded, such as constraint satisfaction rate, multi-hop QA, or code generation. Then try a higher bit width, finer group size, or mixed precision (keeping sensitive layers at high precision). Finally, compare the results against your preset threshold using the same evaluation set.

    Q: Should I use full fine-tuning or PEFT?
    A: If you only need to adjust output style, format, or a small amount of task capability, choose PEFT. If you need to inject a large amount of new domain knowledge or change the output distribution, choose full fine-tuning. Validate either choice with a small-scale A/B test.

    Q: Does private deployment mean compliance?
    A: No. It only prevents data from being sent to a third-party API. You still need data classification, access control, and log auditing, and public-facing services also require filing and security assessment.

    Q: Is a bigger context window always better?
    A: No need to chase the longest window. A larger window means higher KV cache memory costs, so choose a model based on measured multi-hop QA and mid-document retrieval performance.

    Q: What are the most common mistakes?
    A: Relying on leaderboards instead of your business data, provisioning peak capacity as a steady state, skipping regression validation after quantization, overlooking commercial-use license terms, and running a gradual rollout without rollback thresholds.