constraint-specification

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Constraint Specification

约束条件规范

Constraints are the rules that shape AI output — what format to use, how long to be, what to include, what to exclude. Well-specified constraints produce predictable, useful outputs. Vague constraints produce inconsistent results.
约束条件是塑造AI输出的规则——包括使用何种格式、篇幅长短、应包含和排除的内容。明确的约束条件能产生可预测、有用的输出,模糊的约束条件则会导致结果不一致。

Types of Constraints

约束条件类型

Format constraints:
  • Output structure (JSON, markdown, plain text, bullet points, prose)
  • Section headings and organisation
  • Required fields and optional fields
  • Data types and schemas Length constraints:
  • Word count ranges (not exact numbers — models are bad at counting)
  • Section length proportions ("spend 60% on analysis, 40% on recommendations")
  • Minimum and maximum bounds
  • Conciseness directives ("be brief" vs. "be thorough") Content constraints:
  • Topics to include and exclude
  • Required information elements
  • Prohibited content
  • Source restrictions (only use provided context, don't use external knowledge) Tone constraints:
  • Formality level
  • Emotional register
  • Audience-appropriate language
  • Voice and style guidelines Quality constraints:
  • Accuracy requirements ("cite sources", "flag uncertainty")
  • Completeness requirements ("address all aspects of the question")
  • Originality requirements ("don't repeat the question back")
  • Actionability requirements ("every recommendation must be implementable")
格式约束:
  • 输出结构(JSON、markdown、纯文本、项目符号段落、散文体)
  • 章节标题与组织结构
  • 必填字段与可选字段
  • 数据类型与模式 长度约束:
  • 字数范围(不要用精确数字——模型不擅长计数)
  • 章节长度比例("60%篇幅用于分析,40%用于建议")
  • 最小与最大篇幅限制
  • 简洁性指令("简洁表述" vs "详尽阐述") 内容约束:
  • 需包含与排除的主题
  • 必填信息要素
  • 禁止内容
  • 来源限制(仅使用提供的上下文,不得使用外部知识) 语气约束:
  • 正式程度
  • 情感基调
  • 符合受众的语言风格
  • 语气与风格指南 质量约束:
  • 准确性要求("引用来源"、"标注不确定性")
  • 完整性要求("覆盖问题的所有方面")
  • 原创性要求("不要重复问题内容")
  • 可操作性要求("每条建议必须可落地执行")

Writing Effective Constraints

编写有效的约束条件

  • Be specific: "Keep responses under 200 words" beats "be concise"
  • Prioritise: When constraints conflict, state which wins. "Accuracy over brevity."
  • Provide examples: Show what a constrained output looks like
  • Test boundaries: What happens at the edge of each constraint?
  • Separate hard and soft constraints: Hard constraints must always be met. Soft constraints are preferences.
  • 具体明确:"回复控制在200字以内"比"简洁表述"效果更好
  • 设定优先级:当约束条件冲突时,明确说明优先级。例如"准确性优先于简洁性"。
  • 提供示例:展示符合约束条件的输出样例
  • 测试边界:测试每个约束条件的极限情况会产生什么结果?
  • 区分硬性与软性约束:硬性约束必须始终满足,软性约束是偏好性要求。

Constraint Interactions

约束条件的相互作用

Constraints interact and can conflict:
  • "Be thorough" vs. "Keep it under 100 words"
  • "Be creative" vs. "Follow this exact format"
  • "Be helpful" vs. "Don't give medical advice" Resolve conflicts explicitly in the prompt. Don't make the model guess which constraint takes priority.
约束条件之间会相互作用甚至冲突:
  • "详尽阐述" vs "控制在100字以内"
  • "富有创意" vs "严格遵循此格式"
  • "提供帮助" vs "不得提供医疗建议" 在提示词中明确解决冲突,不要让模型自行猜测哪个约束条件优先级更高。

Design Artefacts

设计产物

  • Constraint specification documents per output type
  • Constraint priority hierarchies
  • Constraint test cases (inputs designed to stress each constraint)
  • Constraint violation examples (what bad looks like)
  • Constraint evolution logs (how constraints changed and why)
  • 针对每种输出类型的约束条件规范文档
  • 约束条件优先级层级
  • 约束条件测试用例(用于测试各约束条件极限情况的输入)
  • 约束条件违规示例(展示不符合要求的输出样例)
  • 约束条件演变日志(记录约束条件的变更及原因)