Skip to content

Prompt Engineering: Basic Principles

Brief

Prompt engineering is the practice of crafting instructions for LLMs to elicit predictable and high-quality responses. See also Prompt.

What is a Prompt

A prompt is the input data for an LLM that defines the task and context. The quality of the prompt directly affects the quality of the response. A poorly formulated prompt can lead to incorrect or incomplete answers.

Key Components of a Prompt

  • Instruction — what needs to be done.
  • Context — additional information that helps the model understand the task.
  • Examples — demonstrations of the expected response format.
  • Input data — data that needs to be processed.
  • Output format — how the response should look.

Principles of Prompt Construction

  1. Be specific. Instead of saying "Write an article," specify the topic, style, length, and target audience.
  2. Use separators. Clearly delineate instructions from context and examples.
  3. Provide examples. Few-shot examples help the model understand the expected format.
  4. Specify constraints. If the response should be brief or in Russian, state this.
  5. Use a system prompt. A system prompt sets the overall behavior of the model. More details in the article System Prompt.

Examples

Bad Prompt

Translate the text.

Good Prompt

Translate the following text from English to Russian, maintaining an official tone.

Text: "The meeting is scheduled for 10 AM."

Translation:

The Role of Context

LLMs use context to generate responses. The more relevant context you provide, the more accurate the response will be. However, context is limited by the window size. More details in the article Context Window.

Conclusion

Prompt engineering is an iterative process. Experiment with formulations, use examples, and evaluate the results. Over time, you will develop your own templates that work for your tasks.