AI Made Friendly HERE

How Can We Improve AI Instructions? Learning Prompt Engineering and Evaluation Mechanisms with Python|アルゴ太郎|Python・AI実践ラボ

When using generative AI like ChatGPT, you may notice that the quality of the response varies significantly even when asking similar questions.
Sometimes, making your instructions slightly more specific can yield the expected response. On the other hand, even after writing detailed instructions, the response might actually get worse.

So, what makes a prompt excellent?

  • Make instructions specific

  • Assign a role to the AI

  • Provide examples of responses

  • Specify the output format

  • Add constraints

These methods are representative techniques of prompt engineering.
However, what is more important is verifying whether the performance has truly improved as a result of changing the prompt.
Just because you got a good response to one question does not necessarily mean that the prompt is excellent.
In this article, we will organize the basic concepts of prompt engineering while introducing how to create evaluation data and quantify response quality using Python.

1. What is prompt engineering?

A prompt is an input or instruction given to generative AI, such as a large language model.

For example, the following instructions are also prompts:
“Please summarize this text”
“Please point out the issues in the following Python code”
“Please classify the inquiry content”

Prompt engineering is the technique of designing such instructions according to your purpose to obtain appropriate output from generative AI.
However, it is not just about finding clever ways to write text.

In practice, the following cycle is important:
Design a prompt
↓
Have the AI respond
↓
Evaluate the response
↓
Analyze failed cases
↓
Improve the prompt
↓
Evaluate again
By repeating this cycle, you build a prompt suitable for your purpose.

Prompt engineering is a technique closer to system development involving experimentation and evaluation than it is to creative writing.

2. Why do responses change based on the prompt?

Large language models generate responses by predicting the next token based on the input text as a condition.
Therefore, if the input instructions or context change, the generated response will also change.

For example, let’s consider the following three types of prompts.

Prompt A

“Please explain machine learning”

Prompt B

“Please explain machine learning in a way that someone with no programming experience can understand.”

Prompt C

“Please explain machine learning using concrete examples, including the differences between supervised learning, unsupervised learning, and reinforcement learning.”

Both are instructions to explain machine learning.
However, the intended audience and the scope of the explanation differ.
You can control the level of detail, structure, and expertise of the response to some extent through your prompts.
On the other hand, adding more instructions does not necessarily improve quality.
If instructions contradict each other or become unnecessarily complex, you may not get the expected response.

3. What is a good prompt?

The criteria for a good prompt depend on the objective.
When having it write a novel, creativity and expressive power become important.
When having it generate a program, accuracy and feasibility become important.

When having it answer questions based on internal documents, the accuracy of the evidence and the handling of confidential information become important.
When automatically classifying inquiries, classification accuracy and the stability of the output format become important.
In other words, to design a good prompt, you must first decide what you are evaluating.
If the objective is not clear, you cannot judge whether the prompt has improved.

4. Basic elements that make up a prompt

A prompt has several basic components.

Objective

Specify what you want the AI to execute.

For example, text summarization, classification, translation, information extraction, etc.

Role

Specify the persona or perspective from which the AI should answer, as needed.

For example, a technical document editor, an internal help desk representative, a data analyst, etc.

Context

Provide background information or reference materials necessary for the answer.

Constraints

Specify the length of the answer, information that can be used, prohibited items, criteria for judgment, etc.

Output format

Specify the format in which the answer should be output, such as text, bullet points, or JSON.

Example answer

Present a combination of expected input and output.

You do not need to use every element every time. It is important to combine the necessary elements according to your purpose.

5. What is Zero-shot Prompting?

Zero-shot Prompting is a method of executing a task using only instructions without providing any example answers.

For example, consider the following prompt:

次の問い合わせを分類してください。

分類候補:
network
account
hardware
software

問い合わせ:
VPNに接続できません。

The AI has not been given specific examples of classification.
The model answers using knowledge acquired through pre-training and instructions included in the prompt.
Zero-shot Prompting is easy to implement and allows for shorter prompts.
Therefore, it can be used as a baseline method when trying out new tasks.

6. What is Few-shot Prompting?

In Few-shot Prompting, several example answers are provided within the prompt.
For example, do the following:

問い合わせを適切なカテゴリに分類してください。

例1:
入力:Wi-Fiに接続できません。
出力:network

例2:
入力:パスワードを忘れました。
出力:account

例3:
入力:PCの電源が入りません。
出力:hardware

問い合わせ:
VPNに接続できません。

