Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT SWIFT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING HTML & CSS BASH RUST

AWS Prompting Techniques


Fundamentals of Prompt Engineering

Prompt engineering is an emerging field that focuses on developing, designing, and optimizing prompts to improve the output of LLMs for your needs.

With prompt engineering, you can guide the model's behavior to achieve the outcomes you want.


Prompt Engineering vs Fine-Tuning

Prompt Engineering vs Fine-Tuning

Prompt engineering differs from fine-tuning.

When fine-tuning, you adjust the weights or parameters using training data to optimize a cost function.

Fine-tuning can be an expensive process, both in computation time and cost.

With prompt engineering, you guide the trained foundation model (FM), large language model (LLM), or text-to-image model to provide more relevant and accurate answers.


LLM Interactions

LLM Interactions

Prompt engineering is the fastest way to harness the power of large language models.

By interacting with an LLM through a series of questions, statements, or instructions, you can adjust LLM output behavior based on the specific context of the output you want to achieve.

Effective prompt techniques can help your business accomplish the following benefits:

  • Boost a model's abilities and improve safety.
  • Augment the model with domain knowledge and external tools without changing model parameters or fine-tuning.
  • Interact with language models to grasp their full capabilities.
  • Achieve better quality outputs through better quality inputs.

Elements of a prompt

A prompt's form depends on the task. Prompts can contain some or all of the following elements:

Instructions
Task description or how to perform it
Context
Information to guide the model
Input data
The input for which you want a response
Output indicator
The output type or format

Example prompt breakdown

U
Write a summary of a service review using two sentences.

Store: Online, Service: Shipping.

Review: Amazon Prime Student is a great option for students looking to save money. Not paying for shipping is the biggest save in my opinion. As a working mom of three who is also a student, it saves me tons of time with free 2-day shipping...
Instructions Context Input data Output indicator
AI
Amazon Prime Student is a fantastic option for college students, offering free 2-day shipping, streaming services, books, and other benefits for half the price of a regular Prime membership. It saves time and money, making college life easier.

Design effective prompts

Carefully design your prompts for the best output. Each tip below includes examples comparing less effective and more effective prompts:

1. Be clear and concise

Use straightforward, natural language. Avoid ambiguity and isolated keywords.

Less effective prompt
Compute the sum total of the subsequent sequence of numerals: 4, 8, 12, 16.
More effective prompt
What is the sum of these numbers: 4, 8, 12, 16?

2. Include context

Provide details that help the model respond accurately—type of business, intended use, etc.

Less effective prompt
Summarize this article: [insert article]
More effective prompt
Provide a summary of this article to be used in a blog post: [insert article]

3. Specify the response format

State the format (summary, list, poem), length, style, or content requirements clearly.

Less effective prompt
What is the capital?
More effective prompt
What is the capital of New York? Provide the answer in a full sentence.

4. Mention desired output at the end

State what response you want at the end to keep the model focused.

Less effective prompt
Calculate the area of a circle.
More effective prompt
Calculate the area of a circle with radius 3 inches. Round to the nearest integer.

5. Start with a question

Use who, what, where, when, why, or how for more specific answers.

Less effective prompt
Summarize this event.
More effective prompt
Why did this event happen? Explain in three sentences.

6. Provide example responses

Include example output format so the model understands what you expect.

Less effective prompt
Determine the sentiment of this post: [insert post]
More effective prompt
Determine sentiment using examples:
"great pen" => Positive
"I hate when my phone dies" => Negative
[insert post] =>

7. Break up complex tasks

  • Divide into subtasks - Split into multiple prompts if results aren't reliable.
  • Ask for confirmation - Check if the model understood your instruction.
  • Think step by step - Ask the model to reason through the problem systematically.

8. Experiment and be creative

Try different prompts, determine what works, and adjust accordingly.


Evaluate model responses

Review responses to ensure quality. Make changes as needed, you can even ask one model to check output from another. Prompt engineering is an iterative skill that improves with practice.


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.