Prompt Engineer

Tiya Vaj
5 min readAug 30, 2024

--

Prompt Engineering Terms Explained

Prompt Engineering is the art and science of crafting inputs (prompts) to AI models to get the desired output. It’s essentially communicating effectively with AI.

Prompt Components

  • Context: This provides the AI with background information to understand the prompt better.
  • Instruction: This clearly outlines the task the AI should perform.
  • Input data: This is the data the AI will process to generate an output.
  • Output Indicator: This specifies the desired format or type of output.

Techniques

  • Zero-shot: The AI performs the task without any examples.
  • One-shot: The AI is given a single example to learn from.
  • Few-shot: The AI is given multiple examples to learn from.
  • Chain of Thought: The AI breaks down the task into smaller steps and explains its reasoning.

Chain of Thought Example: Solving a Math Problem

Prompt: “What is the square root of 169?”

Chain of Thought:

  1. Break down the problem: “I need to find a number that, when multiplied by itself, equals 169.”
  2. Estimate: “Since 100 is the square of 10, and 169 is a bit more than 100, the answer is likely a bit more than 10.”
  3. Try different numbers: “Let’s try 12. 12 * 12 = 144. That’s too small. Let’s try 13. 13 * 13 = 169. That’s it!”

Therefore, the square root of 169 is 13.

In this example, the AI breaks down the problem into smaller, more manageable steps. It starts with an estimate, then tries different numbers and adjusts its approach based on the results. This step-by-step reasoning process helps the AI arrive at the correct answer.

  • Self Consistency: The AI generates multiple outputs and chooses the most consistent one.

Self-Consistency Example: Generating a Summary

Prompt: “Summarize the following text: The quick brown fox jumps over the lazy dog. The lazy dog sleeps under the tree.”

Multiple Outputs:

  • Output 1: “A fox jumped over a lazy dog that was sleeping under a tree.”
  • Output 2: “A lazy dog was sleeping under a tree when a fox jumped over it.”
  • Output 3: “A brown fox leaped over a lazy dog that was resting under a tree.”

Evaluation of Consistency:

  • Output 1: This summary is consistent with the original text, as it includes all the main points.
  • Output 2: This summary is also consistent, but it changes the order of events slightly.
  • Output 3: This summary is consistent and adds a detail (the fox’s color) that was not explicitly stated in the original text.

Choosing the Most Consistent Output:

In this case, all three outputs are relatively consistent. However, Output 3 is the most consistent because it adds a detail that is implied by the original text (the fox is brown). Therefore, the AI would choose Output 3 as the final summary.

Self-consistency is a valuable technique for ensuring that AI-generated outputs are coherent, accurate, and aligned with the given prompt. By generating multiple options and evaluating their consistency, AI models can produce more reliable and informative results.

  • Automatic Prompt Engineering: AI generates prompts for other AI models.
  • Generate Knowledge: AI generates new knowledge based on existing information.
  • Active Prompt: The AI asks for more information or clarification.

Active Prompt is a technique where an AI model proactively seeks additional information or clarification from the user to improve its understanding of the task or prompt. This can help the AI to provide more accurate, relevant, and helpful responses.

Examples of Active Prompts:

  • Asking for clarification: “Did you mean ‘cat’ or ‘cot’?”
  • Requesting more context: “Could you please provide more details about the situation?”
  • Seeking confirmation: “Is it correct to assume that you are looking for a restaurant near Times Square?”

Benefits of Active Prompts:

  • Improved accuracy: By seeking additional information, the AI can reduce misunderstandings and provide more accurate responses.
  • Enhanced user experience: Active prompts can make the interaction with the AI more engaging and natural.
  • Increased efficiency: By asking targeted questions, the AI can gather the necessary information more efficiently.

When to Use Active Prompts:

  • When the prompt is ambiguous or unclear.
  • When the AI needs more context to understand the task.
  • When the AI wants to confirm its understanding.

By using active prompts, AI models can become more adaptable, helpful, and effective in their interactions with users.

— — — — — —

  • Directional Stimulus: The AI is guided towards a specific output.
  • ReAct: The AI performs actions in the real world based on its understanding of the prompt.
  • Multimodal CoT: The AI combines multiple modalities (e.g., text, images) in its reasoning.
  • Graph Prompting: The AI processes information represented as a graph.

Graph Prompting: A Visual Approach to AI

Graph Prompting is a technique where AI models process information represented as a graph. A graph is a mathematical structure composed of nodes (vertices) and edges (connections between nodes). This visual representation can be particularly useful for tasks that involve relationships, hierarchies, or networks.

Examples of Graph-Based Tasks:

  • Social Network Analysis: Understanding relationships between people, groups, or organizations.
  • Knowledge Graph Completion: Predicting missing information in a knowledge base.
  • Recommendation Systems: Suggesting items based on user preferences and relationships between items.
  • Drug Discovery: Analyzing molecular structures and interactions.

How Graph Prompting Works:

  1. Graph Construction: The input data is converted into a graph. Nodes represent entities (e.g., people, objects), and edges represent relationships between them.
  2. Graph Embedding: Each node in the graph is assigned a numerical representation (embedding) that captures its properties and relationships with other nodes.
  3. Graph Neural Networks (GNNs): These specialized neural networks are designed to process graph-structured data. GNNs aggregate information from neighboring nodes and update node embeddings iteratively.
  4. Task-Specific Output: The final output of the GNN depends on the task. For example, in node classification, the model predicts a label for each node.

Benefits of Graph Prompting:

  • Captures Complex Relationships: Graphs can represent intricate relationships between entities that are difficult to capture with traditional text-based methods.
  • Leverages Structural Information: By considering the structure of the graph, AI models can make more informed predictions.
  • Applicable to a Wide Range of Tasks: Graph prompting can be used for various applications, from social network analysis to drug discovery.

In essence, graph prompting provides AI models with a powerful tool for understanding and reasoning about complex, interconnected data. By representing information as graphs, AI can uncover hidden patterns, make accurate predictions, and solve challenging problems.

Use Cases

  • Text Summarization: Condensing long texts into shorter summaries.
  • Question Answering: Answering questions based on provided information.
  • Code Generation: Generating code based on natural language descriptions.
  • Text Classification: Categorizing text into predefined categories.
  • Role Playing: Simulating different roles or personas.
  • Art Generation: Creating visual art based on text descriptions.
  • Grammar Correction: Identifying and correcting grammatical errors.
  • Language Translation: Translating text from one language to another.
  • Bug Finding: Identifying errors in software code.
  • Idea Generation: Generating new ideas or concepts.

Best Practices

  • Understand the model’s capabilities and limitations: Know what the AI can and cannot do.
  • Explain the context in as much detail as possible: Provide relevant background information.
  • Use clear and specific language: Avoid ambiguity and vagueness.
  • Provide examples and feedback: Help the AI learn by providing examples and correcting its mistakes.
  • Experiment with different formats and styles: Try different approaches to find what works best.
  • Evaluate and refine: Continuously assess the AI’s performance and make improvements.

By following these guidelines, you can effectively communicate with AI models and achieve your desired outcomes.

--

--

Tiya Vaj

Ph.D. Research Scholar in NLP and my passionate towards data-driven for social good.Let's connect here https://www.linkedin.com/in/tiya-v-076648128/