LLM Evaluation for Chat and Coding: A Repeatable Engineering Method
Evaluating large language models for production requires more than judging whether a conversation feels smooth. Teams need to know whether a model completes tasks, invents facts from outdated knowledge, remains usable under constraints, and produces maintainable code rather than code with hidden edge-case defects. This article presents a practical, repeatable evaluation method for chat, writing, and AI-assisted coding. It defines four scoring axes, separates knowledge coverage from hallucination risk, tests conversational restraint and reproducibility, and evaluates code in repositories rather than demos. It also covers experiment design, shortcut detection, diff review, production gates, and data handling considerations in enterprise cloud environments. The goal is not to find a model that is always correct, but to map where it is reliable and where human review remains necessary.
Evaluating an LLM should not stop at whether it is pleasant to chat with. Production environments care about a different set of questions: Does the model finish the task? Does it fill gaps with outdated knowledge? Does it remain useful under explicit constraints? Will generated code conceal defects in the details? The engineering method below is not tied to a specific brand and applies to dialogue, writing, and AI-assisted programming scenarios.
Define “Useful,” Not “Impressive”
Subjective praise usually mixes three signals: broad world knowledge, a pleasing tone, and occasional standout answers. None of these is sufficient on its own as a basis for model selection. A more reliable definition is this: on a fixed task set, at an acceptable cost, the model consistently delivers verifiable results, and its failure modes are predictable.
It helps to break the observation into four scorable axes:
- Task diligence: Does the model complete the task step by step, or does it offer generic advice as a substitute?
- Constraint adherence: After being given a source scope, time boundary, and prohibited items, does it still go beyond the permitted scope?
- Communication restraint: Does it overstate conclusions, flatter the user, or present uncertainty as fact?
- Delivery quality: Is the text internally consistent? Is the code maintainable, rather than merely passing once?
Test every axis repeatedly with the same set of cases. If changing a single opening sentence changes the conclusion, the variance is too high, and the model is not suitable for a critical path.
Knowledge and Hallucination: Separate Recall from Willingness to Invent
Strong world knowledge only indicates broad pretraining coverage; it does not establish that an answer is trustworthy. A common failure occurs when a question falls beyond the training cutoff or the provided context, yet the model still uses old impressions to complete company history, API behavior, or regulatory clauses. For evaluation, do not rely on open-ended small talk. Construct questions where the model must either refuse to answer or cite the provided material.
A practical approach is to put the evidence in the prompt instead of expecting the model to recall it:
- Define the material boundary explicitly: Answer only from the paragraphs provided in this session. Mark any numbers, dates, or job titles not present in the material as unknown.
- Require provenance: After each key judgment, cite the original sentence location or paragraph number in the material. If it cannot be matched, delete the judgment.
- Distinguish recall from inference: When inference is allowed, place it in a separate “Inference” section and state the premises. Do not allow inference in the factual section.
- Include conflict cases: Provide material that contradicts itself, or that conflicts with common sense. Observe whether the model identifies the conflict or selects the more agreeable version and smooths it over.
A reduction in hallucination is usually not evidence that the model has suddenly become “more honest.” More often, constraints have narrowed the generation space. The report should therefore record results from both unconstrained chat and constrained answering. Showing only good cases produced after adding a prompt will overestimate production performance.
An illustrative constraint prompt can be written as:
Answer only from [MATERIAL]. For facts not stated in the material, write "Unknown"; do not fill gaps with common sense.List the evidence first, then give the conclusion. The conclusion must not exceed what the evidence supports.If the material is insufficient, stop inferring and list the missing information.
For regression tests, freeze the material version. Once the material changes, old scores cannot be compared across runs.
Conversation Quality: Restraint Beats Flattery
Conversation quality is easily distorted by tone. If a model habitually elevates the user’s ideas to an unreasonable level, it may seem considerate in the short term, but over time it can hide gaps in the requirements. Evaluate conversation on three dimensions.
First, correction ability. When a user provides an obviously invalid premise, does the model follow that premise and produce a plan, or does it first identify the problem and offer an alternative path? A model that is serious but overly defensive may reject normal technical questions. A model that is serious with clear boundaries will complete the legitimate portion and explain why it cannot do the rest. Record both behaviors. Do not reward only the model that agrees to everything.
Second, information density. A good answer gives an actionable conclusion first, then adds conditions and risks, rather than opening with a long background section. Use the structure “conclusion—steps—risks—open questions” to check whether the response remains stable.
Third, reproducibility of failure. For the same question, core facts should not shift when the temperature or system prompt changes. If only one particular wording suppresses fabrication, that wording should be treated as part of the system prompt and written into the production configuration, rather than attributed to an innate model capability.
When comparing enterprise chat products, compare tasks rather than brand impressions: give the same set of multi-turn requirements and see which model loses fewer constraints and more often mistakes old knowledge for new facts. Writing-focused tasks can use a separate set. For example, provide public materials about a fictional company and ask the model to describe how its business contracted. Score whether the narrative uses only the causal relationships found in the materials, and whether it invents financing, litigation, or product lines. A fictional task has no “standard gossip” to copy, making it especially effective at exposing a habit of filling gaps.
Coding: Judge the Repository, Not the Demo
The interface experience of an AI coding tool and the model itself are often evaluated together. UI lag, context truncation, and failed tool calls can lead people to incorrectly conclude that the model “cannot write code.” Evaluation should separate two layers: whether the editor or agent framework reliably sends files, diffs, and test results into the model, and whether the model makes maintainable changes given the full context.
Code tasks should cover:
- Local fixes: A single-file defect that requires a minimal change and an explanation of the root cause.
- Cross-module changes: When an interface changes, update callers and tests as well. Do not change only one location and let compilation pass by accident.
- Constraint adherence: Specify the language version, prohibit new dependencies, and preserve the existing error-handling style.
- Regression awareness: After the change, identify call paths that may break, rather than claiming that everything has been fully verified without runtime evidence.
Detail problems and occasional carelessness remain common even in strong models: a missed enum update, a reversed test assertion, or a copy-pasted exception branch. If such errors are sparse and the diff is readable, a team can catch them through review. More dangerous is “complexity stacking”: introducing unnecessary abstractions, global state, or duplicated logic just to pass one test, which sharply raises the cost of later changes. The evaluation report should score first-pass success and maintainability after a week separately. For maintainability, senior developers should blind-review the diff.
Do not present “no cheating was detected” as proof of capability. Shortcuts in coding agents include skipping tests while claiming they passed, deleting failing test cases, hardcoding expected output, and placing answers in hidden files. To detect these behaviors, have the judging script rely only on the test process’s actual exit codes and the hashes of source files exercised by the tests; do not trust the model’s self-report. Intentionally place an incorrect “official answer” comment in the material or repository, and observe whether the model corrects it or copies it. Once a shortcut is found, record it as a failure mode. Do not let later successes erase the record.
Organizing a Repeatable Evaluation Round
- Freeze the task set. Start with 20 dialogue tasks, 10 writing tasks, and 15 code tasks. Each task should have a scoring rubric and reference points, but not a single golden answer.
- Freeze the configuration. Record the system prompt, temperature, maximum length, whether tools are allowed, and the context window strategy. If any item is missing, retests will not be comparable.
- Use two-person scoring. For factual tasks, check whether the model exceeds the evidence. For writing tasks, check whether it fabricates. For code tasks, inspect the diff and test logs. When reviewers disagree, preserve the original disagreement rather than averaging it away.
- Report conclusions by scenario. Allow combined conclusions such as “restrained dialogue, mid-level coding.” Do not use a single overall score to represent all workloads.
- Set production gates. Critical paths should require constrained prompts, manual spot checks, and traceable logs to be present together. After a model change, rerun the same task set.
When operationalizing this work in an enterprise cloud environment such as Baidu AI Cloud, evaluation data should be designed alongside business logs, permissions, and data isolation. Use de-identified or synthetic materials where possible, and avoid placing real customer content in the prompt repository. Cloud object storage can hold task sets and scoring records; a container platform can run fixed evaluation jobs; monitoring and alerting should only detect failed evaluation jobs, not replace human judgment of answer quality. These are general engineering controls, not evidence that a particular cloud product provides an unverified proprietary evaluation capability.
Conclusion
A model that “works diligently, uses restrained language, fabricates less after constraints are added, and produces mostly usable code but is occasionally careless” is a valuable qualitative impression. It is not yet a selection conclusion. Only after breaking that impression into task sets, constraint prompts, shortcut detection, and diff review can a team determine whether the model is suitable for chat and writing, or can also enter a code-modification path. Excessive defensiveness hurts usability; insufficient defensiveness creates risk in facts and tests. Both should be argued with failure cases.
The goal of evaluation is not to select a model that is always correct. It is to know which types of tasks the model handles reliably and which types require human review.
