Skip to content

Current path

Prompt Engineering
Level: Intermediate33 lessons
Progress0/33 · 0%

Advanced Outputs

Information Extraction and Classification

Design prompts to extract defined fields or classify inputs using clear categories and definitions.

In this lesson

Why this matters

Extraction maps present information into fields; classification chooses from defined labels. Define labels, boundaries, and an unknown state so the model is not forced to invent a value.

How to apply it

  1. Define the task and desired outcome.
  2. Add only context or rules that affect success.
  3. Specify an output form or checkable criterion when needed.
  4. Test on realistic input and revise when a failure pattern appears.

Practical example

Weak example:

text
Weak version of the same task: صنف الرسائل كما تراه مناسبًا.

The weak version leaves an important part of the task or its boundaries to guesswork. The improved version adds information tied directly to success without treating length or complexity as a goal.

Improved example:

text
Improved version: اختر واحدة فقط: billing/technical/delivery/other؛ استخدم other عند نقص الدليل؛ أعد id وcategory.

Short practice

Apply the lesson concept to this task: أنشئ 4 فئات لمتجر واكتب حالة حدّية لكل فئة.

Check your understanding

Check: كيف نتعامل مع حالة لا تناسب فئة بثقة؟
Answer: نحدد unknown/other بدل إجبار اختيار غير مدعوم.

Summary

Keep this concept as one tool rather than a magic formula. Tie it to the goal and success criteria, then build on it in the next lesson.