Introduction

In this segment of our course, we're going to dive into more complex strategies for controlling the proportions of our desired output. The example we'll use is about crafting emails. Writing emails, especially in a professional context, requires a balance between conciseness and completeness. This lesson will focus specifically on generating emails that are neither too brief nor excessively long, but rather enriched with succinct paragraphs that collectively deliver a comprehensive message.

Let's Start Simple

Here is a simple but well-structured prompt that's aimed at creating an email.

Sample Output:

The F-shaped email

Now the last output was pretty good but it's far from great. An interesting study about how humans read emails reveals that emails that are structured in a shape that resembles the letter F are easier to read. So ideally we want to help our LLM to build emails in the F shape. Let's revisit our prompt.

While we could spend a lot of time in the CONSTRAINTS section explaining how the F shape would work, the key was to add an example while keeping our description of the F shape short and to the point. The above prompt will consistently produce emails in the shape and format desired.

Conclusion

In this lesson, you've learned how to craft prompts that meet complex output size requirements. By using the creation of professional emails as an example, we've shown the importance of balance and structure—like the F-shaped format—to guide content generation. This method ensures your prompts effectively direct language models to produce outputs that are not only precise in length but also optimal in structure for any given purpose. Mastery of these techniques is key to leveraging language models to their fullest potential. On to Practice!

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal