AI教程 2025年01月11日
0 收藏 0 点赞 107 浏览 9647 个字
摘要 :

面向开发者的LLM入门课程-英文原版Prompt: 英文原版Prompt 1.使用分隔符清晰地表示输入的不同部分 text = f””” You should express what you want a……

哈喽!伙伴们,我是小智,你们的AI向导。欢迎来到每日的AI学习时间。今天,我们将一起深入AI的奇妙世界,探索“面向开发者的LLM入门课程-英文原版Prompt”,并学会本篇文章中所讲的全部知识点。还是那句话“不必远征未知,只需唤醒你的潜能!”跟着小智的步伐,我们终将学有所成,学以致用,并发现自身的更多可能性。话不多说,现在就让我们开始这场激发潜能的AI学习之旅吧。

面向开发者的LLM入门课程-英文原版Prompt

面向开发者的LLM入门课程-英文原版Prompt:

英文原版Prompt

1.使用分隔符清晰地表示输入的不同部分

text = f”””
You should express what you want a model to do by
providing instructions that are as clear and
specific as you can possibly make them.
This will guide the model towards the desired output,
and reduce the chances of receiving irrelevant
or incorrect responses. Don’t confuse writing a
clear prompt with writing a short prompt.
In many cases, longer prompts provide more clarity
and context for the model, which can lead to
more detailed and relevant outputs.
“””
prompt = f”””
Summarize the text delimited by triple backticks
into a single sentence.
“`{text}“`
“””
response = get_completion(prompt)
print(response)

To guide a model towards the desired output and reduce irrelevant or incorrect responses, it is important to provide clear and specific instructions, which can be achieved through longer prompts that offer more clarity and context.

2.寻求结构化的输出

prompt = f”””
Generate a list of three made-up book titles along
with their authors and genres.
Provide them in JSON format with the following keys:
book_id, title, author, genre.
“””
response = get_completion(prompt)
print(response)

{
“books”: [
{
“book_id”: 1,
“title”: “The Enigma of Elysium”,
“author”: “Evelyn Sinclair”,
“genre”: “Mystery”
},
{
“book_id”: 2,
“title”: “Whispers in the Wind”,
“author”: “Nathaniel Blackwood”,
“genre”: “Fantasy”
},
{
“book_id”: 3,
“title”: “Echoes of the Past”,
“author”: “Amelia Hart”,
“genre”: “Romance”
}
]
}

3.要求模型检查是否满足条件

text_1 = f”””
Making a cup of tea is easy! First, you need to get some
water boiling. While that’s happening,
grab a cup and put a tea bag in it. Once the water is
hot enough, just pour it over the tea bag.
Let it sit for a bit so the tea can steep. After a
few minutes, take out the tea bag. If you
like, you can add some sugar or milk to taste.
And that’s it! You’ve got yourself a delicious
cup of tea to enjoy.
“””
prompt = f”””
You will be provided with text delimited by triple quotes.
If it contains a sequence of instructions,
re-write those instructions in the following format:

Step 1 – …
Step 2 – …

Step N – …

If the text does not contain a sequence of instructions,
then simply write “No steps provided.”
“””{text_1}”””
“””
response = get_completion(prompt)
print(“Completion for Text 1:”)
print(response)

Completion for Text 1:
Step 1 – Get some water boiling.
Step 2 – Grab a cup and put a tea bag in it.
Step 3 – Once the water is hot enough, pour it over the tea bag.
Step 4 – Let it sit for a bit so the tea can steep.
Step 5 – After a few minutes, take out the tea bag.
Step 6 – If you like, add some sugar or milk to taste.
Step 7 – Enjoy your delicious cup of tea.

text_2 = f”””
The sun is shining brightly today, and the birds are
singing. It’s a beautiful day to go for a
walk in the park. The flowers are blooming, and the
trees are swaying gently in the breeze. People
are out and about, enjoying the lovely weather.
Some are having picnics, while others are playing
games or simply relaxing on the grass. It’s a
perfect day to spend time outdoors and appreciate the
beauty of nature.
“””
prompt = f”””You will be provided with text delimited by triple quotes.
If it contains a sequence of instructions,
re-write those instructions in the following format:
Step 1 – …
Step 2 – …

Step N – …

If the text does not contain a sequence of instructions,
then simply write “No steps provided.”
“””{text_2}”””
“””
response = get_completion(prompt)
print(“Completion for Text 2:”)
print(response)

Completion for Text 2:
No steps provided.

4.提供少量示例(少样本提示词,Few-shot prompting)

prompt = f”””
Your task is to answer in a consistent style.

: Teach me about patience.

: The river that carves the deepest
valley flows from a modest spring; the
grandest symphony originates from a single note;
the most intricate tapestry begins with a solitary thread.