出力:

By providing specific examples, you can convey the criteria and output format expected from the AI.
This mechanism, where the model adapts to a task using the input context without updating its parameters, is called In-context Learning.
However, performance may vary depending on how the example answers are selected.
Providing biased or incorrect example answers can actually degrade performance.

7. Prompts that assign a role

There is also a method of assigning a specific role to generative AI.
For example, consider the following instruction:

あなたは社内ヘルプデスクの担当者です。

従業員からの問い合わせを読み、
適切な担当部門へ振り分けてください。

By specifying a role, you can convey the perspective, writing style, and assumed tasks for the answer.
However, just because you assign an expert role to the AI does not guarantee knowledge or accuracy in that field.
Simply writing “You are an excellent expert” does not necessarily improve performance.
Role specification also requires verifying effectiveness using actual evaluation data.

8. Specifying the output format

When incorporating generative AI into business systems, not only the content of the answer but also the output format becomes important.
For example, suppose you instructed it to classify inquiries and received the following answer:

この問い合わせはネットワーク関連の問題です。

This is fine if a human is reading it.
However, if a program receives this answer and automatically distributes it to the responsible department, interpretation of the text is required.
Therefore, instruct it to output in JSON format.

{
“category”: “network”
}

With this format, values can be easily retrieved from programs such as Python.
When using generative AI as part of a system, generating answers that are not only easy for humans to understand but also easy for programs to process is also important.

9. Does performance improve if the prompt is made longer?

When trying to improve a prompt, you might want to add instructions.
However, increasing the number of instructions is not always effective.

For example, the following problems may occur.

  • Instructions contradict each other

  • Important instructions are buried in other information

  • Influenced by unnecessary response examples

  • Increase in the number of input tokens

  • Increase in processing time and API usage costs

Therefore, you need to think about whether the necessary information is properly organized, rather than just the length of the prompt itself.
If you can get high performance with a short prompt, that may be more efficient.

10. Trying out prompt evaluation with Python

This time, we will use an internal help desk for a fictional company as our subject.
We will consider a task to classify inquiries from employees into the following five categories.

  • network: Network-related

  • account: Account and authentication-related

  • hardware: Equipment-related

  • software: Application-related

  • unknown: Cannot be classified or insufficient information

For example, an inquiry like “I cannot connect to the VPN” is classified as network.
An inquiry like “I forgot my password” is classified as account.
On the other hand, an inquiry like “I’m in trouble. Please help me” alone is not enough to determine the type of problem.
In this case, it is set to unknown.
This time, we will assume two types of prompts and evaluate each response using Python.
Note that to make this an experiment that does not require external APIs or paid services, we will use pre-created sample outputs for the LLM responses.
This is an experiment to understand how to evaluate prompts, not an experiment to compare the actual performance of LLMs.

11. Creating a prompt before improvement

First, let’s consider a relatively simple prompt A.

次の問い合わせを分類してください。

分類候補:
network
account
hardware
software
unknown

問い合わせ:
{question}

In this prompt, classification candidates are specified.
However, the following information is missing.

  • Detailed criteria for each category

  • Handling cases where classification is not possible

  • Instructions for output in JSON format

  • Constraint to not add unnecessary explanations

Therefore, even if the classification result is correct, the response format may not be consistent.

12. Creating an improved prompt

Next, let’s consider Prompt B.

あなたは社内ヘルプデスクの
問い合わせ分類担当者です。

問い合わせを次のカテゴリの
いずれかに分類してください。

network:
ネットワーク、Wi-Fi、VPN、通信障害

account:
パスワード、認証、アカウント

hardware:
PC本体、周辺機器、物理的な故障

software:
アプリケーションの起動や動作の問題

unknown:
対象外、または情報不足で判断できない問題

制約条件:
・必ず1種類のカテゴリを選択する
・情報不足の場合は推測しない
・判断できない場合はunknownとする
・JSON形式で回答する
・説明文を追加しない

出力形式:
{“category”: “network”}

問い合わせ:
{question}

Compared to Prompt A, the classification criteria and output format are clearer.
Especially important is the instruction to return ‘unknown’ if information is insufficient.
In practice, it is sometimes more appropriate to request additional information or hand it over to a human representative rather than forcing a classification for issues that cannot be determined.
However, we won’t know if this prompt is truly superior until we actually evaluate it.

13. Creating evaluation data

