赞
踩
推荐:使用NSDT场景编辑器助你快速搭建可二次编辑的3D应用场景
为了帮助用户获得最佳输出,OpenAI 提供了使用 GPT 模型的最佳实践。这来自体验,因为许多用户不断尝试使用此模型并找到了最有效的方法。
在本文中,我将总结使用 OpenAI GPT 模型应了解的最佳实践。这些做法是什么?让我们进入它。
GPT 模型输出仅与您的提示一样好。通过对您想要的内容的明确说明,它将提供您期望的结果。提高 GPT 输出的一些提示包括:
- import openai
-
- openai.api_key = ""
-
- res = openai.ChatCompletion.create(
- model="gpt-3.5-turbo",
- max_tokens=100,
- temperature=0.7,
- messages=[
- {
- "role": "system",
- "content": """
-
- When I ask to explain something, bring it in a way that teacher
- would explain it to students in every paragraph.
-
- """,
- },
- {
- "role": "user",
- "content": """
-
- What is golden globe award and what is the criteria for this award? Summarize them in 2 paragraphs.
-
- """,
- },
- ],
- )
提供示例结果来指导 GPT 模型应如何回答您的问题也很棒。例如,在此代码中,我传递了如何解释情绪,GPT 模型应模仿我的风格。
- res = openai.ChatCompletion.create(
- model="gpt-3.5-turbo",
- max_tokens=100,
- temperature=0.7,
- messages=[
- {
- "role": "system",
- "content": "Answer in a consistent style.",
- },
- {
- "role": "user",
- "content": "Teach me about Love",
- },
- {
- "role": "assistant",
- "content": "Love can be sweet, can be sour, can be grand, can be low, and can be anything you want to be",
- },
- {
- "role": "user",
- "content": "Teach me about Fear",
- },
- ],
- )
- res = openai.ChatCompletion.create(
- model="gpt-3.5-turbo",
- max_tokens=100,
- temperature=0.7,
- messages= [
- {
- "role": "system",
- "content": """
- Use the following step-by-step instructions to respond to user inputs.
- step 1 - Explain the question input by the user in 2 paragraphs or less with the prefix "Explanation: ".
- Step 2 - Translate the Step 1 into Indonesian, with a prefix that says "Translation: ".
-
- """,
- },
- {
- "role": "user",
- "content":"What is heaven?",
- },
- ])
- res = openai.ChatCompletion.create(
- model="gpt-3.5-turbo",
- max_tokens=100,
- temperature=0.7,
- messages= [
- {
- "role": "system",
- "content": """
- Work on your solution to the problem, then compare your solution to the user and evaluate
- if the solution is correct or not. Only decide if the solution is correct once you have done the problem yourself.
-
- """,
- },
- {
- "role": "user",
- "content":"1 + 1 = 3",
- },
- ])
- res = openai.ChatCompletion.create(
- model="gpt-3.5-turbo",
- max_tokens=100,
- temperature=0.7,
- messages= [
- {
- "role": "system",
- "content": """
- Write and execute Python code by enclosing it in triple backticks,
- e.g. ```code goes here```. Use this to perform calculations.
-
- """,
- },
- {
- "role": "user",
- "content":"""
-
- Find all real-valued roots of the following polynomial equation: 2*x**5 - 3*x**8- 2*x**3 - 9*x + 11.
-
- """,
- },
- ])
GPT 模型是目前最好的模型之一,以下是改进 GPT 模型输出的一些最佳实践:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。