chapter seven

7 Prompt engineering: Strategies for guiding and evaluating LLMs

 

This chapter covers

  • Prompt engineering and its role in generative AI
  • Crafting effective prompts to guide model behavior
  • Assessing the quality and reliability of AI outputs
  • Comparing prompt engineering to post-training

When ChatGPT became widely available to the public in late 2022, millions of people began experimenting—not just with what these AI systems could do, but with how to ask them questions effectively. It quickly became clear that even small changes in wording could significantly shape a model’s response. A prompt like “summarize the moon landing” might return a straightforward paragraph. But add “in the voice of a noir detective,” and it becomes a gritty tale of a spacecraft called the Eagle, landing in a world of shadows and suspicion.

What is prompt engineering?

Prompting techniques and frameworks

Overview of common prompting techniques

Structuring prompts to guide model behavior

Prompting frameworks for structured output

Evolving practices in prompt engineering

Evaluating AI-generated outputs

Identifying evaluation metrics

Assembling evaluation datasets

Scoring model responses

Prompting vs. post-training

Conclusion

Summary