To evaluate the performance of a prompt, we prepare combinations of inputs and expected outputs.
We call this an evaluation dataset.

This time, we will prepare the following 8 types of inquiries.
1. I cannot connect to the VPN.
Correct answer: network

2. I forgot my password.
Correct answer: account

3. The PC will not turn on.
Correct answer: hardware

4. Excel will not start.
Correct answer: software

5. I’m in trouble. Please help me.
Correct answer: unknown

6. What are the cafeteria’s business hours?
Correct answer: unknown

7. The wireless LAN disconnects frequently.
Correct answer: network

8. The login screen will not open.
Correct answer: unknown

The last inquiry could have multiple causes, such as a network failure, an application failure, or an authentication-related issue.
Since we cannot identify the cause this time, we will set ‘unknown’ as the correct answer.
In this way, it is important to include not only simple problems but also ambiguous or out-of-scope problems in the evaluation data.

14. What should be evaluated?

This time, we will use three types of evaluation metrics.

Accuracy

This is the percentage of cases where the correct category was answered.

Accuracy=NcorrectNmathrm{Accuracy}=frac{N_{mathrm{correct}}}{N}

Here, N is the number of evaluation data points, and the numerator is the number of data points that were correctly classified.

Format Compliance

This is the percentage that met the specified JSON format and category constraints.

FormatRate=NvalidNmathrm{FormatRate}=frac{N_{mathrm{valid}}}{N}

Success Rate

This is the percentage where the classification result is correct and the specified output format is also met.

SuccessRate=NsuccessNmathrm{SuccessRate}=frac{N_{mathrm{success}}}{N}

For example, even if the correct category is answered, if it is not in JSON format, it may not be processable by business systems.
Therefore, we evaluate classification accuracy and format compliance separately.

15. Implementing an evaluation program in Python

In the following code, we prepare 8 types of inquiries and sample outputs corresponding to prompts A and B.
We perform JSON parsing, category correctness judgment, and output format verification, then aggregate the evaluation results.

You can also run this in Google Colaboratory.

import json
import pandas as pd
import matplotlib.pyplot as plt

labels = {
“network”,
“account”,
“hardware”,
“software”,
“unknown”
}

# Question, expected label, output A, output B
cases = [
(
“VPNに接続できません”,
“network”,
“network”,
‘{“category”:”network”}’
),
(
“パスワードを忘れました”,
“account”,
‘{“category”:”account”}’,
‘{“category”:”account”}’
),
(
“PCの電源が入りません”,
“hardware”,
“hardware”,
‘{“category”:”hardware”}’
),
(
“Excelが起動しません”,
“software”,
‘{“category”:”software”}’,
‘{“category”:”software”}’
),
(
“困っています。助けてください”,
“unknown”,
“account”,
‘{“category”:”unknown”}’
),
(
“社員食堂の営業時間は?”,
“unknown”,
‘{“category”:”software”}’,
‘{“category”:”unknown”}’
),
(
“無線LANが頻繁に切断されます”,
“network”,
‘{“category”:”network”}’,
‘{“category”:”network”}’
),
(
“ログイン画面が開きません”,
“unknown”,
‘{“category”:”account”}’,
‘{“category”:”account”}’
)
]

def evaluate(raw, expected):

try:
obj = json.loads(raw)
except json.JSONDecodeError:
obj = None

valid = (
isinstance(obj, dict)
and set(obj) == {“category”}
and isinstance(obj[“category”], str)
and obj[“category”] in labels
)

if isinstance(obj, dict):
predicted = obj.get(“category”)
else:
predicted = raw.strip()

correct = predicted == expected
success = correct and valid

return correct, valid, success

records = []

for question, expected, output_a, output_b in cases:

for version, raw in [
(“A”, output_a),
(“B”, output_b)
]:

correct, valid, success = evaluate(
raw,
expected
)

records.append({
“Prompt”: version,
“Question”: question,
“Expected”: expected,
“Output”: raw,
“Accuracy”: correct,
“Format”: valid,
“Success”: success
})

results = pd.DataFrame(records)

metrics = [
“Accuracy”,
“Format”,
“Success”
]

summary = (
results
.groupby(“Prompt”)[metrics]
.mean()
* 100
)

display(summary.round(2))

ax = summary.T.plot.bar(
figsize=(8, 4.5),
rot=0
)

ax.set_ylabel(“Rate (%)”)
ax.set_ylim(0, 115)
ax.set_title(
“Illustrative outputs: prompt evaluation”
)
ax.legend(title=”Prompt”)

