Home/AI/ML Notes/GenAI and LLMs Summary/Prompt Engineering
⌂ Main Page
GenAI and LLMs Summary

Prompt Engineering

Prompting techniques, Google's prompt-engineering guidance, verbalized sampling, RAT, and RankPrompt.

Prompt Engineering

Google Prompting Framework

  • Persona

  • Task + sub-tasks

  • Context

  • References

  • Evaluate and iterate

WISER Framework (similar, but missing context)

  • W Who - Assign an identity or role

  • I Instructions - Tell the model what to do

  • S Sub-tasks - Break it down into simpler steps

  • E Example - Provide examples (if applicable)

  • R Review - Look at output / evaluation metrics and iterate

1. Write Clear and Specific Instructions: longer prompts w/context & details yield more accurate results.

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: reasonretrieverefineanswer (vs. retrieve → generate in regular RAG).

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.