TellWorldAI World Archive
Ask中文

Home›Practice›Practice

Practice

Advanced prompting techniques

Seven prompting techniques you can stack: few-shot, chain-of-thought, generated knowledge, least-to-most, self-refine, maieutic, plus temperature control. You will pick the right mix for a task and make outputs predictable.

Once you can write a competent prompt, the next step is knowing which technique to reach for and how to stack them. This page walks through seven foundational techniques — from few-shot to maieutic prompting — shows how to wire your own company data into a prompt, and explains the temperature parameter that makes outputs predictable or creative on demand.

Prompting is an emergent skill

Prompt engineering is the process of creating prompts that produce the desired outcome — less an engineering discipline than a set of techniques you can apply [1]. Worth remembering: prompting is an emergent property of an LLM, not a feature built into the model but something discovered through use [1].

The seven basic techniques

Zero-shot is a single prompt answered purely from training data, like "What is Algebra?" [1]. Few-shot adds examples: give the model a few Shakespearean sonnets and ask for one about the moon, and the examples carry the context, format, and style of the output [1]:

Write a poem in the style of Shakespeare. Here are a few examples of Shakespearean sonnets.:
  Sonnet 18: 'Shall I compare thee to a summer's day? Thou art more lovely and more temperate...'
  Sonnet 116: 'Let me not to the marriage of true minds Admit impediments. Love is not love Which alters when it alteration finds...'
  Sonnet 132: 'Thine eyes I love, and they, as pitying me, Knowing thy heart torment me with disdain,...'
  Now, write a sonnet about the beauty of the moon.

Chain-of-thought teaches the model how to break a problem into steps. The classic demo: ask "Alice has 5 apples, throws 3 apples, gives 2 to Bob and Bob gives one back" and the model answers 5 — wrong; the correct answer is 1 (5 - 3 - 2 + 1). With a worked example showing the calculation, the model answers 1 [1]:

Lisa has 7 apples, throws 1 apple, gives 4 apples to Bart and Bart gives one back:
  7 -1 = 6
  6 -4 = 2
  2 +1 = 3  
  Alice has 5 apples, throws 3 apples, gives 2 to Bob and Bob gives one back, how many apples does Alice have?

The prompt gets substantially longer — example, calculation, original question — which is the price and the point of the technique. Generated knowledge adds facts to the prompt, least-to-most splits a big problem into ordered subproblems (collect, clean, analyze, plot, present data, for the data-science case) [1]. Self-refine and maieutic prompting make the model critique itself; both get their own section below.

Generated knowledge: wiring in your own data

Prompts often need to be built from your company's data. The standard shape is a template with {{variable}} placeholders that get replaced with real values from your API [1]:

{{company}}: {{company_name}}
{{products}}:
{{products_list}}
Please suggest an insurance given the following budget and requirements:
Budget: {{budget}}
Requirements: {{requirements}}

Filled with sample data [1]:

Insurance company: ACME Insurance
Insurance products (cost per month):
- Car, cheap, 500 USD
- Car, expensive, 1100 USD
- Home, cheap, 600 USD
- Home, expensive, 1200 USD
- Life, cheap, 100 USD

Please suggest an insurance given the following budget and requirements:
Budget: $1000
Requirements: Car, Home, and Life insurance

Run as-is, the model suggested a package that also included the Life insurance — not what the budget allowed. The fix came from trial and error: add type and cost fields to each product line and the keyword restrict to the budget line [1]:

Insurance company: ACME Insurance
Insurance products (cost per month):
- type: Car, cheap, cost: 500 USD
- type: Car, expensive, cost: 1100 USD
- type: Home, cheap, cost: 600 USD
- type: Home, expensive, cost: 1200 USD
- type: Life, cheap, cost: 100 USD

Please suggest an insurance given the following budget and requirements:
Budget: $1000 restrict choice to types: Car, Home

Now the answer is a single recommendation, the Car cheap product at 500 USD per month [1]. The takeaway: even a basic technique like generated knowledge still needs prompt optimization in most cases before it delivers the outcome you want [1].

Making the model critique itself

LLM output cannot be trusted blindly — the model predicts what is most likely to say next, not what is correct — so two techniques put verification into the loop [1].

Self-refine runs a four-step cycle: initial prompt, model answers, you critique the answer and ask for improvements, the model answers again with the critique in mind; repeat as often as you like [1]. Asked to "Create a Python Web API with routes products and customers", the model produced code with a wrong import; asked for three improvements, it named the correct import (from flask import Flask), a missing if __name__ == '__main__': block, and f-strings for the return statements, then delivered the corrected program [1].

Maieutic prompting goes deeper: ask the model to explain each part of its answer and discard inconsistent parts. On a pandemic crisis plan, the model listed five steps, explained the risks (loss of life, business, reputation, customers, employees), and answered consistently — loss of life and loss of business — when asked which risks were biggest [1]. Consistency raises confidence, but the output should still be verified by a human [1].

Temperature: predictable or varied output

LLMs are nondeterministic: the same prompt run twice can produce two completely different Flask programs [1]. Whether that is a problem depends on the task — a request like "Generate any 3 questions on geography" welcomes variety, while a specific output format demands control [1].

Temperature is the main control: a value between 0 and 1, where 0 is the most deterministic, 1 the most varied, and the default is 0.7 [1]. Two runs at 0.1 differ only slightly; at 0.9 the results could not be more varied [1]. Other knobs exist — top-k, top-p, repetition penalty, length penalty, diversity penalty — but they are beyond the basics [1].

Five habits that raise quality

Specify context — domain, topic, the more the better; limit the output to a number or length; specify both what and how ("Create a Python Web API with routes products and customers, divide it into 3 files"); use templates to enrich prompts with your data; and spell correctly — misspellings still get answers, but correct spelling gets better ones [1].

Adapted from lesson 5 of Microsoft's open-source course *Generative AI for Beginners*[1], released under the MIT License.

Sources

  1. 1
    Creating Advanced Prompts | Generative AI for BeginnersMicrosoft generative-ai-for-beginners (MIT)

Cite this page: Advanced prompting techniques. TellWorld, https://www.tellworld.net/practice/practice-advanced-prompts. Updated 2026-11-14

Related news

View all