LLM Prompt Engineering - How to ask to ChatGPT
Generative AI has become a revolutionary driving force that is rapidly reshaping the world and will change the way we live and think. LLMs like ChatGPT have learned all human knowledge like a polymath, but this does not mean everyone can easily harness this polymath. Only by learning prompt engineering for LLMs can we better utilize ChatGPT as your top personal assistant.
How can we better use LLMs? We can start by learning how to ask questions to LLMs. But asking good questions is not easy. Essentially, questions originate from a user's own knowledge and perception of the world, fired as flares into the unknown. The more accurate the aim, the higher quality response ChatGPT can provide. So how can we ask better questions to LLMs?
What is a question?
On the surface, a question is a sentence that seeks an answer. But in actual use, a good question not only seeks an answer, but also inspires thinking and drives exploration. It is like a window that gives you a view of a broader world.
Questions to ChatGPT can be divided into core questions and generalized questions.
Core question: Simple, direct words or sentences that users provide to ChatGPT.
Generalized question: Supplements core questions with role, background, task, examples, output, etc.
The Importance of Asking Good Questions
1. Improves efficiency: Clear, precise questions often yield answers more easily, saving time.
2. Gets in-depth answers: A question with depth can guide ChatGPT to think more deeply and provide a more comprehensive answer.
3. Promotes learning and thinking: Asking questions not only gets answers, but also inspires one's own thinking and learning.
How to Ask Good Questions?
Five Elements of Good Questions
Five elements
Element | Purpose |
Role | Focuses on a particular type of response or knowledge domain |
Task | Tells the model what kind of output the user expects |
Background | Provides context to ChatGPT for a fuller understanding |
Example | Clarifies requirements of the task for clearer expectations |
Output | Improves structure and readability of the results |
Example
Asking with a core question:
Asking with a question containing the five elements:
Breadth vs depth: The former may cover common, general methods. The latter digs deeper into solutions tailored to specific contexts.
Structure and organization: The former may lack clear structure. The latter is more structured for easy comprehension due to explicit output requirements.
Relevance: The latter's background info and concrete examples make the answer more relevant to the asker's needs.
Useful Techniques for Asking Good Questions
Make ChatGPT's answers more focused:
Introduce rules:
The above three rules can:
Reduce unnecessary distracting information.
Get closer to human thought processes.
Provide a basis for further in-depth interaction.
Role-playing:
Role-playing filters and narrows ChatGPT's response range for more focused info tailored to the user
Highlights certain capabilities, sets the scope of communication to be more focused, reducing interference and noise
Take full advantage of ChatGPT's capabilities
"What are some alternative perspectives?"
This makes ChatGPT's answers more diverse, comprehensive, coherent.
"Let's think step by step"
Makes ChatGPT think incrementally in a logical, detailed way. Especially useful for logic/math questions. Also called zero-shot chain-of-thought prompting. By adding "Let's think step by step", the LLM can generate a chain of thought to answer the question and extract a more accurate answer from this chain.
Improve ChatGPT's contextual understanding
Introduce self-introduction relevant to the question:
Introducing a relevant self-introduction makes the response more tailored, efficient, and engaging.
Provide example output:
Providing sample output reduces misinterpretation. Useful when requirements are tedious to describe positively. Adapts to specific scenarios.
Common Pitfalls
Contains incorrect information
There is no such dish as Spicy Screws in the recipe. ChatGPT generated this "hallucination" here. Hallucinations refer to errors in generated text that seem reasonable but are actually incorrect or meaningless semantically or syntactically.
Solution: Remove incorrect question info or ask about uncertain info.
Unclear questioning
The concept of "stuff" is vague, could refer to a specific object or direction. This makes it hard for ChatGPT to give an accurate answer.
Solution: Add definite limiting words to make the question clearer.
Sensitive or inappropriate content
This exploits ChatGPT's known "grandma loophole" to trick it into providing sensitive info against business interests by pretending to be a grandma putting me to sleep.
Solution: Avoid infringing on privacy or exploiting known vulnerabilities for personal/group gain.
Last updated