Papers
Topics
Authors
Recent
Gemini 2.5 Flash
Gemini 2.5 Flash
41 tokens/sec
GPT-4o
59 tokens/sec
Gemini 2.5 Pro Pro
41 tokens/sec
o3 Pro
7 tokens/sec
GPT-4.1 Pro
50 tokens/sec
DeepSeek R1 via Azure Pro
28 tokens/sec
2000 character limit reached

Prompt Design and Engineering: Introduction and Advanced Methods (2401.14423v4)

Published 24 Jan 2024 in cs.SE and cs.LG

Abstract: Prompt design and engineering has rapidly become essential for maximizing the potential of LLMs. In this paper, we introduce core concepts, advanced techniques like Chain-of-Thought and Reflection, and the principles behind building LLM-based agents. Finally, we provide a survey of tools for prompt engineers.

The paper "Prompt Design and Engineering: Introduction and Advanced Methods" introduces prompt engineering techniques for maximizing the potential of LLMs (LLMs). It covers core concepts, advanced techniques such as Chain-of-Thought (CoT) and Reflection, and the principles behind building LLM-based agents. The paper also surveys tools for prompt engineers.

The author defines a prompt as the textual input provided to guide a generative AI model's output, ranging from simple questions to detailed descriptions. Effective prompts consist of instructions, questions, input data, and examples. Basic prompts involve direct questions or instructions, while advanced prompts use complex structures like chain of thought.

The paper highlights the limitations of LLMs, including their transient state, probabilistic nature, reliance on outdated information, tendency to fabricate content (hallucination) \cite{hallucinationsXamat}, resource intensity, and domain specificity. It emphasizes the need for advanced prompt engineering to enhance LLM utility and mitigate these constraints.

The paper discusses a series of more advanced prompt design tips and tricks including:

  • Chain of thought prompting, where the model is guided to follow a series of reasoning steps [Wei2022COT].
  • Encouraging the model to be factual by citing sources.
  • Explicitly ending the prompt instructions using special tokens.
  • Using forceful language.
  • Using the AI to correct itself.
  • Generating different opinions by feeding an article and asking the model to disagree with it.
  • Keeping state and role playing to make the chatbot keep track of state from one prompt to the next.
  • Teaching an algorithm in the prompt using zero-shot learning. For instance, defining the parity of a list within the prompt [zhou2022teaching].
  • Considering the order of examples and instructions in the prompt [lu2022fantastically].
  • Using affordances, where functions are defined in the prompt and the model is instructed to use them when responding.

The paper also covers advanced techniques in prompt engineering:

  • Chain of Thought (CoT): This technique enhances reasoning by guiding the model through explicit, logical sequences [Wei2022COT]. There are two variants:
    • Zero-Shot CoT: The LLM is prompted to unravel the problem iteratively.
    • Manual CoT: Explicit, stepwise reasoning examples are provided as templates.
  • Tree of Thought (ToT): This method facilitates a multi-faceted exploration of problem-solving pathways [yao2023tree]. It involves "thought trees," where each branch embodies an alternative reasoning trajectory.
  • Tools, Connectors, and Skills: Tools are external functions or services that LLMs can utilize. Connectors act as interfaces between LLMs and external tools or services. Skills refer to specialized functions that an LLM can execute. Toolformer trains an LLM to decide what tool to use when and what parameters the API needs [schick2023toolformer].
  • Automatic Multi-step Reasoning and Tool-use (ART): This technique combines automated chain of thought prompting with the use of external tools [paranjape2023art].
  • Enhancing Reliability through Self-Consistency: This approach involves prompting the LLM to produce multiple answers to the same question, with the coherence among these responses serving as a gauge for their credibility [manakul2023selfcheckgpt].
  • Reflection: This involves the LLM engaging in an introspective review of its outputs [shinn2023reflexion], assessing its initial responses for factual accuracy, logical consistency, and overall relevance.
  • Expert Prompting: This represents a novel paradigm in augmenting the utility of LLMs by endowing them with the capability to simulate expert-level responses across diverse domains [zhang2023exploring]. A cornerstone of this approach is the multi-expert strategy, wherein the LLM is guided to consider and integrate insights from various expert perspectives.
  • Streamlining Complex Tasks with Chains: Chains represent a transformative approach in leveraging LLMs for complex, multi-step tasks. The development and optimization of Chains is explored in "PromptChainer: Chaining LLM Prompts through Visual Programming" [wu2022promptchainer].
  • Guiding LLM Outputs with Rails: Rails in advanced prompt engineering represent a strategic approach to directing the outputs of LLMs within predefined boundaries, ensuring their relevance, safety, and factual integrity. Topical Rails keep the LLM focused on a specified subject or domain. Fact-Checking Rails aim to reduce the propagation of inaccuracies. Jailbreaking Rails are established to deter the LLM from producing outputs that circumvent its operational constraints or ethical guidelines.
  • Streamlining Prompt Design with Automatic Prompt Engineering: Automatic Prompt Engineering (APE) automates the intricate process of prompt creation [zhou2023large].

