Evaluating LLM Writing and Coding Capabilities: A Practical Engineering Guide
This article turns the subjective "which model is better" debate into a repeatable engineering process. It breaks writing quality into four measurable dimensions (instruction following, style consistency, factuality, naturalness), shows how negative constraint lists suppress machine-like phrasing, and explains how to build a fixed, versioned evaluation set with a weighted rubric. On the coding side, it goes beyond pass rate to cover interaction quality, long-horizon consistency, and run-to-run variance. Finally, it describes how to run the whole evaluation as an automated pipeline with regression on every model or prompt change.
1. Why “Model of the Year” Rankings Need to Be Engineered
Personal, experience-based model rankings have one inherent flaw: they are not reproducible. The same model performs very differently across prompts, context lengths, and sampling parameters, and a single impressive generation may just be sampling luck. Turning “it feels better” into a decision-ready conclusion requires three things: explicit evaluation dimensions, a fixed evaluation sample set, and a repeatable scoring process.
Below, the two highest-frequency scenarios — writing and coding — are broken down into measurable metrics, along with methods for putting them into practice.
2. Four Measurable Dimensions of Writing Quality
2.1 Instruction Following: Constraint Satisfaction Rate
Treat every hard requirement in the prompt as an assertion, then measure the proportion of assertions violated by the output. Constraints that can be checked automatically include length ranges, banned words, paragraph count, required entities, and output format (for example, the output must be valid JSON).
def constraint_pass(text: str, spec: dict) -> dict:checks = {"length": spec["min_len"] <= len(text) <= spec["max_len"],"no_banned": not any(w in text for w in spec["banned"]),"paragraphs": text.count("\n\n") + 1 == spec["paragraphs"],"json_valid": is_valid_json(text) if spec.get("json") else True,}return {"score": sum(checks.values()) / len(checks), "detail": checks}
2.2 Style Transfer: Style Consistency
Prepare several reference texts in the target style and extract quantifiable style features: average sentence length, punctuation density, ratio of formal to colloquial vocabulary, and variance in paragraph length. Then compare the feature distance between the generated text and the reference corpus. The smaller the distance, the more successful the style transfer. This is far more stable than judging whether something “reads like it.”
2.3 World Knowledge and Factuality: Hallucination Rate
Sample and verify the checkable claims in the generated text, then measure the proportion that no authoritative source supports. In engineering practice, a more reliable approach is not post-hoc verification but upfront constraint: require the model to provide traceable evidence for factual statements, or introduce retrieval augmentation into the pipeline so external material is injected as context.
2.4 Text Naturalness: Boilerplate Density
Count the frequency of high-frequency filler expressions (“in today’s era,” “in summary,” “it is worth noting”) and summary-style subheadings. The lower the density, the closer the text is to human writing.
3. Suppressing “Machine Flavor” with a Negative Constraint List
Negative constraints (a banned-phrase list) are the lowest-cost, fastest-acting measure, but the count must be controlled and conflicts must be checked.
[Writing Constraints]1. Do not use the "not X, but Y" construction that negates first and pivots after.2. Do not use em dashes or long strings of parenthetical insertions.3. Do not output bulleted structures or subheadings; the whole text is continuous prose.4. Do not use summary boilerplate.5. If constraints conflict, satisfy 1 and 2 first; the rest may be relaxed.
Three practical points: once constraints exceed about five, they begin to inhibit one another and make expression stiff; every constraint must be writable as an assertion so it can be validated automatically; before shipping, run an A/B comparison with and without constraints on the same sample batch to confirm the metrics improve, not just the style.
4. Evaluation Set and Scoring Rubric
The evaluation set does not need to be large. Thirty to fifty samples covering typical tasks are enough to support relative comparison; what matters is that the set stays fixed and is version-controlled.
{"task_id": "write_017","input": "Write a 200-word summary for an internal technical weekly report","spec": {"min_len": 180, "max_len": 240, "banned": ["empower", "close the loop"], "paragraphs": 1},"rubric": [{"dim": "instruction", "weight": 0.4},{"dim": "style", "weight": 0.2},{"dim": "factuality", "weight": 0.25},{"dim": "naturalness", "weight": 0.15}]}
Automatic metrics handle the computable parts; human blind review handles aesthetics and readability. During blind review, hide model identifiers, randomize order, and average the scores of three or more reviewers while discarding outlier ratings.
5. Coding Evaluation: Pass Rate Is Not Enough
5.1 Frontend and Interaction Quality
Functional correctness is only the baseline. What really separates models is visual consistency, adherence to spacing and grid conventions, completeness of state feedback, and accessibility (semantic tags, contrast, keyboard reachability). All of these can be turned into a checklist and verified item by item.
5.2 Long-Horizon Tasks and Logical Consistency
The core risk in long-horizon tasks is context drift: interface contracts defined early are forgotten later. The engineering countermeasure is to split the task into small steps with acceptance conditions and backfill structured state at every step.
state = {"contracts": {...}, "done": [], "open_questions": []}for step in plan:patch = agent.apply(step, context=state)if run_tests(patch) and review(patch, state["contracts"]):state["done"].append(step.id)else:state["open_questions"].append(step.id)
5.3 Regression and Maintainability
Run the same task five times and measure the variance of the pass rate. A model with high variance does not belong in an automated pipeline, even if its mean is higher.
6. Turning Evaluation into a Pipeline
Evaluation should run automatically like unit tests: samples and rubrics are stored in object storage and versioned, tasks are distributed through a message queue, execution environments run on a container platform, and metrics are written to a logging service where monitoring and alerting track drift. On Baidu AI Cloud, these capabilities all map to general-purpose cloud product categories and can be composed directly following existing engineering conventions, with no custom work required.
The pipeline should output at least four trend metrics: constraint satisfaction rate, style feature distance, hallucination rate, and pass rate variance. Any change to the model or the prompt triggers a full regression, avoiding the “fix one scenario, break three others” problem.
7. Conclusion
Model selection should not rely on a single impressive experience. Break writing into four computable dimensions — instruction following, style transfer, factuality, and naturalness — and break coding into functional correctness, interaction aesthetics, long-horizon consistency, and run variance. Then use a fixed evaluation set and an automated pipeline for continuous regression, and subjective impressions become auditable engineering conclusions. The method itself is independent of any specific model, and the faster models iterate, the more valuable it becomes.
