Prompt Engineering
Automatic prompting: LLM iterates on prompt & improves quality based on e.g. clf performance.
Chain of thought: Each example explains how the problem is solved step-by-step: the problem is broken into small parts that are solved individually. Improves reasoning performance.
Chain of code (outperforms CoT): encourage LLM to format linguistic or arithmetic sub-tasks in a program as flexible pseudocode - broadens the scope of problems LMs can tackle. Steps:
Define a linguistic or arithmetic reasoning task
Code: LM writes code / pseudocode to outline a solution.
Emulation of code: for non-executable parts of code, the LM emulates the expected outcome, simulating the code execution.
Combining outputs: LM combines code execution + emulation = comprehensive solution
|
Google Prompting Framework
|
WISER Framework (similar, but missing context)
|
1. Write Clear and Specific Instructions: longer prompts w/context & details yield more accurate results.
Use Delimiters for Clarity (triple backticks)
Ask for structured output (JSON)
Ask the model to check conditions (if then)
Provide examples ("Few-shot" prompts)
2. Give the model time to “think”: specify steps, let model think step by step before giving the final answer.
3. Balance specificity with creativity - be specific + let the model be creative: a) exhaustive details and context, b) top p - higher p increase randomness / creativity in next word prediction, lower p - next-token selection more predictable (default 1.0), c) temperature – higher temp. increases randomness / creativity (default 1.0)
4. “Act as…”: extremely powerful.
5. Always double-check if hallucinations (e.g. ask for documentation as proof)
6. Iterate to find more efficient prompts (change words)
7. Itemize instructions (better to understand vs. long paragraphs)
8. Avoid negations (confuses model)
9. Chain-of-thought prompting
Verbalized Sampling - sample LLM responses for better ideas!
Instead of asking for a single "best" answer Ask the model to generate 5 distinct responses with their respective probabilities - 2.1x higher creativity levels.
Rationale: direct prompts can limit LLM’s capabilities. Post-training alignment (e.g., RLHF) introduced the narrow alignment bias which can lead to "mode collapse" (outputs of limited variety, not capturing full diversity of training data distribution). But creativity isn't gone, it’s just suppressed.
Retrieval Augmented Thoughts (RAT): RAG + COT ⇒ RAT - iterative CoT prompts w/info retrieval: reason → retrieve → refine → answer (vs. retrieve → generate in regular RAG).
Prompt LLM w/ zero-shot CoT to generate preliminary reasoning steps.
At each reasoning step, retrieve relevant external information (documents, facts, evidence).
Revise and improve the CoT steps using the retrieved context, correcting or enriching the reasoning.
Generate response using revised reasoning chain and retrieved context.
RankPrompt: elicits high-quality feedback from LLM & enables LLMs to self-rank their responses using in-context learning, without additional resources: a) breaks down ranking problem into series of comparisons among responses, b) leverage the inherent capabilities of LLMs to generate chains of comparison as contextual exemplars, c) experiments w/11 arithmetic and commonsense reasoning tasks - enhances LLM reasoning.