赞
踩
课程地址: https://learn.deeplearning.ai/chatgpt-prompt-eng
@OpenAI & @ Deeplearing.ai
Prompting 的两个基本原则:
需要注意的是:
eg:使用 ``` 来包裹用户的提示内容,以避免提示注入 prompt injections
"""
---
<>
<tag> </tag>
示例内容
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) OutPut:Clear and specific instructions should be provided to guide a model towards the desired output, and longer prompts can provide more clarity and context for the model, leading to more detailed and relevant outputs.
指定输出的内容格式为 HTML
或 JSON
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)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。