LLM Model Selection and Capability Evaluation: A Practical Guide for Four Scenarios
Model selection should start from the task, not the model. This guide presents a three-step approach: filter candidate models with a unified five-dimension scorecard, build scenario-specific test sets with recorded metrics, and use production monitoring data to decide whether to switch models or adjust prompts. It covers model evaluation weights, code generation validation with CI checks, command query selection with executable examples, and RAG component selection for real-time retrieval, including access control and evaluation metrics such as Recall@5 and answer accuracy.
LLM Model Selection and Capability Evaluation: A Practical Guide for Four Scenarios
Model selection should start from the task, then compare models. A model that excels at code generation is not necessarily reliable for real-time retrieval or long-form report generation. The approach described below has three steps: first, filter candidate models with a unified scorecard; second, build a test set for each scenario and record metrics; finally, use production monitoring data to decide whether to switch models or adjust prompts.
1. Filtering Candidate Models with a Five-Dimension Scorecard
During selection, score each candidate model on the following five dimensions, from 1 to 5 points each, then compute a weighted sum. The weights are only a starting point and should be adjusted based on business priorities.
| Dimension | Question to Answer | Example Weight | Low-Score Signal | High-Score Signal |
|---|---|---|---|---|
| Accuracy | What proportion of outputs are correct on your own business test set? | 30% | Requires heavy manual correction | Directly usable or needs only minor edits |
| Context length | Can it hold project interface files or report materials in a single pass? | 20% | Frequent truncation, losing key constraints | Leaves at least 30% headroom for output |
| Timeliness | Can it access the latest news, documentation versions, and real-time data? | 15% | Knowledge stops at the training cutoff | Supports retrieval integration and can label data timestamps |
| Cost | Are token and invocation costs per task under control? | 20% | Per-task cost exceeds the cost of manual work | Per-unit price for high-frequency tasks fits the budget |
| Task complexity match | Does the model’s reasoning ability match the task difficulty? | 15% | Using a flagship model for simple tasks, causing waste | Sufficient reasoning headroom for complex tasks |
Adjust the weights as follows. For high-frequency, low-risk command queries, raise the combined weight of cost and response latency above 35%. For scenarios involving production code, raise the accuracy weight above 40% and set a minimum accuracy threshold — models below the threshold are eliminated outright and do not participate in the weighted scoring.
2. Selecting a Model for Code Generation and Validating Output
The core capabilities for code scenarios are logical reasoning, syntax accuracy, and long-context understanding. Vendors typically do not disclose the proportion of code in their pretraining data, so you should not select a model based on marketing claims like “strong coding ability.” Rely on actual test results.
Build the test set as follows. Extract 50 to 100 real requirements from your project, each accompanied by interface definitions, input/output samples, and at least one set of unit tests. The test set should cover the main languages and frameworks in your project — for example, test Python data processing modules and Go microservice modules separately. Results from one language cannot represent all of them.
Prompts should constrain the output as much as possible to reduce interference from explanatory text. Here is an example template:
You are a senior Python engineer. Output only the function implementation that matches the interface definition below. No explanations.Interface: def parse_order(payload: dict) -> OrderConstraints:1. Raise ValueError when payload is missing order_id2. Convert all amount fields to Decimal with two decimal places3. Do not introduce third-party dependencies beyond those in the test files
Model-generated code must pass automated validation before entering the codebase. Run the following steps in sequence in the CI pipeline:
ruff check src/ tests/mypy src/ --strictpytest -q tests/ --maxfail=3
If static checks or unit tests fail, the code cannot be merged. If the same requirement fails generation twice in a row, execute a fallback: first split the requirement into smaller function-level tasks; if it still fails, switch to the next-highest-scoring candidate model from the test set. Record every failed sample as input for future prompt optimization.
Evaluation metrics include compilation pass rate, unit test pass rate, the number of lines modified by humans, and the number of invocations needed for the first pass. Of these, the number of manually modified lines best reflects the real impact on productivity.
3. Model Selection and Examples for Everyday Command Queries
For everyday Q&A, text polishing, and command queries, the primary metrics are response speed and basic accuracy. These tasks require little reasoning depth, so a smaller, cheaper model is usually sufficient — but you need a test set to confirm its accuracy on command syntax.
Operations engineers often describe query needs in natural language, such as “find requests in Nginx with status code 500 in the past 5 minutes.” Any command the model produces must be validated in a test environment first. The example below assumes the log uses Nginx’s default combined format, with the status code in the 9th field:
export LC_ALL=Cpattern=$(for m in 0 1 2 3 4 5; do date -d "-$m min" '+%d/%b/%Y:%H:%M'; done | paste -sd'|')grep -E "\[($pattern)" /var/log/nginx/access.log | awk '$9 == 500' | tail -n 50
This command covers the current minute plus the previous 5 minutes — 6 minutes in total — so it may return one extra minute of data beyond a strict 5-minute window. LC_ALL=C ensures month abbreviations are in English; otherwise %b may produce non-matching strings under other locales. Before running it, verify the output against a sample log file, and only then run it on production hosts.
This scenario has three evaluation metrics. First, command executability: the proportion of commands that run successfully in a sandbox. Second, result correctness: verified by manually sampling and comparing against the logs. Third, the P95 time-to-first-token latency, used to judge the experience under high concurrency.
If query volume is large, place model calls in stateless function services with concurrency limits and timeouts. On timeout, return a cached result or prompt the user to retry, rather than waiting indefinitely.
4. Component Selection and Evaluation for Real-Time Retrieval
Real-time retrieval uses retrieval-augmented generation (RAG) to work around stale model training data. A typical system includes five stages — document parsing, vector indexing, crawling, reranking, and generation — and each stage requires its own selection decision.
| Component | Options | Selection Criteria | Notes |
|---|---|---|---|
| Vector store | Managed vector service, pgvector, dedicated vector database | For datasets under a million records, start with pgvector to reduce operational overhead | Confirm the index type (e.g., HNSW) and memory footprint |
| Document parsing | General-purpose parsing libraries, layout-aware parsing services | Choose layout-aware parsing when documents contain tables or scanned pages | Preserve page numbers and headings after parsing to enable citations |
| Crawler | Self-built crawler, third-party data APIs | Prefer authorized APIs for public information | Respect robots.txt and site terms of service; set rate limits |
| Reranker | Cross-encoder reranking | Enable when recall results contain significant noise | Adds latency; include it in the cost evaluation |
Index update strategies should differ by data type. News-like data can be incrementally updated every 15 minutes, using content hashes to detect changes and avoid redundant vectorization. API documentation should trigger updates on version releases, with version numbers recorded so answers can cite the documentation version.
Permission isolation must be enforced at the retrieval stage. During retrieval, filter documents against the user’s access control list (ACL) — do not send all results into the prompt and then ask the model to ignore unauthorized content. Models cannot reliably follow instructions like “do not disclose”; permission filtering must be guaranteed by code at the retrieval layer.
Below is pseudocode for the retrieval flow, including fallbacks for empty results and timeouts:
def answer(query, user):intent = classify_intent(query)docs = vector_search(query, acl=user.acl, top_k=20, timeout=2.0)if not docs:return "No relevant materials were found. Please rephrase or specify a source."docs = rerank(query, docs)[:5]context = format_with_sources(docs)return llm_generate(prompt=build_prompt(intent, context, query))
Retrieval quality is evaluated with three metrics. Recall@5 measures the proportion of cases where the correct document appears in the top 5 results. Answer accuracy is judged by humans against the source text. Citation hit rate measures whether the citation IDs given by the model are correct.