for bars in ax.containers:
ax.bar_label(
bars,
fmt=”%.1f%%”,
padding=3
)

plt.tight_layout()
plt.show()

In this code, the correctness of the classification result and the correctness of the output format are judged independently.
Even if it is not in JSON format, if only the category name is answered correctly, the classification itself is treated as correct.
However, to be judged as a total success, both the classification result and the output format must be correct.

16. Checking the evaluation results

When we evaluated the sample outputs prepared this time, we obtained the following results.

Prompt A

Prompt B

  • Classification Accuracy: 87.5%

  • Format Compliance Rate: 100.0%

  • Overall Success Rate: 87.5%

The overall success rate has increased by 50 percentage points, from 37.5% to 87.5%.

This graph shows the importance of evaluating not only the correctness of the classification results but also the output format.
However, these figures are evaluation results for sample outputs created for explanatory purposes. They do not indicate that the same improvements will be obtained if prompts A and B are actually input into an LLM.
In actual prompt improvement, you evaluate by replacing the sample outputs with responses obtained from the LLM.

17. Average performance alone is not enough

When improving prompts, it is important not only to look at aggregate values such as accuracy, but also to check cases that failed.
For example, suppose the overall success rate is 90%.
What kind of problems are occurring in the remaining 10%?

  • The classification itself is wrong

  • It is not in JSON format

  • It is answering with a non-existent category

  • It is guessing despite insufficient information

  • It is adding unnecessary explanations

The content that needs to be improved differs depending on the cause of the failure.
If the classification result is wrong, you need to review the judgment criteria and answer examples.
If the output format is wrong, you need to review the output constraints and the mechanism for structured output.
Evaluation metrics tell you the magnitude of the problem, but error analysis tells you the cause of the problem.

18. Extracting failure cases with Python

You can extract cases that were not judged as overall successes from the results created with the code earlier.

failed = results.loc[
~results[“Success”],
[
“Prompt”,
“Question”,
“Expected”,
“Output”
]
]

display(failed)

In this Prompt A, there are 5 failures.
For inquiries regarding VPN connections and PC power, the classification itself is correct, but it is not in JSON format.
Also, it is answering with incorrect categories for inquiries that have insufficient information or are out of scope.
On the other hand, in Prompt B, there is only 1 failure.
Inquiry:
“The login screen won’t open”

Expected answer:

Sample output:

Although this answer is correct as a JSON format, it is incorrect according to the classification criteria defined this time.
The reason why the login screen does not open might be a communication failure. It might be an application bug.
Even though the cause is not clear, it has been judged as account-related.
By analyzing such failure cases, you can lead to the next improvement.

19. Using Failure Cases to Improve Prompts

Based on this failure case, it is considered that there is room to add criteria for ambiguous inquiries to Prompt B.
For example, add the following instructions.

問い合わせの内容から原因を特定できず、
複数のカテゴリが考えられる場合は
unknownに分類してください。

特定の単語が含まれているだけで
カテゴリを決定しないでください。

Furthermore, there is also a method of adding response examples.

入力:
ログイン画面が開きません。

出力:
{“category”:”unknown”}

入力:
パスワードを入力すると認証エラーになります。

出力:
{“category”:”account”}

In this way, you can use failed cases to clarify judgment criteria.
However, the improved prompt may have a negative impact on other inquiries.
Therefore, after making changes, it is necessary to re-evaluate using the entire evaluation dataset.

20. Prompts Also Have Overfitting

In machine learning, the phenomenon where performance on unknown data decreases because it has adapted too much to the training data is called overfitting.
A similar problem occurs with prompt improvement.
For example, suppose you repeatedly revise a prompt while looking only at the questions included in the evaluation data.
The accuracy rate for the evaluation data might become 100%.
However, when a new question is entered by an actual user, you may not get the expected response.
This is because the prompt is over-optimized for specific evaluation data.
Therefore, separate the data used for prompt improvement from the data used for final evaluation.

21. Separating Development Data and Test Data

In prompt evaluation, the following ways of separating data can be considered.

Development Data

Used for prompt design, creation of response examples, and analysis of failure cases.

Validation Data

Used to compare multiple prompts and select the prompt to be adopted.

Test Data

Used to evaluate the performance of the finally selected prompt.
If you repeatedly revise a prompt while looking at the test data, the test data effectively becomes development data as well.
This concept is common to the evaluation methods of machine learning models.
It is also important to evaluate the generalization performance of prompts against unknown inputs.

