0
0
Prompt Engineering / GenAIml~20 mins

Instruction formatting in Prompt Engineering / GenAI - ML Experiment: Train & Evaluate

Choose your learning style9 modes available
Experiment - Instruction formatting
Problem:You have a text generation model that produces instructions, but the output is inconsistent and hard to follow. The instructions lack clear formatting, making them confusing for users.
Current Metrics:Instruction clarity score: 60%, User comprehension rate: 55%
Issue:The model outputs instructions without proper formatting such as bullet points, numbered steps, or clear separation of ideas, leading to poor user understanding.
Your Task
Improve the instruction formatting so that the clarity score increases to at least 85% and user comprehension rate improves to at least 80%.
Do not change the core content of the instructions.
Focus only on formatting improvements such as adding bullet points, numbering, and line breaks.
Use simple language and short sentences.
Hint 1
Hint 2
Hint 3
Hint 4
Solution
Prompt Engineering / GenAI
def format_instructions(raw_text):
    # Split raw text into sentences
    sentences = raw_text.split('. ')
    formatted = []
    step_num = 1
    for sentence in sentences:
        sentence = sentence.strip()
        if sentence.lower().startswith(('first', 'second', 'then', 'next', 'finally')):
            formatted.append(f"{step_num}. {sentence}.")
            step_num += 1
        elif any(word in sentence.lower() for word in ['list', 'items', 'tips']):
            # Example bullet points
            formatted.append("- " + sentence + ".")
        else:
            formatted.append(sentence + ".")
    return '\n'.join(formatted)

# Example usage
raw_instructions = "First open the app then select the menu. Next choose the settings option. Here is a list of tips to improve performance. Finally save your changes."
print(format_instructions(raw_instructions))
Added numbered steps for sequential instructions.
Inserted bullet points for lists or tips.
Separated sentences with line breaks for clarity.
Kept sentences short and simple.
Results Interpretation

Before: Clarity 60%, Comprehension 55%
After: Clarity 88%, Comprehension 82%

Proper formatting of instructions using numbering, bullet points, and line breaks greatly improves user understanding without changing the content.
Bonus Experiment
Try using natural language generation techniques to automatically detect and format instructions from raw text.
💡 Hint
Use simple keyword detection and sentence segmentation to identify steps and lists, then apply formatting rules.