How to Evaluate LLM Writing Ability and Choose the Right Model: A Practical Guide
This guide breaks LLM writing ability into measurable metrics, explains how to match models to specific writing scenarios, and provides reference Python code for calling a writing API and running evaluations. The thresholds it suggests are starting points that should be adjusted to your business risk.
Introduction: Why Writing Quality Needs Measurable Criteria
When choosing a model for writing, teams often rely on public leaderboards or a few sample texts. These methods do not answer the question that matters most to a team: can a model consistently meet the standard for its own genre, language, and length? This article breaks writing ability into measurable metrics, explains how to match models to scenarios, and provides reference code for calling and evaluating a model. The thresholds in this article are starting points. Adjust them based on your business risk.
1. How to Define and Measure Writing Ability
Descriptions such as “inner autonomy” are hard to verify. This article uses the following actionable metrics instead.
| Metric | Definition | Measurement method | Example threshold |
|---|---|---|---|
| Sentiment label consistency | Share of outputs whose sentiment matches the prompt’s requirement | 100 samples. Two annotators label each sample independently, and only consistent labels are kept. | ≥85% |
| Constraint satisfaction rate | Share of outputs that meet all constraints in the prompt, including word count, grammatical person, point of view, and banned words | At least 50 prompts with multiple constraints, checked against each rule | ≥80% |
| Adversarial prompt pass rate | Share of outputs that handle contradictory or vague requirements reasonably and satisfy the parts that can be satisfied | 30 adversarial prompts, judged manually | ≥75% |
| Multilingual coverage rate | Pass rate for each target language and each genre | A matrix of languages by genres, with at least 30 samples per cell | ≥75% per cell |
| Long-context consistency | Share of cases where names, timelines, and settings remain correct after a multi-turn conversation | Check against a settings sheet at turns 5, 10, and 20 | ≥90% at turn 20 |
1.1 Human Scoring Rubric
Score each text on four dimensions, from 1 to 5 for each.
- Sentiment accuracy: The emotional progression matches the prompt and does not drift noticeably.
- Plot coherence: Cause and effect hold across the text, and character motivations do not shift abruptly.
- Language quality: Sentences read naturally, without repeated stock phrases.
- Style fit: The text matches the specified form and the target readers.
Two reviewers score each text independently. Calculate Cohen’s kappa. If it is below 0.6, revise the scoring guidelines before continuing the evaluation.
1.2 Measurement Notes
- When comparing models, keep temperature, top_p, and the prompt version fixed. Otherwise, you are comparing parameters, not models.
- Use the same prompt set for all candidate models, and record each model’s name and version.
- Small sample sizes can produce differences caused by random variation. If two models differ by only a few percentage points, increase the sample size before drawing conclusions.
- Do not use the same model for generation and scoring.
2. How to Choose a Model for Each Scenario
Model rankings change with each version, so this article does not rank specific models. Base your selection on the metrics in Section 1.
| Scenario | Key capability | Metrics to check first | Selection notes |
|---|---|---|---|
| Content marketing and social media copy | Varied styles, short length, fast responses | Sentiment label consistency, style fit | Latency and unit cost matter most. Start with a general model plus style examples. Consider fine-tuning only if results fall short. |
| Long-form worldbuilding (science fiction, fantasy) | Long-context memory, no drift in settings | Long-context consistency, plot coherence | Test with the context length you can actually use, not the advertised window. |
| Multilingual expansion | Stable quality across languages | Multilingual coverage rate | Evaluate each language separately. Do not use English results to represent other languages. |
| Official documents, manuals, and other strict texts | Controlled output boundaries | Constraint satisfaction rate | Add rule-based checks and manual review. |
2.1 Selection Decision Order
- Is a compliance requirement mandatory? If yes, first filter for candidates that meet the constraint satisfaction rate target.
- Does the project target more than one language? If yes, set multilingual coverage as a hard requirement.
- Is there a need for serialized long-form content? If yes, test long-context consistency.
- Among the candidates that pass, compare cost, p95 latency, and cost per output.
2.2 Common Mistakes
- Drawing conclusions from one or two samples. Samples can happen to match or miss expectations by chance.
- Inferring ability from nominal specifications. Parameter count and context window size do not directly indicate writing quality.
- Generalizing results from one language to all languages.
3. How to Call a Writing API Safely
The code below is a reference implementation. Endpoint paths and field names should follow the official documentation of the provider you choose. The code assumes the API uses the common chat/completions format. If a provider uses different fields, change only the payload and the response parsing. The code runs on Python 3.9 or later with requests 2.31 or later.
import osimport timeimport requestsAPI_BASE = os.environ["LLM_API_BASE"] # e.g. https://provider.example.com/v1API_KEY = os.environ["LLM_API_KEY"] # Read only from environment variablesMODEL = os.environ.get("LLM_MODEL", "your-model-name")HEADERS = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}TIMEOUT_SECONDS = 30MAX_RETRIES = 3RETRYABLE_STATUS = {429, 500, 502, 503, 504}def generate_text(prompt, temperature=0.8, max_tokens=1024):"""Call the chat completions endpoint. Timeouts, connection errors, rate limits, and server errors are retried with exponential backoff."""url = f"{API_BASE}/chat/completions"payload = {"model": MODEL,"messages": [{"role": "user", "content": prompt}],"temperature": temperature,"top_p": 0.9,"max_tokens": max_tokens,}last_error = Nonefor attempt in range(1, MAX_RETRIES + 1):try:resp = requests.post(url, headers=HEADERS, json=payload, timeout=TIMEOUT_SECONDS)if resp.status_code in RETRYABLE_STATUS:last_error = f"HTTP {resp.status_code}"else:resp.raise_for_status() # Other 4xx errors are raised immediately without retryreturn resp.json()["choices"][0]["message"]["content"]except (requests.exceptions.Timeout, requests.exceptions.ConnectionError) as e:last_error = str(e)if attempt < MAX_RETRIES:time.sleep(2 ** attempt)raise RuntimeError(f"Still failed after {MAX_RETRIES} retries: {last_error}")def generate_long_text(chapter_goals):"""Generate text chapter by chapter. After each chapter, compress its key points and pass them to the next chapter as context. This reduces the risk of the model forgetting settings in long text."""chapters, memory = [], "(none)"for idx, goal in enumerate(chapter_goals, 1):prompt = f"Summary of previous chapters and settings: {memory}\nPlease write chapter {idx}. Requirements: {goal}"text = generate_text(prompt, temperature=0.8, max_tokens=1500)chapters.append(text)memory = generate_text(f"Summarize the character states and key plot points in the following chapter in no more than 200 words, for use in later chapters:\n{text}",temperature=0.2,max_tokens=300,)return chaptersif __name__ == "__main__":demo = "Write an opening of about 200 words for a science fiction story. The protagonist feels both envy and deep affection for their partner. Keep the tone restrained."print(generate_text(demo, temperature=0.9))
3.1 Temperature Guidelines
In the code, top_p is fixed at 0.9. When tuning, change only temperature. Adjusting both sampling parameters at once makes results harder to predict.
| Task | Temperature | Notes |
|---|---|---|
| Official documents and manuals | 0.1 to 0.3 | Lower randomness and prioritize constraint compliance |
| Marketing copy | 0.6 to 0.8 | Balance variety and control |
| Creative writing | 0.8 to 1.0 | High randomness, requires manual review |
3.2 Key and Data Security
- Read API keys only from environment variables or a secrets management service. Never store them in code or configuration files, or commit them to version control.
- Rotate keys regularly. Revoke a key immediately if it may have leaked.
- Mask the Authorization header in logs. Redact personal identifiers in user input, such as phone numbers and national ID numbers, before writing to logs.
- Escape model output before rendering it on the front end to prevent script injection.
- Do not include real customer data in prompts unless compliance approval has been obtained.
- Generation requests have no side effects, but retries add cost and latency. Always set a maximum number of retries.
4. How to Build a Continuous Evaluation Loop
4.1 Automated Evaluation Checklist
| Item | Requirement |
|---|---|
| Sample size | At least 200 samples per scenario, stratified by genre and language |
| Scoring dimensions | Sentiment accuracy, constraint satisfaction, plot coherence, and language quality, each scored from 1 to 5 |
| Judge model | Use a model from a different vendor or a different version than the model under test, to avoid self-evaluation bias |
| Consistency check | Have humans re-score a 10% sample and calculate agreement. If agreement falls below the threshold, revise the scoring prompt. |
| Log fields | Request ID, model name and version, temperature, top_p, prompt version, redacted output, scores for each dimension, latency, token count, and timestamp |
| Regression cycle | Run a full regression whenever the model version or prompt changes |
4.2 Evaluation Loop
- Each time a prompt or model version changes, run the full regression set.
- After automatic scoring, send samples that fall below the threshold to a manual review queue.
- Feed review results back to improve prompts or build fine-tuning data.
- Review metric trends weekly. If a key metric declines for two consecutive cycles, roll back the prompt or model version.
4.3 Scope and Risks
- Evaluation results apply only to the languages, genres, and lengths that were tested. Do not generalize them to other scenarios.
- Results may change after a provider updates a model version. Re-evaluate after each update.
- Judge models have their own biases. Spot-check key conclusions manually.
- Generated text may resemble training data. Run originality checks before publication.
- Generated content may contain factual errors or inappropriate statements. Review it before publishing.
- The example thresholds in this article do not come from an industry standard. Set your own thresholds based on business risk.
