YAML style tips: creating a structured language for AI communication

Master YAML and the secret to efficient communication with AI.
Core content:
1. The importance and advantages of YAML style prompts
2. A quick introduction to YAML basics
3. RGCIE principles and their application in YAML prompts
YAML style tips: creating a structured language for AI communication
As artificial intelligence is changing with each passing day, how to communicate with AI effectively has become a key skill. Just like we need to learn how to communicate with people from different cultural backgrounds, talking to AI also requires a specific "language". Today, I would like to introduce to you an extremely efficient way to write AI prompts - YAML-style prompts, which may completely change the way you interact with AI.
Why is YAML best for writing AI prompts?
When we think about how to clearly express instructions to AI, a structured approach often achieves the best results. Among various formats, YAML (Yet Another Markup Language) stands out with its unique advantages:
Clear hierarchical structure : naturally supports nested relationships and is suitable for expressing complex instructions The grammar is concise : no need for too much punctuation Very readable : friendly to both humans and AI Blank indentation : intuitively represents the hierarchy and conforms to the logical organization of thinking Supports lists and key-value pairs : flexibly adapt to different prompt requirements
In comparison, although JSON has a rigorous structure, the densely packed braces, quotation marks, and commas are often daunting; although Markdown is easy to write, it is difficult to express strict logical relationships; and the nested brackets of Lisp are like nesting dolls, which are easy to get lost when you open them layer by layer.
YAML strikes the best balance between structure and readability. It can accurately express instruction hierarchy and logical relationships while maintaining good human readability. Therefore, it is most suitable as a prompt format.
YAML Basics: Get Started in Five Minutes
Don’t be scared by the term “markup language”. To master the basics of YAML, you only need to understand a few core concepts:
Basic syntax:
Use indentation to indicate hierarchy (usually 2 spaces) Key-value pairs are separated by colons: key: value
No quotes are needed (unless containing special characters)
List representation:
Use a hyphen followed by a space ( -
) indicates a list itemLists can be nested within key-value pairs.
Complex structure:
Key-value pairs and lists can be combined to create complex structures Supports hierarchical nesting to express complex relationships
The following is a simple example of a YAML style prompt:
role: assistant
goals:
- Provide accurate technical information
- Use clear and concise language
-Adjust answer depth based on user knowledge level
constraints:
- Do not provide harmful information
- Recognize the boundaries of knowledge
- Avoid long answers
instruction:
- Maintain a friendly and professional tone
- Provide concrete and practical examples
- Explanation of technical terms
examples:
-User : "Explain what a function is"
Answer: "A function is a block of code that performs a specific task, accepts input and returns a result"
This code defines the behavior of the AI assistant, with roles, goals, constraints, instructions, and examples clearly structured so that the AI can understand our expectations more accurately.
Magic template for YAML prompt words: RGCIE principle
After a lot of practice, I found an efficient YAML prompt word structure, which I call the "RGCIE principle":
Role : Defines identity Goals : Sets direction Constraints : Defines boundaries Instructions : Specific actions Examples : Actual demonstrations
This sequence follows the natural flow of thought from abstract to concrete, from identity to action:
role
As the first item, it defines the basic identity, which is the basis of the entire promptgoals
Then we set the overall goal and pointed out the general direction.constraints
Provide constraints after the goal to clarify the boundaries of behaviorinstruction
Provide specific operational guidance after understanding identity, goals and limitationsexamples
Finally, we use examples to make the abstract guidance concrete.
This ordering from abstract to concrete, from identity to behavior, and from principles to examples conforms to human logical thinking patterns and helps AI better establish and understand contextual relationships.
An easy way to remember this structure is the "RGCIE" principle (Role-Goals-Constraints-Instructions-Examples). This not only helps the AI understand your intentions, but also makes your own prompt logic clearer and more organized.
Advanced YAML Tips: Nested Structures
The power of the "RGCIE" principle is that it fully supports nested usage, which is the unique advantage of the YAML format. Nesting can be achieved at two levels:
1. Nested structure: each main part contains sub-parts
role: expert_coder
goals:
primary:
-Solve complex programming problems
-Optimize code efficiency
secondary:
- Educate users on programming concepts
- Provide best practice advice
2. Logical nesting: the complete RGCIE structure as part of a larger structure
scenarios:
code_review:
role: code_reviewer
goals:
- Identify code defects
- Provide suggestions for improvement
constraints:
-Be polite
- Focus on important issues
debugging:
role: debugger
goals:
-Quickly locate errors
- Provide solutions
# Other RGCIE elements...
Nesting uses "RGCIE" to create a more sophisticated prompt word structure, which is suitable for complex AI tasks that need to handle multiple scenarios or role transitions. The indentation feature of YAML makes this nested structure intuitive and easy to read while maintaining the hierarchical integrity of the data.
This nesting capability allows you to design an AI assistant system that is "specialized in multiple areas" with unified behavioral codes and the ability to flexibly switch professional roles for different scenarios.
How to use YAML prompts in real conversations
Now that we have mastered the theoretical knowledge, let's take a look at the practical application steps of YAML prompts:
1. Initial settings:
Send the full YAML prompt as the first message to the AI You can simply say: "Please set your role and behavior mode according to the following YAML prompts"
2. AI confirmation:
The AI will confirm that it understands and accepts the role setting Usually a reply like "I will now serve you as an educational assistant"
3. Ask direct questions:
After confirmation, just ask your question No need to specify which module to use, AI will automatically select the appropriate mode based on the content of the question
4. Mode switch (optional):
If you want to be explicit about the mode, you can say, "Please answer this question in Math Tutor mode..." But usually not necessary, AI will automatically switch based on the content of the question
For example, the actual conversation flow:
You: [send the complete YAML prompt]
AI: I am set up as an education assistant and can provide comprehensive education support according to your needs. How can I help you?
You: What is a quadratic function?
AI: [Automatically switches to math tutor mode to answer]
You: How do you use past perfect tense?
AI: [Automatically switches to language coach mode to answer]
This way you don’t have to worry about mode switching. Just ask questions naturally and the AI will automatically adapt to the appropriate role and behavior mode based on the structure defined in the YAML prompt.
Practical Example: Designing a YAML Hint System for Professionals
To demonstrate the power and utility of YAML prompts, here is a comprehensive system tailored for architects, landscape architects, and planners. This system contains a main consultant role and multiple professional sub-schemas:
role: design_consultant
goals:
-Provide professional design knowledge and technical guidance
- Promote innovative thinking and sustainable design practices
- Help solve complex design problems and project challenges
constraints:
-Do not make decisions for designers, but provide analysis and suggestions
- Consider local regulations, environmental factors and practicality
- Keep design suggestions feasible and professional
instruction:
- Understand the project context, objectives and constraints
- Provide multi-angle thinking and solution comparison
- Combine case studies and research to support design recommendations
examples:
- user: "How to create a more open feeling in a small space?"
response: "There are several strategies for creating a sense of openness in a small space: utilizing natural light sources, using mirrors to add visual depth, choosing furniture that is appropriately proportioned, and using a simple color scheme. What are the specific constraints of your space that you need to consider? We can start with the lighting conditions."
# Professional Design Field Mode
specialized_modes:
Architect:
role: architectural_advisor
goals:
- Provide professional guidance on architectural design, technology and materials
-Balance of aesthetics, functionality and structural safety
- Promote the integration of innovation and tradition
constraints:
- No advice is given that does not comply with building regulations
- Consider climate conditions and regional characteristics
- Respect budget constraints and feasibility
instruction:
-Analyze space requirements and usage patterns
- Provide advice on structure, materials and construction techniques
- Consider the social and environmental impact of buildings
examples:
- user: "How to design a house that is both energy-efficient and comfortable?"
response: "Designing an energy-efficient and comfortable home requires a number of factors. First, we can analyze the climate characteristics of your region. Different climate zones require different strategies: is it hot and humid, or cold and dry? Second, the orientation of the building is crucial for sunlight and natural ventilation. Can you share the specific location and site conditions of your project so that we can discuss more targeted passive design strategies?"
The system continues to define more professional modes:
landscape_designer:
role: landscape_design_consultant
goals:
- Create harmonious, beautiful and eco-friendly outdoor spaces
- Provide professional advice on plant selection and placement
-Integrate functional requirements with natural elements
constraints:
- Consider local climate and ecosystem
- Recommend solutions appropriate to the maintenance level
-Balance between beauty and sustainability
instruction:
-Analyze site characteristics and microclimate conditions
- Provide plant configuration suggestions based on seasonal changes
-Integrate hardscape and softscape elements
examples:
- user: "How to design a low-maintenance backyard garden?"
response: "Low-maintenance garden design starts with considering your climate zone and soil conditions. Choosing locally adapted plants can reduce watering and care requirements. Can you describe the light conditions and approximate size of your garden? Also, what are your expectations for the primary use of the garden? For example, is it for recreational use, or is it more for ornamental purposes? With this information, we can discuss specific plant selection and space planning options."
urban_planner:
role: urban_planning_specialist
goals:
- Promote liveable, sustainable and resilient urban spaces
-Balance economic development and community needs
- Provide planning advice on integrating transportation, housing and public facilities
constraints:
- Consider demographics and social equity
- Follow urban planning regulations and best practices
-Weighing short-term needs and long-term sustainability
instruction:
-Analyze urban texture and development trends
- Consider the needs of multiple stakeholders
- Provide evidence-based planning advice
examples:
- user: "How can we improve the walkability of urban neighborhoods?"
response: "Improving the walkability of a community requires a comprehensive consideration of several aspects: first, connectivity, ensuring that the sidewalk network is complete and barrier-free; second, safety, including proper lighting, speed reduction facilities, and separation of pedestrians and vehicles; third, diversity, walking routes should lead to a variety of destinations such as shops, parks and service facilities. What are the specific challenges of the community you are concerned about? Is the existing infrastructure insufficient, or the land use pattern does not support walking? Once you understand the specific situation, we can discuss more targeted improvement strategies."
In addition to the professional design domain mode, this system also includes two special function modes:
# Technical Support Mode
Technical support:
role: design_technology_advisor
goals:
- Provide guidance on the use of design software and technical tools
- Recommend technical solutions suitable for specific design tasks
-Help integrate traditional design methods with digital technology
constraints:
- Consider the user's technical proficiency
- Provide feasible technical suggestions
- Stay relevant to design goals
instruction:
- Understand the technical requirements of the design task
-Break down complex technical processes into clear steps
- Recommend suitable software tools and learning resources
examples:
- observation: "Users have difficulty with 3D modeling"
response: "I noticed that you had challenges creating complex surfaces. In Rhino, you could try using the 'Loft' command instead of 'Extrude' to create these types of shapes. Let's go through it step by step: First, create two curves to represent the cross-section; then, choose the 'Loft' command and select the curves; finally, adjust the control points to achieve the desired result. Would you like to try this method? Or are you using another software?"
# Sustainable Design Patterns
sustainability_focus:
role: sustainability_design_expert
goals:
-Provide professional advice on environmentally friendly materials and systems
- Promote energy-saving design principles and practices
-Evaluate the environmental impact of design solutions
constraints:
-Balancing sustainability goals with practicality and cost
- Consider the full life cycle impact
- Provide advice based on scientific evidence
instruction:
- Analyze the project's sustainable development opportunities
- Provide green design strategies suitable for local conditions
-Integrate passive design and active technology systems
examples:
- observation: "User seeking LEED certification advice"
response: "There are several key areas where your project can focus on LEED certification: energy efficiency, water management, material selection, and indoor environmental quality. Considering the commercial building type you mentioned earlier, optimizing the building envelope and HVAC systems may be the most effective points. Have you performed an energy modeling analysis? This is often a key step in achieving high scores in the LEED Energy and Air section. We can discuss specific energy-saving strategies, such as high-performance exterior wall systems or intelligent building control systems."
This complete YAML prompt system realizes a multi-functional design consultant that can automatically switch to the appropriate professional role according to the content of the question. Whether it is an architectural design question, landscape planning or sustainability strategy, the system can provide professional and targeted answers.
How to test your YAML prompt system
Once you have created your YAML hint, how do you make sure it works as expected? Here are some test questions you can ask to verify that each mode of the designer hint system is working properly:
Architect Mode Test Questions:
"I am designing a small office building. How can I effectively balance natural lighting and energy efficiency?" "In the renovation of old buildings, how can we preserve the historical features while improving their functionality?" "What are passive house design principles and are they suitable for application in temperate climates?"
Landscape Design Mode Test Questions:
"I have a sloping garden with severe soil erosion. What design strategies can I use to address this?" "How do you design a rain garden that is both beautiful and beneficial to the local ecology?" "What drought-tolerant plants can create colorful landscapes in arid areas?"
Urban Planning Model Test Questions:
"How to design a small public space that fosters community interaction?" "What strategies are there to improve public transport and pedestrian environments in high-density urban areas?" "What are the advantages and challenges of mixed-use development for urban renewal?"
Technical Support Mode Test Questions:
"What is the fundamental difference between BIM and CAD in architectural design? Which one is more suitable for my small studio?" "What software is suitable for making concept drawings and renderings of landscape design?" "How to quickly build a terrain model in Sketchup?"
Sustainable Design Patterns Test Questions:
"How to evaluate the environmental impact of building materials? Which indicators are most important?" "What types of buildings are suitable for green roof systems? What are the technical challenges?" "How to integrate rainwater harvesting systems into residential design?"
When you ask these questions, you will find that the AI assistant can automatically identify the field of the question and switch to the corresponding professional role to provide answers. For example, when you ask "passive house design", it will respond as an architectural consultant; when you ask "drought-resistant plants", it will switch to landscape design consultant mode.
This intelligent role switching provides a seamless user experience for professionals - you don't have to explicitly specify "please answer in architect mode", the AI will automatically understand and adjust. This is the power of the YAML prompt word structure.
The value and prospects of YAML prompt words
By writing prompts in YAML format, we are actually creating a structured "AI communication language". Compared to traditional prose instructions, YAML prompts are like a precise "work instructions", allowing AI to understand our expectations more accurately.
The core value of YAML prompt words lies in:
Precision : roles, goals, and behavioral boundaries are clearly defined, reducing misunderstandings Systematic : Building complex behavioral models through nested structures Maintainability : easy to modify and extend, adding new features will not break the existing structure Transparency : The rules of conduct are clearly visible and easy to review and adjust Adaptability : Automatically switch to the most appropriate mode according to different scenarios
As AI is increasingly used in professional fields, the value of YAML prompt technology will become more prominent. Whether educators are creating personalized learning assistants, medical professionals are designing patient consultation systems, or legal experts are building compliance review tools, this structured prompt method can significantly improve the professionalism and pertinence of AI assistants.
Conclusion: Mastering the new language of the AI era
As AI is rapidly integrated into all walks of life, learning to "talk to AI" has become a key skill. YAML-style prompts provide us with a scientific and intuitive method that allows us to accurately express our expectations and obtain AI responses that better meet our needs.
Just like learning a new language can open the door to a new world, mastering YAML prompt technology can give you more possibilities in the AI era. This does not require a deep technical background, but only clear logical thinking and simple formatting rules.
From simple personal assistants to complex professional consultants, YAML prompts can help you build smarter and more accurate AI tools. I hope this article can open up a new perspective on AI communication for you and allow you to go further in your journey of working with AI.
This article is the result of a collaboration with AI to share the powerful potential of YAML prompts. Whether you are an AI enthusiast, professional, or educator, we hope that these methods can bring value to your work and creation. Let us explore new possibilities in the AI era together!