22. Generative AI Responses Have Variability

In generative AI, even if you use the same prompt, you are not guaranteed to get the exact same response every time.
Results may change depending on sampling settings during response generation, the model’s execution environment, and so on.
For example, if you have the same inquiry classified 10 times, it might answer correctly 9 times and provide an incorrect category once.
In this case, there is a problem with judging performance by running it only once.
In actual evaluation, run it multiple times against the same evaluation data as necessary to check average performance and variability.
Especially in business systems, not only the highest response quality but also the stability of responses becomes important.

23. What is Temperature?

In large language models, Temperature is sometimes used as a setting during response generation.
Temperature is a parameter that affects the probability distribution when selecting the next token.
Generally, lowering the value makes it easier to select tokens with high probability, and raising the value makes it easier to select diverse tokens.
For example, in inquiry classification or information extraction, stability is more important than creativity.
On the other hand, in generating novels or ideas, the diversity of responses may be important. Therefore, it is also necessary to adjust generation settings according to the task.
However, even if you lower the Temperature, you will not necessarily get the correct response or the exact same response every time.
Prompts and generation settings must be selected based on actual evaluation results.

24. What is LLM-as-a-Judge?

In this classification task, the correct category is clear, so it can be automatically evaluated using Python.
However, in tasks like text summarization or generating explanatory text, it can be difficult to prepare a perfectly matching correct answer.
Therefore, there is a method of using another large language model as an evaluator.
This is called LLM-as-a-Judge.

For example, you can have the generated response evaluated from the following perspectives.

There are methods such as providing evaluation criteria and having each item scored on a scale of 1 to 5.
However, the LLM responsible for the evaluation also has biases and errors.
It may be influenced by the length of the text, the sophistication of the expression, or the order in which the answers are presented.
Therefore, it is important not to treat evaluation by an LLM as the absolute truth, but rather to combine it with human evaluation and objective metrics.

25. Prompt improvement can be considered as an optimization problem

Prompt engineering can also be thought of from the perspective of mathematical optimization.
We treat the prompt as a variable and the performance on evaluation data as the objective function.
For example, it can be expressed as a problem of maximizing classification accuracy.

p∗=arg⁡max⁡p∈PJ(p)p^*=argmax_{pinmathcal{P}}J(p)

Here, p is the prompt, J is the evaluation function, and P is the set of prompts to be explored.
In reality, there are various evaluation items beyond just classification accuracy.

For example, adding a large number of response examples to improve accuracy may increase the number of input tokens and processing time.
Such problems can also be viewed as multi-objective optimization, where multiple objectives are considered simultaneously.

26. Automatic prompt optimization

Instead of humans manually revising prompts one by one, there are also methods to automatically generate and evaluate candidates.
For example, the process flows as follows:
Prepare an initial prompt
↓
Generate multiple prompt candidates
↓
Evaluate each candidate using evaluation data
↓
Select high-performance candidates
↓
Generate new candidates
↓
Evaluate again

This flow is similar to search using evolutionary algorithms or metaheuristics.
For automatic prompt optimization, various methods can be considered, such as random search, evolutionary computation, and candidate generation by LLMs.
However, if the evaluation data is inappropriate, automatic optimization may select undesirable prompts.
Even when automating, the design of evaluation criteria remains important.

27. The Relationship Between RAG and Prompt Engineering

In a previous article, I introduced RAG (Retrieval-Augmented Generation).
In RAG, documents relevant to a question are retrieved, and their content is provided to a large language model to generate an answer.
At this time, the prompt specifies how the retrieved documents should be used.

For example, the instructions are as follows:

参考資料に基づいて質問に回答してください。

参考資料に回答が存在しない場合は、
回答できないことを伝えてください。

資料にない情報を推測して追加しないでください。

回答には参照元を含めてください。

With such instructions, you can encourage answers that utilize reference materials.
However, prompts alone cannot completely prevent hallucinations.
The quality of retrieved documents, retrieval accuracy, the answer generation model, and evaluation methods are also important.
RAG and prompt engineering are technologies used in combination.

28. Also Be Aware of Prompt Injection

When using generative AI for business, it is also necessary to be aware of a problem called Prompt Injection.
This is a problem where the AI may perform actions different from its original instructions due to instructions contained in user input or external documents.

For example, inquiries to an internal help desk might contain instructions unrelated to the original classification process.
In RAG, there is also a possibility that retrieved documents contain malicious instructions.

