1.9 Prompt engineering

NCA-GENL · Core Machine Learning and AI Knowledge (30% of the exam) · Official objective: “Use prompt engineering principles to create prompts to achieve desired results.”

How to word prompts and set sampling options to get the result you want.

Key points

  1. NVIDIA describes chain-of-thought prompting as providing few-shot examples where the reasoning process is explained, so the large language model (LLM) shows its reasoning when it answers.

    What NVIDIA says (1)

    “Do this by providing some few-shot examples, where the reasoning process is explained. When the LLM answers the prompt, it shows its reasoning process as well.”

    — An Introduction to Large Language Models: Prompt Engineering and P-Tuning

  2. At a lower temperature the model is more conservative and only picks higher-probability tokens. NVIDIA notes lower temperatures suit definitive tasks like question answering or summarization.

    What NVIDIA says (2)

    “Lower temperatures are suitable for more definitive tasks like question-answering or summarization.”

    — How to Get Better Outputs from Your Large Language Model

    “At a lower temperature, the model is more conservative and is limited to choosing tokens with higher probabilities.”

    — How to Get Better Outputs from Your Large Language Model

  3. NVIDIA defines zero-shot as prompting the model without any example of the expected behavior. For example, a zero-shot prompt simply asks a question.

    What NVIDIA says (2)

    “Zero-shot means prompting the model without any example of expected behavior from the model.”

    — An Introduction to Large Language Models: Prompt Engineering and P-Tuning

    “For example, a zero-shot prompt asks a question.”

    — An Introduction to Large Language Models: Prompt Engineering and P-Tuning

  4. System prompting adds a system-level prompt to the user prompt. It gives the large language model (LLM) specific, detailed instructions on how to behave.

    What NVIDIA says (1)

    “This approach involves adding a system-level prompt in addition to the user prompt to provide specific and detailed instructions to the LLMs to behave as intended.”

    — Mastering LLM Techniques: Customization

Key terms

Try it

Sample question

Which prompt technique helps a large language model (LLM) on multi-step reasoning by showing worked reasoning in the examples?

Show the answer

Answer: Few-shot chain-of-thought prompting

NVIDIA describes chain-of-thought prompting as providing few-shot examples where the reasoning process is explained, so the large language model (LLM) shows its reasoning when it answers.

What NVIDIA says (1)

“Do this by providing some few-shot examples, where the reasoning process is explained. When the LLM answers the prompt, it shows its reasoning process as well.”

— An Introduction to Large Language Models: Prompt Engineering and P-Tuning

Practice 1.9 (4 questions) Full Core Machine Learning and AI Knowledge guide

← 1.8 Text embeddings · 1.10 Traditional ML with Python packages →