: Teach me about resilience.
“””
response = get_completion(prompt)
print(response)

: Resilience is like a mighty oak tree that withstands the strongest storms, bending but never breaking. It is the unwavering determination to rise again after every fall, and the ability to find strength in the face of adversity. Just as a diamond is formed under immense pressure, resilience is forged through challenges and hardships, making us stronger and more resilient in the process.

5.指定完成任务所需的步骤

text = f”””
In a charming village, siblings Jack and Jill set out on
a quest to fetch water from a hilltop
well. As they climbed, singing joyfully, misfortune
struck—Jack tripped on a stone and tumbled
down the hill, with Jill following suit.
Though slightly battered, the pair returned home to
comforting embraces. Despite the mishap,
their adventurous spirits remained undimmed, and they
continued exploring with delight.
“””
# example 1
prompt_1 = f”””
Perform the following actions:
1 – Summarize the following text delimited by triple
backticks with 1 sentence.
2 – Translate the summary into French.
3 – List each name in the French summary.
4 – Output a json object that contains the following
keys: french_summary, num_names.

Separate your answers with line breaks.

Text:
“`{text}“`
“””
response = get_completion(prompt_1)
print(“Completion for prompt 1:”)
print(response)

Completion for prompt 1:
1 – Jack and Jill, siblings, go on a quest to fetch water from a hilltop well,but encounter misfortune when Jack trips on a stone and tumbles down the hill,with Jill following suit, yet they return home and remain undeterred in their adventurous spirits.
2 – Jack et Jill, frère et sœur, partent en quête d’eau d’un puits au sommet d’une colline, mais rencontrent un malheur lorsque Jack trébuche sur une pierre et dévale la colline, suivi par Jill, pourtant ils rentrent chez eux et restent déterminés dans leur esprit d’aventure.
3 – Jack, Jill
4 – {
“french_summary”: “Jack et Jill, frère et sœur, partent en quête d’eau d’un puits au sommet d’une colline, mais rencontrent un malheur lorsque Jack trébuche sur une pierre et dévale la colline, suivi par Jill, pourtant ils rentrent chez eux et restent déterminés dans leur esprit d’aventure.”,
“num_names”: 2
}

prompt_2 = f”””
Your task is to perform the following actions:
1 – Summarize the following text delimited by <> with 1 sentence.
2 – Translate the summary into French.
3 – List each name in the French summary.
4 – Output a json object that contains the
following keys: french_summary, num_names.
Use the following format:
Text:
Summary:

Translation:

Names: Output JSON:
Text: <{text}>
“””
response = get_completion(prompt_2)
print(“nCompletion for prompt 2:”)
print(response)

6.指导模型在下结论之前找出一个自己的解法

prompt = f”””
Determine if the student’s solution is correct or not.
Question:
I’m building a solar power installation and I need
help working out the financials.
– Land costs $100 / square foot
– I can buy solar panels for $250 / square foot
– I negotiated a contract for maintenance that will cost
me a flat $100k per year, and an additional $10 / square
foot
What is the total cost for the first year of operations
as a function of the number of square feet.
Student’s Solution:
Let x be the size of the installation in square feet.
Costs:
1. Land cost: 100x
2. Solar panel cost: 250x
3. Maintenance cost: 100,000 + 100x
Total cost: 100x + 250x + 100,000 + 100x = 450x + 100,000
“””
response = get_completion(prompt)
print(response)

The student’s solution is correct. They correctly identified the costs for land,solar panels, and maintenance, and calculated the total cost for the first year of operations as a function of the number of square feet.

prompt = f”””
Your task is to determine if the student’s solution
is correct or not.
To solve the problem do the following:
– First, work out your own solution to the problem.
– Then compare your solution to the student’s solution
and evaluate if the student’s solution is correct or not.
Don’t decide if the student’s solution is correct until
you have done the problem yourself.
Use the following format:
Question:
question here
“`
Student’s solution:
“`
student’s solution here
“`
Actual solution:
“`
steps to work out the solution and your solution here
“`
Is the student’s solution the same as actual solution
just calculated:
“`
yes or no
“`
Student grade:
“`
correct or incorrect
“`
Question:
“`
I’m building a solar power installation and I need help
working out the financials.
– Land costs $100 / square foot
– I can buy solar panels for $250 / square foot
– I negotiated a contract for maintenance that will cost
me a flat $100k per year, and an additional $10 / square
foot
What is the total cost for the first year of operations
as a function of the number of square feet.
“`
Student’s solution:
“`
Let x be the size of the installation in square feet.
Costs:
1. Land cost: 100x
2. Solar panel cost: 250x
3. Maintenance cost: 100,000 + 100x
Total cost: 100x + 250x + 100,000 + 100x = 450x + 100,000
Actual solution:
“””
response = get_completion(prompt)
print(response)

