An AI-based video generation system produced zen koan-style philosophical statements about code patterns. While the statements appeared unique, they repeated identical structural patterns (e.g., ‘The X doesn’t know it’s Y until Z’), reducing their relevance and originality.
Issue
The AI-generated philosophical statements exhibited structural repetition despite high uniqueness rates (94%). Analysis revealed:
- Repeated patterns like ‘The function doesn’t know it’s a tool until the decorator tells it so’ (appeared 5 times).
- Overuse of generic koan structures unrelated to the specific code being explained.
- Lack of context-specific grounding in actual code behavior.
Culprit
The system lacked contextual grounding and effective prompt engineering:
- Missing context-specific references: Statements were generated without integrating relevant documentation or code context.
- Ineffective negative prompting: Examples labeled as ‘DO NOT COPY’ inadvertently reinforced the patterns.
- Structural monotony: Prompts lacked guidance on enforcing variety in sentence subjects and paradox creation.
Solution
Contextual Grounding via Semantic Search
Integrated semantic search to retrieve relevant documentation before generating philosophical statements. This ensured the statements were grounded in actual code context.
Prompt Redesign
Redesigned prompts to:
- Remove structural examples and replace them with abstract guidance for creating paradoxes.
- Enforce variety by specifying constraints on sentence subjects (e.g., avoiding repetitive phrases like ‘The function’).
- Add context-specific constraints to align statements with the actual code being discussed.
Results
The revised system produced contextually relevant and structurally varied philosophical statements:
- Before: Repetitive and generic koans (e.g., ‘The function doesn’t know it’s a tool until the decorator tells it so’).
- After: Unique, context-specific statements like:
- ‘The function that reveals its name becomes nameless to the model, while the nameless function speaks through borrowed words.’
- ‘The thread that disappears still holds the answer.’
This approach improved the relevance and originality of the philosophical statements while maintaining performance efficiency.