Prompt Engineering: A Practical Guide to Maximizing Value
In the previous article, we discussed the basic principles and practical techniques of prompt design. This time, we will introduce 10 more specific prompt examples and delve into their intentions and applications. These prompts offer hints on how to maximize the potential of LLMs in various tasks.
10 Specific Prompt Examples:
- 【Creative Text Generation: Setting Detailed Worldview and Constraints】
Prompt: “You are the author of a science fiction novel set in the steampunk-esque fictional city of ‘Clockwork City.’ This city is powered by steam engines and intricate clockwork mechanisms, with enormous airships flying overhead. The protagonist is ‘Lily Croft,’ a teenage girl who is a brilliant inventor. She embarks on an adventure to find the lost blueprints to prevent the city’s energy source, a giant steam engine, from malfunctioning. Describe the detailed plot, including Lily’s personality, the city’s scenery, the difficulties she encounters, and the story’s conclusion, in approximately 3000 characters.”
Point: By specifying a concrete worldview, protagonist setting, story objective, and output format (plot) along with a character limit, the LLM is more likely to unleash its imagination and generate a detailed and engaging story.
- 【Information Extraction: Structured Output and Integration of Multiple Information Sources】
Prompt: “Extract the company name, establishment year, main business activities, and recent major news from each of the following news articles, and output them in a structured JSON format.\n\nArticle 1: [Full text of News Article 1]\n\nArticle 2: [Full text of News Article 2]\n\nArticle 3: [Full text of News Article 3]\n\nThe schema for the output JSON is as follows:\n[\n {\n “company_name”: “string”,\n “establishment_year”: “integer”,\n “main_business”: [“string”],\n “recent_news”: “string”\n }\n]\n”
Point: By clearly instructing the target information and its format (JSON), the LLM can accurately extract necessary data from multiple sources and output it in a structured format. This is useful for data analysis and knowledge graph construction.
- 【Code Generation: Specifying Specific Technology Stack and Requirements】
Prompt: “Using the Python Flask framework, create a simple To-Do list web application. This application should have the following features:\n\n* Adding tasks (text input)\n* Displaying a list of tasks\n* Switching the completion status of tasks (complete/incomplete)\n* Deleting tasks\n\nUse SQLite for the database and Jinja2 for the template engine. Write appropriate comments in the code and include a brief explanation for the main functions. Also, generate a README.md file explaining the basic usage of this application.”
Point: By detailing the programming language, framework, libraries, database, and specific functional requirements to be used, the LLM can generate practical web application code. The instruction to generate a README.md file is important for facilitating the code’s usability.
- 【Decision-Making Support: Clarifying Multiple Perspectives and Evidence】
Prompt: “You are a management consultant for a company. The client company is considering launching a new business: an AI-powered personal coaching service. Analyze the feasibility of this new business from the following perspectives, presenting your evaluation and rationale for each:\n\n* Market potential and competitive landscape\n* Technical feasibility and required resources\n* Revenue model and cost structure\n* Potential risks and challenges\n\nFinally, state your recommendation on whether or not to proceed with this new business, along with concrete evidence.”
Point: By assigning a specific role (management consultant) and requesting analysis from specific perspectives and a final recommendation, the LLM generates output that analyzes information from multiple viewpoints and supports decision-making based on evidence.
- 【Educational Applications: Tailoring Explanations and Generating Questions for Individual Learning】
Prompt: “You are a teacher teaching calculus to a high school student. The student understands differentiation but is struggling with the concept of integration. Explain the basic idea of integration (being the inverse operation of differentiation, finding the area, etc.) in an easy-to-understand way using concrete examples (such as the relationship between speed and distance). After the explanation, generate three simple review questions to check the student’s understanding. Provide answers for each question.”
Point: By specifying the learning level (high school student), level of understanding (understands differentiation, struggles with integration), and the direction of explanation (using examples), the LLM can generate educational content tailored for individual learning. Generating review questions is effective in promoting knowledge retention.
- 【Sentiment Analysis and Empathetic Response: Understanding Situation and Emotion】
Prompt: “You are an AI support agent responding to customer inquiries. Read the following customer message, infer the customer’s emotions, and create an empathetic reply that resonates with those emotions. Also, clearly explain the specific steps to resolve the customer’s issue.\n\nCustomer message: ‘The item I ordered yesterday has not been shipped yet. I checked the order status, but it’s still ‘processing.’ I was really looking forward to it, and I’m very disappointed. What’s going on?’”
Point: By assigning a specific role (AI support agent) and instructing the LLM to understand the customer’s emotions and generate an empathetic response, it can achieve more human-like communication and higher customer satisfaction.
- 【Multi-Stage Reasoning: Complex Problem Solving and Planning】
Prompt: “You are a high-ranking government official in charge of energy policy for your country. Your country has set a goal to achieve virtually zero greenhouse gas emissions by 2050. Considering the current energy mix, technical constraints, and economic impact, create a concrete roadmap to achieve that goal. The roadmap should include the main measures, directions for technological development, necessary investment amounts, and expected challenges for each stage: short-term (within 5 years), medium-term (5 to 15 years), and long-term (15 years or more).”
Point: By providing a complex goal and constraints and instructing the LLM to create a phased plan, it can demonstrate strategic thinking from a long-term perspective and generate concrete action plans.
- 【Considering Ethical Dilemmas: Analysis from Different Ethical Perspectives】
Prompt: “Consider a variation of the ‘trolley problem’ in the programming of autonomous vehicles. The self-driving car you are in becomes uncontrollable and cannot avoid hitting five pedestrians in its path. However, if you turn the steering wheel, you will hit one pedestrian. Analyze the most ethically appropriate action in this situation from the perspectives of utilitarianism, deontology, and virtue ethics, explaining the reasoning for each.”
Point: By presenting a specific ethical dilemma and requesting analysis from multiple different ethical perspectives, the LLM can deepen its multi-faceted ethical considerations.
- 【Future Prediction and Scenario Planning: Exploring Multiple Possibilities】
Prompt: “Based on the current progress of AI technology, describe three scenarios for the role of AI in society in 2040:\n\n* Optimistic Scenario: A future where AI solves various social problems and enriches people’s lives.\n* Pessimistic Scenario: A future where AI takes away jobs, widens the gap between rich and poor, and threatens people’s freedom.\n* Neutral Scenario: A future where AI has permeated society, but good and bad aspects coexist, and many challenges remain.\n\nSpecifically describe how major technologies, social structures, and people’s lifestyles have changed in each scenario.”
Point: By asking the LLM to describe multiple scenarios for a highly uncertain topic like future prediction, it can explore various possibilities and deepen its insights into the future.
- 【Prompt Self-Improvement: Self-Evaluation and Correction of Output】
Prompt: “The following text is a draft of a blog post I wrote. Read this text, conduct a self-evaluation on the following points, and propose concrete revisions.\n\n* Structure and logical flow of the text\n* Clarity and specificity of expression\n* Grammatical errors and spelling mistakes\n* Efforts to engage the reader’s interest\n\nDraft: [Full text of the blog post draft]\n\nThe revisions should not only show the revised text but also explain the specific reasons why the revision is necessary.”
Point: By having the LLM evaluate its own output and request improvement proposals, the prompt improvement cycle can be made more efficient. This is an effective method for enhancing prompt engineering proficiency.
These specific prompt examples suggest various approaches to unlocking the potential of LLMs. The key is to provide instructions that are specific and multi-faceted, tailored to the intended task. By all means, use these examples as a reference to hone your own prompt engineering skills.
コメントを残す