Fundamentals

Prompt Basics

Fundamentals of prompting

What is a Prompt?

A prompt is a text instruction you send to a language model. The quality of the prompt directly affects the quality of the response. A good prompt clearly formulates the task, provides necessary context, and specifies the desired output format.

Specificity Principle

The more specific the prompt, the better the result. Instead of "write text" specify: topic, length, style, audience, format. The model can't read minds — everything important must be in the prompt.

Iterative Approach

It's rare to write a perfect prompt on the first try. Start with a simple version, evaluate the result, identify issues, and improve the prompt. Repeat until the result meets expectations.

Testing Prompts

Test prompts on different inputs. A prompt that works for one example may give poor results for others. Create a set of test cases and verify against them.

Interactive Demo

Iterative Prompt Improvement

Good prompts are created through iterations

Version 1

Write about dogs.

Quick Tips

Be specific
Write something
Write a 100-word summary of...
Provide context
Is this good?
Review this code for security issues: [code]
Specify format
List some ideas
List 5 ideas as bullet points, each under 20 words
Define the audience
Explain machine learning
Explain ML to a 10-year-old using everyday examples

Key Principles

  • Start simple, add complexity as needed
  • Test on different examples
  • Analyze errors and improve
  • Save prompts that work
  • Be specific about expectations
Common Mistakes
  • Too vague:"Help me with code"
  • No context:"What's wrong here?" (no code)
  • Contradicting instructions:"Be brief, but describe everything in detail"
  • Expecting mind reading:No requirements for format, style, length
Good Practices
  • Specify role:"You are an experienced Python developer..."
  • Provide context:"In the context of a React web application..."
  • Specify format:"Respond in bullet point format"
  • Give examples:"For example: input → output"
Basic Prompt Structure
[ROLE] — Who the model should be
You are a [role] with expertise in [domain].

[CONTEXT] — Background information
Context: [relevant information about the situation]

[TASK] — What needs to be done
Task: [clear task description]

[FORMAT] — How the response should look
Response format:
- [requirement 1]
- [requirement 2]

[CONSTRAINTS] — What to avoid
Constraints:
- Don't [constraint 1]
- Don't [constraint 2]