To calculate the total cost for the first year of operations, we need to add up
the costs of land, solar panels, and maintenance.
1. Land cost: $100 / square foot
The cost of land is $100 multiplied by the number of square feet.
2. Solar panel cost: $250 / square foot
The cost of solar panels is $250 multiplied by the number of square feet.
3. Maintenance cost: $100,000 + $10 / square foot
The maintenance cost is a flat fee of $100,000 per year, plus $10 multiplied by
the number of square feet.
Total cost: Land cost + Solar panel cost + Maintenance cost
So the actual solution is:
Total cost = (100 * x) + (250 * x) + (100,000 + (10 * x))
Is the student’s solution the same as the actual solution just calculated:
No
Student grade:
Incorrect

7.幻觉

prompt = f”””
Tell me about AeroGlide UltraSlim Smart Toothbrush by Boie
“””
response = get_completion(prompt)
print(response)

The AeroGlide UltraSlim Smart Toothbrush by Boie is a technologically advanced toothbrush designed to provide a superior brushing experience. Boie is a company known for its innovative oral care products, and the AeroGlide UltraSlim Smart Toothbrush is no exception.

One of the standout features of this toothbrush is its ultra-slim design. The brush head is only 2mm thick, making it much thinner than traditional toothbrushes. This slim profile allows for better access to hard-to-reach areas of the mouth, ensuring a thorough and effective clean.

The AeroGlide UltraSlim Smart Toothbrush also incorporates smart technology. It connects to a mobile app via Bluetooth, allowing users to track their brushing habits and receive personalized recommendations for improving their oral hygiene routine. The app provides real-time feedback on brushing technique, duration, and coverage, helping users to achieve optimal oral health.

The toothbrush features soft, antimicrobial bristles made from a durable thermoplastic elastomer. These bristles are gentle on the gums and teeth, while also being effective at removing plaque and debris. The antimicrobial properties help to keep the brush head clean and hygienic between uses.

Another notable feature of the AeroGlide UltraSlim Smart Toothbrush is its long battery life. It can last up to 30 days on a single charge, making it convenient for travel or everyday use without the need for frequent recharging.

Overall, the AeroGlide UltraSlim Smart Toothbrush by Boie offers a combination of advanced technology, slim design, and effective cleaning capabilities. It is a great option for those looking to upgrade their oral care routine and achieve a healthier smile.

面向开发者的LLM入门课程-迭代优化
面向开发者的LLM入门课程-迭代优化:迭代优化 在开发大语言模型应用时,很难通过第一次尝试就得到完美适用的 Prompt。关键在于建立一...

嘿,伙伴们,今天我们的AI探索之旅已经圆满结束。关于“面向开发者的LLM入门课程-英文原版Prompt”的内容已经分享给大家了。感谢你们的陪伴,希望这次旅程让你对AI能够更了解、更喜欢。谨记,精准提问是解锁AI潜能的钥匙哦!如果有小伙伴想要了解学习更多的AI知识,请关注我们的官网“AI智研社”,保证让你收获满满呦!

微信扫一扫

支付宝扫一扫

版权: 转载请注明出处:https://www.ai-blog.cn/2418.html

相关推荐
01-15

面向开发者的LLM入门课程-路由链: 路由链 到目前为止,我们已经学习了大语言模型链和顺序链。但是…

215
01-15

面向开发者的LLM入门课程-顺序链: 顺序链 当只有一个输入和一个输出时,简单顺序链(SimpleSequen…

107
01-15

面向开发者的LLM入门课程-简单顺序链: 简单顺序链 顺序链(SequentialChains)是按预定义顺序执行…

107
01-15

面向开发者的LLM入门课程-大语言模型链: 模型链 链(Chains)通常将大语言模型(LLM)与提示(Pro…

107
01-15

面向开发者的LLM入门课程-对话储存英文版提示: 英文版提示 1.对话缓存储存 from langchain.chains…

107
01-15

面向开发者的LLM入门课程-对话摘要缓存储存: 对话摘要缓存储存 对话摘要缓存储存,使用 LLM 对到…

107
01-15

面向开发者的LLM入门课程-对话字符缓存储存: 对话字符缓存储存 使用对话字符缓存记忆,内存将限制…

107
01-15

面向开发者的LLM入门课程-对话缓存窗口储存: 对话缓存窗口储存 随着对话变得越来越长,所需的内存…

107
发表评论
暂无评论

还没有评论呢,快来抢沙发~

助力原创内容

快速提升站内名气成为大牛

扫描二维码

手机访问本站