Editing
Prompt Engineering
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''Prompt templates for common use cases:''' ; Zero-shot classification <syntaxhighlight lang="python"> prompt = """Classify the sentiment of the following customer review. Return ONLY one of: POSITIVE, NEGATIVE, NEUTRAL. Review: "{review_text}" Sentiment:""" </syntaxhighlight> ; Chain-of-thought for math/reasoning <syntaxhighlight lang="python"> prompt = """Solve this problem step by step. Show your reasoning clearly. After working through it, state your final answer on a new line beginning with "Answer:". Problem: A train travels at 60 mph for 2 hours, then at 90 mph for 1.5 hours. What is the total distance traveled?""" # Model will reason: "60Γ2=120, 90Γ1.5=135, total=255 miles" β Answer: 255 miles </syntaxhighlight> ; Structured output (JSON) <syntaxhighlight lang="python"> prompt = """Extract the following information from the job posting below. Return ONLY valid JSON with exactly these fields: { "job_title": string, "company": string, "location": string, "salary_range": string or null, "required_skills": [list of strings], "experience_years": number or null } Job Posting: --- {job_posting_text} --- JSON:""" </syntaxhighlight> ; Few-shot prompting <syntaxhighlight lang="python"> prompt = """Convert informal English to formal business English. Informal: "Hey, just wanted to check in on that report thing" Formal: "I am writing to inquire about the status of the report." Informal: "Can you send that over ASAP?" Formal: "Could you please expedite the delivery of the requested document?" Informal: "{user_input}" Formal:""" </syntaxhighlight> ; Key prompt engineering techniques reference : '''Chain-of-thought''' β "Think step by step" / "Let's reason through this" : '''Self-consistency''' β Sample 5β10 times at temp=0.7, take majority answer : '''Tree of Thoughts''' β Explore multiple reasoning branches, evaluate, backtrack : '''Least-to-most''' β Break complex task into sub-tasks, solve sequentially : '''Generated Knowledge''' β Ask model to generate relevant facts first, then answer : '''Directional Stimulus''' β Include a hint or keyword that steers output direction </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information