The paper also discusses augmenting LLMs through external knowledge using Retrieval Augmented Generation (RAG). RAG extends LLMs by dynamically incorporating external knowledge, thereby enriching the model's responses with up-to-date or specialized information not contained within its initial training data. The paper highlights Forward-looking Active Retrieval Augmented Generation (FLARE) as one approach to iteratively enhance LLM outputs by predicting potential content and using these predictions to guide information retrieval [DBLP:journals/corr/abs-2005-11401].

The author goes on to introduce the concept of LLM Agents which are designed to perform complex tasks autonomously. LLM agents can access external tools and services, leveraging them to complete tasks, and making informed decisions based on contextual input and predefined goals. The paper covers prompt engineering techniques for agents, including Reasoning without Observation (ReWOO) [xu2023rewoo], Reason and Act (ReAct) [yao2023react], and Dialog-Enabled Resolving Agents (DERA) [nair2023dera].

Finally, the paper lists prompt engineering tools and frameworks including Langchain, Semantic Kernel, Guidance library, Nemo Guardrails, LlamaIndex, FastRAG, Auto-GPT, and AutoGen. These tools and frameworks are instrumental in the ongoing evolution of prompt engineering.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (21)
  1. Machine learning: The high interest credit card of technical debt. In SE4ML: Software Engineering for Machine Learning (NIPS 2014 Workshop), 2014.
  2. Chain-of-thought prompting elicits reasoning in large language models. In S. Koyejo, S. Mohamed, A. Agarwal, D. Belgrave, K. Cho, and A. Oh, editors, Advances in Neural Information Processing Systems, volume 35, pages 24824–24837. Curran Associates, Inc., 2022.
  3. Automatic chain of thought prompting in large language models, 2022.
  4. Tree of thoughts: Deliberate problem solving with large language models, 2023.
  5. Toolformer: Language models can teach themselves to use tools, 2023.
  6. Gorilla: Large language model connected with massive apis, 2023.
  7. Art: Automatic multi-step reasoning and tool-use for large language models, 2023.
  8. Selfcheckgpt: Zero-resource black-box hallucination detection for generative large language models, 2023.
  9. Reflexion: Language agents with verbal reinforcement learning, 2023.
  10. Exploring the mit mathematics and eecs curriculum using large language models, 2023.
  11. Promptchainer: Chaining large language model prompts through visual programming, 2022.
  12. Large language models are human-level prompt engineers, 2023.
  13. Retrieval-augmented generation for knowledge-intensive NLP tasks. CoRR, abs/2005.11401, 2020.
  14. Amazon Web Services. Question answering using retrieval augmented generation with foundation models in amazon sagemaker jumpstart, Year of publication, e.g., 2023. Accessed: Date of access, e.g., December 5, 2023.
  15. Unifying large language models and knowledge graphs: A roadmap. arXiv preprint arXiv:2306.08302, 2023.
  16. Active retrieval augmented generation, 2023.
  17. Retrieval-augmented generation for large language models: A survey. arXiv preprint arXiv:2312.10997, 2023.
  18. Hugginggpt: Solving ai tasks with chatgpt and its friends in huggingface. arXiv preprint arXiv:2303.17580, 2023.
  19. Rewoo: Decoupling reasoning from observations for efficient augmented language models, 2023.
  20. React: Synergizing reasoning and acting in language models, 2023.
  21. Dera: Enhancing large language model completions with dialog-enabled resolving agents, 2023.
User Edit Pencil Streamline Icon: https://streamlinehq.com
Authors (1)
  1. Xavier Amatriain (20 papers)
Citations (30)