iTranslated by AI
Why LLMs Change Their Behavior When Told 'You Are an Expert in XX'
Highlights of This Article
Why does simply saying "You are an expert in XX" make the AI behave like one?
This question is what motivated me to start writing this article.
By understanding the principles behind prompt engineering, we can see why giving an AI a "persona" works.
Why does telling an AI "You are an expert in XX" enable it to adopt an expert tone and access relevant knowledge?
This is not magic—it is a natural phenomenon grounded in the training structure of Large Language Models (LLMs) and the mechanism of self-attention.
Understanding this principle goes beyond just "convenient usage"—it allows you to improve LLM output accuracy with a solid rationale.
Reference Paper
This article is based on the paper:
Prompt Engineering for Conversational AI Systems: A Systematic Review of Techniques and Applications
A systematic review of prompt engineering techniques and applications in conversational AI systems.
Paper Content
This paper proposes existing prompt engineering techniques and novel methods expected to improve performance.
By organizing these techniques and unraveling the principles of prompt engineering, we can deepen our understanding.
The article also includes concrete implementation examples, so feel free to use them as a reference.
Existing Prompt Engineering Techniques
The paper introduces four main existing techniques.
In practice, these methods are combined depending on the situation.
Role-Based Prompting
This is the core topic: instructing the AI with phrases like "You are an educator / financial analyst / investment expert."
It is an approach that structures interactions with the AI through a defined persona or behavioral framework.
This technique is particularly effective in educational contexts where the role (e.g., tutor, instructor) is clear. By assigning a specific role, you obtain responses that are consistent and aligned with the context.
■ Example in an educational context
You are a university mathematics professor.
Your role is to teach new employees the basics of matrices.
Please explain technical terms in plain language and use examples to make it easy to understand.
Contextual Framing
Contextual framing is a technique that embeds relevant background information and conditions into the prompt to appropriately guide the AI's response.
It helps the AI understand "what assumptions to use when answering in this situation," improving output accuracy and relevance.
■ Without contextual framing
Write code in Python
■ With contextual framing
You are a software engineer.
Write Python code to extract even numbers from a list, as if explaining to a new employee.
Add comments to make it easy to understand.
Parameter Optimization
While the methods above focus on crafting the content of the prompt, this technique is about adjusting the model's output characteristics.
Parameter optimization is a technique for adjusting the "temperature, diversity, and stability" of LLM output. The two main variables are temperature and top_p.
temperature literally means temperature; in LLMs, it is a parameter that smoothens the probability distribution of the output. In contrast, top_p retains only the set of words whose cumulative probability exceeds p from the top of the probability distribution, and then randomly selects from that set.
When creativity is desired, set high temperature / high top-p; when consistency is desired, set low temperature / low top-p. These can be configured when creating an API client.
# Example parameter settings
resp = client.chat.completions.create(
model="gpt-4o-mini", # Any model
messages=[
{"role": "system", "content": "You are a friendly engineering instructor."},
{"role": "user", "content": "Explain the difference between ECR and ECS for beginners."}
],
temperature=0.4, # ← Determinism (lower = more rigid)
top_p=0.8, # ← Breadth of candidates (higher = more diverse)
)
Few-Shot Learning
As the name implies, this is a technique for adapting a model to a new task using as few examples as possible. It provides input-output examples in the prompt and lets the model learn the pattern.
This is similar to contextual framing, but the difference is that contextual framing explains the background and situation, whereas this technique provides concrete examples to determine the direction of interpretation.
The key drivers of this technique are: the quality of the selected examples, the alignment between example complexity and task requirements, the appropriate number of examples based on task difficulty, and diversity with coverage of edge cases.
Since LLMs tend to prioritize recent information (the Recency effect), placing basic examples first and application-oriented examples later, with the examples closest to the actual task at the end, should stabilize accuracy.
■ Examples of typical and edge cases in email classification
Input: "Congratulations! You have won a $1000 gift card. Click here to claim your prize."
Output: Spam
- This is spam. A typical prize/clickbait-type email.
Input: "Hi, just checking in about our meeting tomorrow at 10am."
Output: Normal
- This is normal. A general business email.
Input: "Reminder: Your account security may be compromised. Please verify your identity immediately."
Output: Spam
- This is spam. Looks like a security notification, but it's phishing.
New Prompt Engineering Techniques
The techniques introduced above can improve performance but do not guarantee perfect answers. Additionally, crafting prompts requires effort, and complex prompts can be difficult to maintain.
To address these challenges, the following three representative methods are currently being researched.
Multimodal Prompt Learning
This is a prompt design that combines multiple modalities—text, images, audio, video, etc. It optimizes alignment across different modalities to enable richer input and output.
Have you ever taken a screenshot of an entire error screen while programming and asked ChatGPT, "What do you think is wrong?" That method is exactly what researchers are studying to improve accuracy.
A more specialized practical example could be in medical settings.
Input: Patient chest X-ray image + "This patient has symptoms of cough and fever. Explain possible diagnoses."
Output: "The image shows a shadow in the lung, and based on the context, pneumonia is suspected. I recommend a blood test as an additional examination."
Automated Prompt Generation
Instead of humans manually crafting prompts each time, this mechanism lets the AI itself generate and refine optimal prompts for the task. By combining it with agents and optimization algorithms, high accuracy can be achieved with less human intervention.
I previously read about a system where AI agents generate other AI agents—that's an application of this technology.
It decomposes the knowledge needed for a task, and if it determines that no existing agent possesses that knowledge, it generates and adds a new agent prompt to create a new specialist. For more details, see:
Educational Implications
This refers to a system that systematically teaches prompt design and helps it become a lasting skill. It encourages people to properly learn about "prompt engineering" so that even users without specialized knowledge can handle appropriate prompts through standard frameworks.
Traditionally, prompt engineering—being a relatively new technical area—has often been left to individual discretion. By sharing correct knowledge properly, it is expected that anyone can achieve high-quality prompt engineering.
I would be happy if this article itself contributes to educational implications.
Principles of Prompt Engineering
The answer to the title of this article lies in this chapter.
The reason prompt engineering improves answer accuracy seems to be rooted in the very nature of LLMs.
Principle 1: The Effect of Instruction Tuning
Instruction Tuning refers to additional training that makes a model follow user queries and instructions. LLMs like ChatGPT undergo instruction tuning (also called instruction fine-tuning), so they obediently follow our instructions, i.e., the prompt engineering we apply.
Principle 2: Guiding the Output Probability Distribution
LLMs learn the "probability distribution of the next word" from vast corpora. The prompt acts as a "conditional statement," shifting the probability in a specific direction.
For example, when told "Write code in Python," the probability of words like print or def increases. When told "Write code in C language," the probability of words like printf or int func(void){...} increases.
Principle 3: Using the Context Reference Method
LLMs refer to the "most recent context (prompt + conversation history)." Few-shot learning and contextual framing leverage this window mechanism to make the model "mimic prior knowledge."
Combined with Principle 4 below, the fact that instructions are often input as system prompts at the very beginning—and thus the instructed content tends to be retained—also seems to have an effect.
Principle 4: Self-Attention Bias
The Transformer, the foundation of existing LLMs, learns which tokens to emphasize via its self-attention mechanism. In doing so, it learns a bias that "important information is often at the beginning and end" in the training data. This generally leads to a tendency for the beginning and end to be emphasized (primacy/recency bias).
This makes sense when we look at business frameworks like the PREP method or our own everyday writing—conclusions often appear at the beginning and end.
These are the reasons why prompt engineering is effective and why the model behaves like the expert we instruct it to be.
Looking at these, it seems that prompt engineering does not fundamentally alter the model. The reason it works is that we understand the naturally occurring quirks and biases in the learning process, and we skillfully exploit them.
When performing prompt engineering, the following points need to be noted:
-
Lack of Reproducibility
- Slight changes in wording can cause output variation.
- Long prompts or complex instructions may be "forgotten."
-
Cannot Transcend Limitations
- Knowledge or abilities not present in the training data cannot be invoked.
- Thinking "you can do anything with clever prompting" leads to wasted effort.
-
Risk of Over-Reliance
- Trying to achieve stable quality through prompts alone requires constant adjustment, increasing costs.
- Neglecting fundamental improvements (e.g., data enrichment, model selection, evaluation frameworks).
It is essential to understand the limitations of prompt engineering while using it as a means to achieve maximum results with minimal effort.
What Value Does the Paper's Content Generate?
This paper provides insights into the importance of prompt engineering through technical explanations of existing techniques and introductions to new methods.
By considering prompt engineering, let's think about its impact on the world in the short and long term.
First, in the short term, being proficient in prompt engineering itself holds value. Or rather, I believe it already holds value.
There are many job postings for prompt engineers, and salaries are high, around 4.5 to 6 million yen.
Since prompt engineering is recognized as a technical skill, understanding its principles and being able to apply it are assets.
However, it would be risky to try to master prompt engineering completely. In the long term, prompt engineering itself is likely to lose value.
The main reason it currently holds value is the high scarcity of the skill—demand exceeds supply.
As this article shows, prompt engineering is easy to learn; once you learn the methods, you can quickly craft effective prompts.
Thus, I predict that, similar to PowerPoint or Excel skills, it will become a nice-to-have skill that anyone with any background can acquire—useful to have, but not rare.
For engineers who interact with LLMs daily, it will become something taken for granted. Therefore, we need to consciously use it daily and internalize it.
Reflections
Although I have some knowledge of the attention mechanism, I realized I have never read the famous paper that introduced it.
Next, I plan to delve into the principles of Attention, which played a key role in the rapid advancement of LLMs.
Discussion