Open-Source LLM Selection: Practices for Long Context, Chinese, and Coding Agent Scenarios

    With the recent surge in open-source large language models (LLMs), selecting the right model for specific business scenarios has become critical. This article explores a systematic approach to LLM evaluation across three core dimensions: Chinese context capabilities, million-token long context, and coding agent intelligence. It also provides guidance on building custom evaluation sets, estimating deployment costs, and implementing models effectively to avoid unstable performance and budget overruns.

    1. Background: Open-Source Models Enter a Phase of Direct Comparison

    Recently, multiple open-source weight LLMs have been released within a close timeframe, allowing developers to compare different models using unified standards. For teams, the question has shifted from “Are there usable open-source models?” to “Which model best fits my business scenario?”

    The cost of a wrong selection is significant. Mismatched model capabilities can lead to unstable performance, inference costs exceeding budgets, and potential compliance risks from licensing terms. Therefore, selection requires a systematic evaluation across three dimensions—Chinese capabilities, long context, and coding agents—combined with deployment conditions.

    2. Three Core Evaluation Dimensions

    2.1 Chinese Context Capability

    Chinese capability cannot be judged solely by general benchmark scores. Chinese word segmentation boundaries are ambiguous, idioms and colloquialisms are prevalent, and domains like government and law are dense with terminology. It is recommended to test the following tasks:

    • Chinese factual QA: Test knowledge coverage, such as local culture or industry standard clauses.
    • Chinese long text rewriting: Test semantic preservation and style control.
    • Bilingual mixed text and terminology handling: Test how technical documents handle the translation and preservation of proper nouns.
    • Colloquial expression comprehension: Test stability in customer service and social media scenarios.

    Chinese evaluation should prioritize real business corpora. Public datasets may already be included in model training data, leading to artificially high scores.

    2.2 Million-Token Long Context Capability

    As the context window expands, models can ingest entire technical manuals, large code repositories, or months of conversation logs at once. However, window size and effective utilization are two different things. Common issues include:

    1. Mid-context information loss: Accuracy drops significantly when key information is located in the middle of the context.
    2. Attention dilution: With more irrelevant content, the model is more likely to cite incorrect passages.
    3. Increased Time To First Token (TTFT): Longer inputs mean longer wait times before the model starts outputting.

    Resource costs must also be estimated in advance. Taking the KV cache as an example, its VRAM usage can be calculated using the following formula:

    KV Cache Size = 2 × Number of Layers × Number of KV Heads × Dimension per Head × Sequence Length × Bytes per Element

    Assuming a model has 32 layers, 8 KV heads, a dimension per head of 128, uses FP16 storage (2 bytes per element), and a sequence length of 1 million tokens, the KV cache alone requires approximately 131 GB (decimal), not including model weights. Long context capability must be evaluated alongside hardware budgets.

    2.3 Coding Agent Capability

    Coding agents refer to models that not only generate code but also plan multi-step tasks, call tools, read error messages, and self-correct. Evaluation should focus on the complete closed loop rather than just single-generation results:

    • Requirement decomposition: Can it transform vague requirements into executable steps?
    • Tool calling: Do function parameters conform to the specified format, and can it correctly retry upon failure?
    • Code fixing: Given a failed test case, can it locate the root cause and complete the fix?
    • Boundary control: When facing insufficient permissions or missing information, can it stop and ask instead of fabricating results?

    3. Building a Custom Evaluation Set

    General benchmarks only provide a reference. Teams should build 50 to 200 business evaluation cases covering high-frequency and high-risk scenarios, with fixed scoring criteria. Below is an example of a general evaluation framework:

    1. from dataclasses import dataclass
    2. @dataclass
    3. class EvalCase:
    4. prompt: str
    5. expected_keywords: list[str]
    6. category: str # e.g., "chinese_qa", "long_context", "agent"
    7. def score_response(response: str, case: EvalCase) -> float:
    8. hits = sum(1 for kw in case.expected_keywords if kw in response)
    9. return hits / max(len(case.expected_keywords), 1)
    10. def run_eval(model_fn, cases: list[EvalCase]) -> dict:
    11. report = {}
    12. for case in cases:
    13. response = model_fn(case.prompt)
    14. score = score_response(response, case)
    15. report.setdefault(case.category, []).append(score)
    16. return {k: sum(v) / len(v) for k, v in report.items()}

    Keyword matching is only the simplest approach. In formal evaluations, it is recommended to add manual spot checks, inter-rater reliability checks among multiple scorers, and unit test pass rates for coding tasks. model_fn can be replaced with the calling function of any model, ensuring all models use the same set of cases and the same scoring logic for comparable results.

    4. Deployment and Cost

    The selection conclusion must ultimately be grounded in a deployment plan. Key considerations include:

    • Quantization strategy: Low-bit quantization reduces VRAM usage but must be re-validated for accuracy on target tasks.
    • Concurrency and batching: Offline tasks are suitable for large batch processing, while online interactions require a focus on Time To First Token (TTFT).
    • Resource isolation: Long context requests consume significant resources; it is recommended to schedule them in a separate queue from short requests.
    • License terms: Commercial scope, attribution requirements, and derivative model restrictions require legal confirmation.

    5. Implementation Recommendations

    First, clarify the task type. If the task is finding answers from a fixed knowledge base, a Retrieval-Augmented Generation (RAG) solution is usually more cost-effective and easier to control than putting all materials into a long context. The advantages of long context only become obvious when the task requires reading through the entire material and performing overall summarization.

    Second, launch in phases. Start with a small traffic grayscale run, record error types and manual correction costs, and then decide whether to expand the scope.

    Third, establish continuous evaluation. Model version updates, prompt modifications, or data distribution shifts can alter results. Evaluation should be integrated into the daily workflow.

    6. Conclusion

    The comparison of open-source LLMs should return to the business problems themselves. Chinese quality, the effectiveness of long context, the closed-loop capability of coding agents, and deployment costs jointly determine the selection conclusion. Making judgments based on a unified evaluation set and a reproducible workflow is more reliable than relying on a single benchmark or release announcement.