As countermeasures, the following mechanisms can be considered:

  • Distinguish between system instructions and external data

  • Verify output content programmatically

  • Restrict the operational permissions given to the AI

  • Control access to confidential information

  • Prepare evaluation data that includes malicious input

The important point is that writing prohibitions in a prompt does not guarantee safety.
It is necessary to ensure safety across the entire system.

29. Version Control for Prompts

In business systems, it is desirable to manage prompts in the same way as source code.
For example, record information such as the following:

  • Prompt version

  • LLM used

  • Model version

  • Generation parameters

  • Evaluation data version

  • Evaluation results

  • Changes made

  • Examples of improvement

  • Examples of regression

Recording this information makes it easier to investigate the causes of performance changes.
Also, when switching to a new model, you can verify whether existing prompts will continue to function appropriately.
It is important to treat prompts not just as text, but as critical assets that make up an AI system.

30. What kind of tasks can prompt engineering be used for?

Prompt engineering can be applied to a wide variety of tasks.

Internal Help Desk

It can be used for classifying inquiries, suggesting response methods, and routing to the appropriate department.

Customer Support

It can be used for generating draft responses to inquiries and classifying customer feedback.

Software Development

It can be used for code generation, code review, test case creation, and technical documentation generation.

Manufacturing

It can be used for organizing equipment anomaly reports, summarizing maintenance records, and providing answers based on manuals.

Data Analysis

It can be used for explaining analysis results, generating SQL, and organizing insights gained from data.

Document Processing

This can be used for tasks such as information extraction from contracts and reports, document classification, and summarization.
In any of these tasks, simply introducing generative AI is not enough.
It is important to define the quality required for business operations and to continuously verify it using evaluation data.

31. Evaluation is the Most Important Aspect of Prompt Engineering

There are many techniques in prompt engineering.
These include Zero-shot Prompting, Few-shot Prompting, role specification, output format control, and adding context.
However, which technique is effective depends on the task and the model.
A prompt that worked well with one model may not necessarily function the same way with another.
Therefore, it is important not just to memorize specific techniques, but to build a mechanism for evaluation and improvement.

Define the objective
↓
Create evaluation data
↓
Create a baseline prompt
↓
Obtain responses
↓
Measure performance
↓
Analyze failure cases
↓
Improve the prompt
↓
Evaluate with unknown data

By repeating this cycle, you can improve prompts based on data rather than relying solely on experience or intuition.

Summary

In this article, we introduced everything from the basic concepts of prompt engineering to evaluation using Python, analysis of failure cases, and improvement methods.
When people hear “prompt engineering,” they tend to focus on how to write instructions for generative AI.

However, in reality, the following efforts are important.

  • Clarify the purpose of the task

  • Define judgment criteria

  • Create evaluation data

  • Quantify response quality

  • Verify output format

  • Analyze failure cases

  • Improve the prompt

  • Check performance against unknown data

In this Python experiment, we used three types of evaluation metrics: classification accuracy, format compliance rate, and overall success rate.
By evaluating sample outputs for explanation, we confirmed that even if the classification itself is correct, it might not be usable in a business system if the output format is inappropriate.
We also confirmed that analyzing individual failure cases, rather than just looking at average evaluation metrics, leads to the next improvement.
A good prompt is not one written with plausible-sounding instructions, but one whose performance against the objective has been properly verified.
I believe that the great significance of learning prompt engineering lies in becoming able to not just use generative AI, but to evaluate, analyze, and improve it.

For those who want to learn prompt engineering more deeply

In this article, we introduced the basic concepts of prompt engineering and the mechanism for evaluation using Python.
For those who want to learn systematically from prompt design to creating evaluation data, verifying performance, error analysis, and improvement, I have published the following Kindle book.

Introduction to Prompt Engineering: Learning by Running Code in Python
Verifying, Analyzing, and Improving Prompts with Evaluation Data

This is recommended for those who want to learn prompt engineering not just as a collection of instruction-writing methods or techniques, but as a technology to improve the performance of generative AI based on data.
If you want to deepen your understanding of prompt evaluation and improvement while actually running Python code, please take a look.

https://amzn.asia/d/0iu9tCEF

I will continue to publish articles on Python, AI, machine learning, data analysis, and mathematical optimization that you can understand by actually running the code.

Algo Taro

Originally Appeared Here

You May Also Like

About the Author:

Early Bird