Chapter 77

Fast Mode in Practice: 2.5x Speed, 6x Price and Scenario Judgment for Opus 4.6 High-Speed Inference

Chapter 77: Creative Writing and Content Generation: Style Control, Diversity, and Brand Consistency

77.1 The Engineering Challenges of Creative Writing

Creative writing is one of the hardest AI application tasks to systematize. Unlike structured data extraction or classification, the "correct answer" for creative writing is inherently fuzzy, subjective, and dependent on audience, purpose, and brand context.

Engineers face four core challenges:

  1. Style controllability — How do you make Claude consistently adopt a specific style (brand voice, a particular author's style)?
  2. Content diversity — How do you prevent mass-generated content from feeling homogeneous and repetitive?
  3. Brand consistency — When content needs to be published across multiple platforms and time periods, how do you maintain a unified brand voice?
  4. Quality evaluation — How do you measure whether creative content is "good"?

This chapter systematically addresses these challenges with implementable engineering solutions.

77.2 Style Control

77.2.1 The Components of Style

Style is not a single dimension but a combination of multiple intertwined ones:

STYLE_DIMENSIONS = {
    "tone": {
        "options": ["formal", "casual", "playful", "authoritative", "empathetic", "humorous"],
        "description": "Overall emotional register"
    },
    "voice": {
        "options": ["first_person", "second_person", "third_person", "collective_we"],
        "description": "Narrative perspective and person"
    },
    "sentence_structure": {
        "options": ["short_punchy", "long_flowing", "varied", "parallel"],
        "description": "Sentence preference"
    },
    "vocabulary_level": {
        "options": ["simple", "intermediate", "advanced", "technical", "colloquial"],
        "description": "Vocabulary complexity"
    },
    "rhetoric": {
        "options": ["factual", "storytelling", "persuasive", "descriptive", "instructional"],
        "description": "Rhetorical strategy"
    }
}

77.2.2 Style Exemplars

The most effective style control method is providing concrete examples rather than abstract descriptions. "Write like this" is far more effective than "write in a lively and engaging way":

def build_style_prompt(
    task: str,
    style_exemplars: list,
    anti_examples: list = None,
    style_description: str = ""
) -> str:
    """
    style_exemplars: list of example texts in the target style (3-5 is optimal)
    anti_examples: examples of what NOT to do (optional but powerful)
    """
    exemplar_section = "\n\n".join([
        f"Example {i+1}:\n{example}"
        for i, example in enumerate(style_exemplars)
    ])
    
    anti_example_section = ""
    if anti_examples:
        anti_example_section = "\n\nNote: The following are examples of what to AVOID:\n" + \
            "\n\n".join([f"Anti-example {i+1}:\n{example}" for i, example in enumerate(anti_examples)])
    
    desc_section = f"\n\nStyle notes: {style_description}" if style_description else ""
    
    return f"""Complete the writing task using the style demonstrated in the examples below.

Target style examples:
{exemplar_section}
{anti_example_section}
{desc_section}

Analyze the examples above, extract their core stylistic traits (sentence structure, tone, vocabulary choice, rhythm), then complete the task in that same style:

{task}"""

77.2.3 Brand Voice Modeling

Brand voice is a brand's accumulated, distinctive communication style. For enterprise applications with high content volume, brand voice must be systematically encoded into prompts:

class BrandVoiceProfile:
    
    def __init__(self, brand_name: str):
        self.brand_name = brand_name
        self.profile = {}
    
    def to_system_prompt(self) -> str:
        voice_attrs = self.profile.get("voice_attributes", {})
        dos = self.profile.get("dos", [])
        donts = self.profile.get("donts", [])
        keywords = self.profile.get("brand_keywords", [])
        signature_phrases = self.profile.get("signature_phrases", [])
        exemplars = self.profile.get("exemplar_texts", [])
        
        dos_text = "\n".join([f"- {item}" for item in dos])
        donts_text = "\n".join([f"- {item}" for item in donts])
        
        exemplar_text = ""
        if exemplars:
            exemplar_text = "\n\nBrand copy examples (study these for style):\n"
            for i, ex in enumerate(exemplars[:3], 1):
                exemplar_text += f"\nExample {i}: {ex}"
        
        return f"""You are a content creator for {self.brand_name}.

Brand voice characteristics:
{chr(10).join([f"- {k}: {v}" for k, v in voice_attrs.items()])}

Content guidelines:
DO:
{dos_text}

DON'T:
{donts_text}

{f"Brand vocabulary (use naturally): {', '.join(keywords)}" if keywords else ""}

{exemplar_text}"""


# Example: tech brand voice profile
TECH_BRAND_PROFILE = {
    "brand_name": "YiteAI",
    "voice_attributes": {
        "tone": "Professional yet approachable",
        "personality": "Intelligent, curious, genuinely excited about technology",
        "formality": "Semi-formal; avoid overly academic language"
    },
    "dos": [
        "Use clear, specific language — avoid hollow tech buzzwords",
        "Explain complex concepts with analogies and real-life scenarios",
        "Acknowledge technical limitations honestly",
        "Center user value over technical features"
    ],
    "donts": [
        "Never use 'disruptive', 'revolutionary', or similar hype terms",
        "Avoid passive voice ('it was designed to...')",
        "Don't stack technical jargon to signal expertise",
        "Don't make unverifiable claims"
    ],
    "brand_keywords": ["intelligent", "efficient", "reliable", "simple"],
    "exemplar_texts": [
        "You don't need to understand machine learning, just like you don't need to understand combustion engines to drive a car. YiteAI handles the complex parts under the hood.",
        "Data privacy isn't a feature — it's a foundation. We don't collect anything you don't need us to."
    ]
}

77.2.4 Style Transfer

def style_transfer(
    source_text: str,
    target_style_exemplar: str,
    preserve_elements: list = None
) -> str:
    """Transfer the style of a text while preserving its content."""
    preserve_text = ""
    if preserve_elements:
        preserve_text = "\n\nNote: The following elements must be preserved verbatim:\n" + \
            "\n".join([f"- {el}" for el in preserve_elements])
    
    transfer_prompt = f"""Rewrite the first text using the style of the second text.

Source text (preserve content, change style):
{source_text}

Target style reference (use for style only, do not use its content):
{target_style_exemplar}
{preserve_text}

Output the style-transferred version at approximately the same length:"""
    
    response = client.messages.create(
        model="claude-opus-4-5",
        max_tokens=len(source_text) * 2 + 500,
        messages=[{"role": "user", "content": transfer_prompt}]
    )
    
    return response.content[0].text

77.3 Content Diversity

77.3.1 Measuring Diversity

Content diversity can be measured across multiple dimensions:

import re

def compute_content_diversity(texts: list) -> dict:
    if len(texts) < 2:
        return {"error": "Need at least 2 texts for diversity evaluation"}
    
    # 1. Vocabulary diversity
    all_words = []
    per_text_words = []
    for text in texts:
        words = re.findall(r'\b\w+\b', text.lower())
        all_words.extend(words)
        per_text_words.append(set(words))
    
    vocabulary_size = len(set(all_words))
    
    # 2. Opening diversity (first 20 characters)
    openings = [text[:20] for text in texts]
    opening_diversity = len(set(openings)) / len(texts)
    
    # 3. Sentence length variance
    sentence_lengths = []
    for text in texts:
        sentences = re.split(r'[.!?]', text)
        sentences = [s for s in sentences if s.strip()]
        sentence_lengths.extend([len(s.split()) for s in sentences])
    
    length_variance = 0
    if sentence_lengths:
        mean_len = sum(sentence_lengths) / len(sentence_lengths)
        length_variance = sum((l - mean_len) ** 2 for l in sentence_lengths) / len(sentence_lengths)
    
    return {
        "vocabulary_size": vocabulary_size,
        "opening_diversity_ratio": opening_diversity,
        "sentence_length_variance": length_variance,
        "diversity_score": (opening_diversity * 0.4 +
                           min(length_variance / 100, 1) * 0.3 +
                           min(vocabulary_size / 1000, 1) * 0.3)
    }

77.3.2 Diversity Enhancement Techniques

def generate_diverse_variations(
    base_content: str,
    n_variations: int = 5,
    diversity_axes: list = None
) -> list:
    """
    diversity_axes options:
    - "angle": vary the approach/perspective
    - "structure": vary the organizational pattern
    - "tone": vary tone within brand-acceptable range
    - "hook": vary the opening hook
    """
    if diversity_axes is None:
        diversity_axes = ["angle", "structure", "hook"]
    
    diversity_prompt = f"""Generate {n_variations} distinct variations of the following content.

Core content:
{base_content}

Diversity requirements:
{chr(10).join([f"- Vary the: {axis}" for axis in diversity_axes])}

Key constraints:
- All variations must convey identical core information and value proposition
- Differences must be genuine, not superficial word substitutions
- No two variations may have the same opening sentence

Output format:
<variation_1>[Variation 1]</variation_1>
<variation_2>[Variation 2]</variation_2>
... and so on"""
    
    response = client.messages.create(
        model="claude-opus-4-5",
        max_tokens=n_variations * (len(base_content) + 200),
        temperature=0.9,
        messages=[{"role": "user", "content": diversity_prompt}]
    )
    
    text = response.content[0].text
    variations = []
    for i in range(1, n_variations + 1):
        tag = f"variation_{i}"
        if f"<{tag}>" in text:
            variation = text.split(f"<{tag}>")[1].split(f"</{tag}>")[0].strip()
            variations.append(variation)
    
    return variations

77.3.3 Breaking Repetitive Patterns

Claude exhibits habitual opening patterns at scale ("Certainly...", "Great question...", etc.). Explicitly prohibit them:

ANTI_REPETITION_INSTRUCTIONS = """Diversity requirements:
- Do NOT start with confirmation phrases like "Certainly", "Of course", "Great", "Sure"
- Do NOT use the same three-part structure (First... Second... Finally...) every time
- Do NOT end every paragraph with the same transitional phrase
- Do NOT overuse exclamation marks
- Vary the frequency of key terms across variations

If you notice yourself repeating a pattern, actively break it."""

77.4 Brand Consistency Management

77.4.1 Content Quality Gate

class ContentQualityGate:
    
    def __init__(self, brand_profile: BrandVoiceProfile):
        self.brand_profile = brand_profile
    
    def check_brand_consistency(self, content: str) -> dict:
        check_prompt = f"""Check whether the following content conforms to the brand voice guidelines.

Brand guidelines:
{self.brand_profile.to_system_prompt()}

Content to check:
{content}

Check for:
1. Does it violate any "DON'T" rules?
2. Does it reflect the brand voice characteristics?
3. Is the vocabulary aligned with the brand tone?
4. How is the overall consistency?

Output as JSON:
{{
  "passes": true/false,
  "overall_score": 0-10,
  "violations": [
    {{"rule": "...", "excerpt": "...", "suggestion": "..."}}
  ],
  "strengths": [...],
  "revision_needed": true/false
}}"""
        
        response = client.messages.create(
            model="claude-opus-4-5",
            max_tokens=1000,
            messages=[{"role": "user", "content": check_prompt}]
        )
        
        import json
        try:
            return json.loads(response.content[0].text)
        except:
            return {"raw_check": response.content[0].text}
    
    def auto_revise(self, content: str, violations: list) -> str:
        violations_text = "\n".join([
            f"- Issue: {v['rule']}; Original: \"{v['excerpt']}\"; Suggestion: {v['suggestion']}"
            for v in violations
        ])
        
        revision_prompt = f"""Revise the following content to fix the brand voice issues.

Original content:
{content}

Issues to fix:
{violations_text}

Brand guidelines:
{self.brand_profile.to_system_prompt()}

Output the revised version directly without explanation:"""
        
        response = client.messages.create(
            model="claude-opus-4-5",
            max_tokens=len(content) * 2,
            messages=[{"role": "user", "content": revision_prompt}]
        )
        
        return response.content[0].text

77.4.2 Complete Content Generation Pipeline

class ContentGenerationPipeline:
    
    def __init__(self, brand_profile: BrandVoiceProfile):
        self.brand = brand_profile
        self.quality_gate = ContentQualityGate(brand_profile)
    
    def generate(
        self,
        content_brief: str,
        content_type: str,
        n_variations: int = 3,
        max_revisions: int = 2
    ) -> list:
        """
        Full pipeline:
        1. Generate initial draft (with brand voice)
        2. Quality check
        3. Auto-revise if needed (up to max_revisions times)
        4. Return approved variations
        """
        system_prompt = self.brand.to_system_prompt()
        
        generation_prompt = f"""Generate {n_variations} {content_type} variations for the following brief.

Content brief:
{content_brief}

Each variation should be distinct and true to the brand voice.

<variant_1>[Content 1]</variant_1>
<variant_2>[Content 2]</variant_2>
<variant_3>[Content 3]</variant_3>"""
        
        response = client.messages.create(
            model="claude-opus-4-5",
            max_tokens=3000,
            system=system_prompt,
            messages=[{"role": "user", "content": generation_prompt}]
        )
        
        variants = self._parse_variants(response.content[0].text, n_variations)
        approved_variants = []
        
        for variant in variants:
            current = variant
            for revision in range(max_revisions + 1):
                check_result = self.quality_gate.check_brand_consistency(current)
                
                if check_result.get("passes", True):
                    approved_variants.append({
                        "content": current,
                        "quality_score": check_result.get("overall_score", 8),
                        "revisions": revision
                    })
                    break
                elif revision < max_revisions:
                    violations = check_result.get("violations", [])
                    if violations:
                        current = self.quality_gate.auto_revise(current, violations)
                else:
                    approved_variants.append({
                        "content": current,
                        "quality_score": check_result.get("overall_score", 5),
                        "revisions": revision,
                        "quality_warnings": check_result.get("violations", [])
                    })
        
        return approved_variants
    
    def _parse_variants(self, text: str, n: int) -> list:
        variants = []
        for i in range(1, n + 1):
            tag = f"variant_{i}"
            if f"<{tag}>" in text:
                variant = text.split(f"<{tag}>")[1].split(f"</{tag}>")[0].strip()
                variants.append(variant)
        return variants

77.5 A/B Test Copy Generation

def generate_ab_test_copy(product_feature, target_audience, platform, n_variants=4) -> dict:
    """
    Generate systematically varied A/B test copy.
    Each variant uses a different core appeal type.
    """
    APPEAL_TYPES = [
        "Rational appeal: emphasize features, data, efficiency gains",
        "Emotional appeal: emphasize feelings, experience, sense of belonging",
        "FOMO (fear of missing out): emphasize what competitors are already gaining",
        "Social proof: emphasize user count, reviews, word of mouth"
    ]
    
    appeals = APPEAL_TYPES[:n_variants]
    
    ab_prompt = f"""Generate {n_variants} A/B test copy variants.

Product feature: {product_feature}
Target audience: {target_audience}
Platform: {platform}

Each variant uses a different appeal type:
{chr(10).join([f"Variant {i+1}: {appeal}" for i, appeal in enumerate(appeals)])}

Each variant needs:
- Headline (under 10 words)
- Body copy (50-80 words)
- Call to action (under 8 words)

Output format:
<variant_1>
Headline: [headline text]
Body: [body copy]
CTA: [call to action]
Appeal type: [appeal used]
</variant_1>
... and so on"""
    
    response = client.messages.create(
        model="claude-opus-4-5",
        max_tokens=2000,
        messages=[{"role": "user", "content": ab_prompt}]
    )
    
    return {
        "variants": response.content[0].text,
        "test_setup": {"appeal_types": appeals, "platform": platform}
    }

Summary

Engineering creative writing does not eliminate creativity — it provides reliable infrastructure for creativity to operate consistently at scale. Style control is most effective through exemplars: showing the model what "good" and "bad" look like beats abstract descriptions every time. Diversity management requires proactively monitoring diversity metrics and applying multi-axis variation strategies to prevent homogenization. Brand consistency management requires encoding brand voice into executable checking rules and building an automated revision loop.

Together these three form the quality control system of a content generation factory: style control ensures output "sounds right," diversity management ensures mass output doesn't feel repetitive, and brand consistency management ensures every piece adds to brand equity rather than eroding it.

Rate this chapter
4.9  / 5  (3 ratings)

💬 Comments