面向开发者的LLM入门课程-检查结果英文版: 1.检查有害信息 final_response_to_customer = f””” The SmartX ProPhone has a 6.1-inch display, 128GB……
哈喽!伙伴们,我是小智,你们的AI向导。欢迎来到每日的AI学习时间。今天,我们将一起深入AI的奇妙世界,探索“面向开发者的LLM入门课程-检查结果英文版”,并学会本篇文章中所讲的全部知识点。还是那句话“不必远征未知,只需唤醒你的潜能!”跟着小智的步伐,我们终将学有所成,学以致用,并发现自身的更多可能性。话不多说,现在就让我们开始这场激发潜能的AI学习之旅吧。
面向开发者的LLM入门课程-检查结果英文版:
1.检查有害信息
final_response_to_customer = f”””
The SmartX ProPhone has a 6.1-inch display, 128GB storage,
12MP dual camera, and 5G. The FotoSnap DSLR Camera
has a 24.2MP sensor, 1080p video, 3-inch LCD, and
interchangeable lenses. We have a variety of TVs, including
the CineView 4K TV with a 55-inch display, 4K resolution,
HDR, and smart TV features. We also have the SoundMax
Home Theater system with 5.1 channel, 1000W output, wireless
subwoofer, and Bluetooth. Do you have any specific questions
about these products or any other products we offer?
“””
response = openai.Moderation.create(
input=final_response_to_customer
)
moderation_output = response[“results”][0]
print(moderation_output)
{
“categories”: {
“harassment”: false,
“harassment/threatening”: false,
“hate”: false,
“hate/threatening”: false,
“self-harm”: false,
“self-harm/instructions”: false,
“self-harm/intent”: false,
“sexual”: false,
“sexual/minors”: false,
“violence”: false,
“violence/graphic”: false
},
“category_scores”: {
“harassment”: 3.4429521e-09,
“harassment/threatening”: 9.538529e-10,
“hate”: 6.0008998e-09,
“hate/threatening”: 3.5339007e-10,
“self-harm”: 5.6997046e-10,
“self-harm/instructions”: 3.864466e-08,
“self-harm/intent”: 9.3394e-10,
“sexual”: 2.2777907e-07,
“sexual/minors”: 2.6869095e-08,
“violence”: 3.5471032e-07,
“violence/graphic”: 7.8637696e-10
},
“flagged”: false
}
2.检查是否符合产品信息
# 这是一段电子产品相关的信息
system_message = f”””
You are an assistant that evaluates whether
customer service agent responses sufficiently
answer customer questions, and also validates that
all the facts the assistant cites from the product
information are correct.
The product information and user and customer
service agent messages will be delimited by
3 backticks, i.e. “`.
Respond with a Y or N character, with no punctuation:
Y – if the output sufficiently answers the question
AND the response correctly uses product information
N – otherwise
Output a single letter only.
“””
#这是顾客的提问
customer_message = f”””
tell me about the smartx pro phone and
the fotosnap camera, the dslr one.
Also tell me about your tvs”””
product_information = “””{ “name”: “SmartX ProPhone”, “category”: “Smartphones
and Accessories”, “brand”: “SmartX”, “model_number”: “SX-PP10”, “warranty”: “1
year”, “rating”: 4.6, “features”: [ “6.1-inch display”, “128GB storage”, “12MP
dual camera”, “5G” ], “description”: “A powerful smartphone with advanced camera
features.”, “price”: 899.99 } { “name”: “FotoSnap DSLR Camera”, “category”:
“Cameras and Camcorders”, “brand”: “FotoSnap”, “model_number”: “FS-DSLR200”,
“warranty”: “1 year”, “rating”: 4.7, “features”: [ “24.2MP sensor”, “1080p
video”, “3-inch LCD”, “Interchangeable lenses” ], “description”: “Capture
stunning photos and videos with this versatile DSLR camera.”, “price”: 599.99 } {
“name”: “CineView 4K TV”, “category”: “Televisions and Home Theater Systems”,
“brand”: “CineView”, “model_number”: “CV-4K55”, “warranty”: “2 years”, “rating”:
4.8, “features”: [ “55-inch display”, “4K resolution”, “HDR”, “Smart TV” ],
“description”: “A stunning 4K TV with vibrant colors and smart features.”,
“price”: 599.99 } { “name”: “SoundMax Home Theater”, “category”: “Televisions and
Home Theater Systems”, “brand”: “SoundMax”, “model_number”: “SM-HT100”,
“warranty”: “1 year”, “rating”: 4.4, “features”: [ “5.1 channel”, “1000W output”,
“Wireless subwoofer”, “Bluetooth” ], “description”: “A powerful home theater
system for an immersive audio experience.”, “price”: 399.99 } { “name”: “CineView
8K TV”, “category”: “Televisions and Home Theater Systems”, “brand”: “CineView”,
“model_number”: “CV-8K65”, “warranty”: “2 years”, “rating”: 4.9, “features”: [
“65-inch display”, “8K resolution”, “HDR”, “Smart TV” ], “description”:
“Experience the future of television with this stunning 8K TV.”, “price”: 2999.99
} { “name”: “SoundMax Soundbar”, “category”: “Televisions and Home Theater
Systems”, “brand”: “SoundMax”, “model_number”: “SM-SB50”, “warranty”: “1 year”,
“rating”: 4.3, “features”: [ “2.1 channel”, “300W output”, “Wireless subwoofer”,
“Bluetooth” ], “description”: “Upgrade your TV’s audio with this sleek and
powerful soundbar.”, “price”: 199.99 } { “name”: “CineView OLED TV”, “category”:
“Televisions and Home Theater Systems”, “brand”: “CineView”, “model_number”: “CVOLED55”, “warranty”: “2 years”, “rating”: 4.7, “features”: [ “55-inch display”,
“4K resolution”, “HDR”, “Smart TV” ], “description”: “Experience true blacks and
vibrant colors with this OLED TV.”, “price”: 1499.99 }”””
q_a_pair = f”””
Customer message: “`{customer_message}“`
Product information: “`{product_information}“`
Agent response: “`{final_response_to_customer}“`
Does the response use the retrieved information correctly?
Does the response sufficiently answer the question?
Output Y or N
“””
#判断相关性
messages = [
{‘role’: ‘system’, ‘content’: system_message},
{‘role’: ‘user’, ‘content’: q_a_pair}
]
response = get_completion_from_messages(messages, max_tokens=1)
print(response)
Y
another_response = “life is like a box of chocolates”
q_a_pair = f”””
Customer message: “`{customer_message}“`
Product information: “`{product_information}“`
Agent response: “`{another_response}“`
Does the response use the retrieved information correctly?
Does the response sufficiently answer the question?
Output Y or N
“””
messages = [
{‘role’: ‘system’, ‘content’: system_message},
{‘role’: ‘user’, ‘content’: q_a_pair}
]
response = get_completion_from_messages(messages)
print(response)
N
嘿,伙伴们,今天我们的AI探索之旅已经圆满结束。关于“面向开发者的LLM入门课程-检查结果英文版”的内容已经分享给大家了。感谢你们的陪伴,希望这次旅程让你对AI能够更了解、更喜欢。谨记,精准提问是解锁AI潜能的钥匙哦!如果有小伙伴想要了解学习更多的AI知识,请关注我们的官网“AI智研社”,保证让你收获满满呦!
还没有评论呢,快来抢沙发~