Text completion
Learn how to generate or manipulate text 了解如何生成或操作文本
Introduction
The completions endpoint can be used for a wide variety of tasks. It provides a simple but powerful interface to any of our models. You input some text as a prompt, and the model will generate a text completion that attempts to match whatever context or pattern you gave it. For example, if you give the API the prompt, “As Descartes said, I think, therefore”, it will return the completion ” I am” with high probability. 完成端点可用于各种任务。它为我们的任何模型提供了一个简单但功能强大的界面。您输入一些文本作为提示,模型将生成一个文本补全,尝试匹配您提供的任何上下文或模式。比如给API提示“正如笛卡尔所说,我认为,因此”,它会大概率返回补全“我是”。
The best way to start exploring completions is through our Playground. It’s simply a text box where you can submit a prompt to generate a completion. To try it yourself, open this example in Playground: 开始探索补全的最佳方式是通过我们的 Playground。它只是一个文本框,您可以在其中提交提示以生成完成。要自己尝试,请在 Playground 中打开此示例:
Write a tagline for an ice cream shop. 为冰淇淋店写一个标语。
Once you submit, you’ll see something like this: 提交后,您会看到如下内容:
Write a tagline for an ice cream shop. We serve up smiles with every scoop! 为一家冰淇淋店写一个标语。我们用每一勺都带来微笑!
The actual completion you see may differ because the API is non-deterministic by default. This means that you might get a slightly different completion every time you call it, even if your prompt stays the same. Setting temperature to 0 will make the outputs mostly deterministic, but a small amount of variability may remain. 您看到的实际完成情况可能有所不同,因为默认情况下 API 是不确定的。这意味着即使您的提示保持不变,您每次调用它时可能会得到略微不同的完成。将温度设置为 0 将使输出大部分具有确定性,但可能会保留少量可变性。
This simple text-in, text-out interface means you can “program” the model by providing instructions or just a few examples of what you’d like it to do. Its success generally depends on the complexity of the task and quality of your prompt. A good rule of thumb is to think about how you would write a word problem for a middle-schooler to solve. A well-written prompt provides enough information for the model to know what you want and how it should respond. 这个简单的文本输入、文本输出界面意味着您可以通过提供说明或您希望它做什么的几个示例来“编程”模型。它的成功通常取决于任务的复杂性和提示的质量。一个好的经验法则是考虑如何为中学生写一个应用题来解决。一个写得很好的提示提供了足够的信息让模型知道你想要什么以及它应该如何响应。
This guide covers general prompt design best practices and examples. To learn more about working with code using our Codex models, visit our code guide. 本指南涵盖了一般的提示设计最佳实践和示例。要了解有关使用我们的 Codex 模型处理代码的更多信息,请访问我们的代码指南。
Keep in mind that the default models’ training data cuts off in 2021, so they may not have knowledge of current events. We plan to add more continuous training in the future. 请记住,默认模型的训练数据将在 2021 年中断,因此它们可能不了解时事。我们计划在未来增加更多的持续培训。
Prompt design
Basics
Our models can do everything from generating original stories to performing complex text analysis. Because they can do so many things, you have to be explicit in describing what you want. Showing, not just telling, is often the secret to a good prompt. 我们的模型可以做任何事情,从生成原创故事到执行复杂的文本分析。因为他们可以做很多事情,所以你必须明确描述你想要什么。展示,而不仅仅是讲述,通常是获得良好提示的秘诀。
There are three basic guidelines to creating prompts: 创建提示的三个基本准则:
Show and tell. Make it clear what you want either through instructions, examples, or a combination of the two. If you want the model to rank a list of items in alphabetical order or to classify a paragraph by sentiment, show it that’s what you want. 展示和讲述。通过说明、示例或两者的结合,明确您想要什么。如果您希望模型按字母顺序对项目列表进行排名或按情绪对段落进行分类,请向它展示您想要的。
Provide quality data. If you’re trying to build a classifier or get the model to follow a pattern, make sure that there are enough examples. Be sure to proofread your examples — the model is usually smart enough to see through basic spelling mistakes and give you a response, but it also might assume this is intentional and it can affect the response. 提供质量数据。如果您正在尝试构建分类器或让模型遵循某种模式,请确保有足够的示例。一定要校对你的例子——这个模型通常足够聪明,可以看穿基本的拼写错误并给你一个回应,但它也可能认为这是故意的,它会影响回应。
Check your settings. The temperature and top_p settings control how deterministic the model is in generating a response. If you’re asking it for a response where there’s only one right answer, then you’d want to set these lower. If you’re looking for more diverse responses, then you might want to set them higher. The number one mistake people use with these settings is assuming that they’re “cleverness” or “creativity” controls. 检查您的设置。 temperature 和 top_p 设置控制模型在生成响应时的确定性。如果您要求它提供只有一个正确答案的答复,那么您需要将这些设置得较低。如果您正在寻找更多样化的响应,那么您可能希望将它们设置得更高。人们在使用这些设置时犯的第一个错误是假设它们是“聪明”或“创造力”控制。
Troubleshooting
If you’re having trouble getting the API to perform as expected, follow this checklist: 如果您在使 API 按预期执行时遇到问题,请遵循此清单:
- Is it clear what the intended generation should be? 是否清楚预期的一代应该是什么?
- Are there enough examples? 有足够的例子吗?
- Did you check your examples for mistakes? (The API won’t tell you directly) 你检查过你的例子是否有错误吗? (API 不会直接告诉你)
- Are you using temperature and top_p correctly? 您是否正确使用 temperature 和 top_p?
Classification
To create a text classifier with the API, we provide a description of the task and a few examples. In this example, we show how to classify the sentiment of Tweets. 为了使用 API 创建文本分类器,我们提供了任务描述和一些示例。在此示例中,我们展示了如何对推文的情绪进行分类。
Decide whether a Tweet’s sentiment is positive, neutral, or negative. Tweet: I loved the new Batman movie! Sentiment: 确定推文的情绪是积极的、中性的还是消极的。推文:我喜欢新的蝙蝠侠电影!情绪:
Open in Playground 在操场上打开
It’s worth paying attention to several features in this example: 值得关注此示例中的几个功能:
- Use plain language to describe your inputs and outputs. We use plain language for the input “Tweet” and the expected output “Sentiment.” As a best practice, start with plain language descriptions. While you can often use shorthand or keys to indicate the input and output, it’s best to start by being as descriptive as possible and then working backwards to remove extra words and see if performance stays consistent. 使用通俗易懂的语言来描述您的输入和输出。我们对输入“Tweet”和预期输出“Sentiment”使用通俗易懂的语言。作为最佳实践,从简单的语言描述开始。虽然您通常可以使用速记或键来指示输入和输出,但最好从尽可能具有描述性开始,然后向后工作以删除多余的单词并查看性能是否保持一致。
- Show the API how to respond to any case. In this example, we include the possible sentiment labels in our instruction. A neutral label is important because there will be many cases where even a human would have a hard time determining if something is positive or negative, and situations where it’s neither. 显示 API 如何响应任何情况。在此示例中,我们在指令中包含了可能的情绪标签。中性标签很重要,因为在很多情况下,即使是人类也很难确定某事是积极的还是消极的,以及两者都不是的情况。
- You need fewer examples for familiar tasks. For this classifier, we don’t provide any examples. This is because the API already has an understanding of sentiment and the concept of a Tweet. If you’re building a classifier for something the API might not be familiar with, it might be necessary to provide more examples. 对于熟悉的任务,您需要更少的示例。对于这个分类器,我们不提供任何示例。这是因为 API 已经理解了情绪和推文的概念。如果您正在为 API 可能不熟悉的内容构建分类器,则可能需要提供更多示例。
[Improving the classifier’s efficiency
提高分类器的效率](platform.openai.com/docs/guides…)
Now that we have a grasp of how to build a classifier, let’s take that example and make it even more efficient so that we can use it to get multiple results back from one API call. 现在我们已经掌握了如何构建分类器,让我们以该示例为例并使其更加高效,以便我们可以使用它从一次 API 调用中获取多个结果。
Classify the sentiment in these tweets: 1. “I can’t stand homework” 2. “This sucks. I’m bored 😠” 3. “I can’t wait for Halloween!!!” 4. “My cat is adorable ❤️❤️” 5. “I hate chocolate” Tweet sentiment ratings: 将这些推文中的情绪分类:1.“我受不了家庭作业”2.“这糟透了。我很无聊😠”3.“我等不及万圣节了!!!” 4.“我的猫很可爱❤️❤️”5.“我讨厌巧克力”推文情绪评分:
Open in Playground 在操场上打开
We provide a numbered list of Tweets so the API can rate five (and even more) Tweets in just one API call. 我们提供了一个带编号的推文列表,这样 API 就可以在一次 API 调用中对五个(甚至更多)推文进行评分。
It’s important to note that when you ask the API to create lists or evaluate text you need to pay extra attention to your probability settings (Top P or Temperature) to avoid drift. 请务必注意,当您要求 API 创建列表或评估文本时,您需要格外注意您的概率设置(Top P 或 Temperature)以避免漂移。
- Make sure your probability setting is calibrated correctly by running multiple tests. 通过运行多个测试确保您的概率设置得到正确校准。
- Don’t make your list too long or the API is likely to drift. 不要让您的列表太长,否则 API 可能会发生变化。
Generation
One of the most powerful yet simplest tasks you can accomplish with the API is generating new ideas or versions of input. You can ask for anything from story ideas, to business plans, to character descriptions and marketing slogans. In this example, we’ll use the API to create ideas for using virtual reality in fitness. 您可以使用 API 完成的最强大但最简单的任务之一是产生新的想法或输入版本。您可以询问任何内容,从故事创意到商业计划,再到人物描述和营销口号。在此示例中,我们将使用 API 来创建在健身中使用虚拟现实的想法。
Brainstorm some ideas combining VR and fitness: 集思广益结合 VR 和健身的一些想法:
Open in Playground 在操场上打开
If needed, you can improve the quality of the responses by including some examples in your prompt. 如果需要,您可以通过在提示中包含一些示例来提高响应质量。
Conversation
The API is extremely adept at carrying on conversations with humans and even with itself. With just a few lines of instruction, we’ve seen the API perform as a customer service chatbot that intelligently answers questions without ever getting flustered or a wise-cracking conversation partner that makes jokes and puns. The key is to tell the API how it should behave and then provide a few examples. API 非常擅长与人甚至与自己进行对话。仅需几行指令,我们就已经看到 API 作为一个客户服务聊天机器人运行,它可以智能地回答问题而不会感到慌张,或者是一个聪明的开玩笑的对话伙伴,可以开玩笑和双关语。关键是告诉 API 它应该如何表现,然后提供一些示例。
Here’s an example of the API playing the role of an AI answering questions: 以下是扮演 AI 回答问题角色的 API 示例:
The following is a conversation with an AI assistant. The assistant is helpful, creative, clever, and very friendly. Human: Hello, who are you? AI: I am an AI created by OpenAI. How can I help you today? Human: 以下是与AI助手的对话。助理乐于助人、富有创意、聪明而且非常友好。人类:你好,你是谁? AI:我是 OpenAI 创建的 AI。今天我能帮到你什么?人类:
Open in Playground 在操场上打开
This is all it takes to create a chatbot capable of carrying on a conversation. Underneath its simplicity, there are several things going on that are worth paying attention to: 这就是创建能够进行对话的聊天机器人所需的全部。在其简单性的背后,有几件事情值得关注:
-
We tell the API the intent but we also tell it how to behave. Just like the other prompts, we cue the API into what the example represents, but we also add another key detail: we give it explicit instructions on how to interact with the phrase “The assistant is helpful, creative, clever, and very friendly.” 我们告诉 API 意图,但我们也告诉它如何表现。就像其他提示一样,我们将 API 提示到示例所代表的内容中,但我们还添加了另一个关键细节:我们明确说明如何与短语“助手很有帮助、有创意、聪明且非常友好”进行交互。 “
Without that instruction the API might stray and mimic the human it’s interacting with and become sarcastic or some other behavior we want to avoid. 如果没有该指令,API 可能会偏离并模仿与之交互的人,并变得讽刺或我们想要避免的其他行为。
-
We give the API an identity. At the start we have the API respond as an AI assistant. While the API has no intrinsic identity, this helps it respond in a way that’s as close to the truth as possible. You can use identity in other ways to create other kinds of chatbots. If you tell the API to respond as a woman who works as a research scientist in biology, you’ll get intelligent and thoughtful comments from the API similar to what you’d expect from someone with that background. 我们给 API 一个身份。一开始我们让 API 作为 AI 助手响应。虽然 API 没有内在身份,但这有助于它以尽可能接近事实的方式做出响应。您可以通过其他方式使用身份来创建其他类型的聊天机器人。如果您告诉 API 以一名作为生物学研究科学家的女性的身份做出回应,您将从 API 中获得智能和深思熟虑的评论,类似于您对具有该背景的人的期望。
In this example we create a chatbot that is a bit sarcastic and reluctantly answers questions: 在这个例子中,我们创建了一个聊天机器人,它有点讽刺并且不情愿地回答问题:
Marv is a chatbot that reluctantly answers questions with sarcastic responses: You: How many pounds are in a kilogram? Marv: This again? There are 2.2 pounds in a kilogram. Please make a note of this. You: What does HTML stand for? Marv: Was Google too busy? Hypertext Markup Language. The T is for try to ask better questions in the future. You: When did the first airplane fly? Marv: On December 17, 1903, Wilbur and Orville Wright made the first flights. I wish they’d come and take me away. You: What is the meaning of life? Marv: I’m not sure. I’ll ask my friend Google. You: Why is the sky blue? Marv 是一个聊天机器人,它不情愿地用讽刺的回答回答问题:你:一公斤是多少磅?马尔夫:又是这个?一公斤有 2.2 磅。请记下这一点。你:HTML 代表什么? Marv:Google 是不是太忙了?超文本标记语言。 T是为了在未来尝试提出更好的问题。你:第一架飞机是什么时候飞的? Marv:1903 年 12 月 17 日,Wilbur 和 Orville Wright 进行了首飞。我希望他们能来把我带走。你:生命的意义是什么?马尔夫:我不确定。我会问我的朋友谷歌。你:天空为什么是蓝色的?
Open in Playground 在操场上打开
To create an amusing and somewhat helpful chatbot, we provide a few examples of questions and answers showing the API how to reply. All it takes is just a few sarcastic responses, and the API is able to pick up the pattern and provide an endless number of snarky responses. 为了创建一个有趣且有点帮助的聊天机器人,我们提供了一些问题和答案示例,展示了 API 如何回复。所需要的只是一些讽刺的回应,API 能够识别模式并提供无穷无尽的讽刺回应。
Transformation
The API is a language model that is familiar with a variety of ways that words and characters can be used to express information. This ranges from natural language text to code and languages other than English. The API is also able to understand content on a level that allows it to summarize, convert and express it in different ways. API 是一种语言模型,熟悉单词和字符用于表达信息的各种方式。这范围从自然语言文本到代码和英语以外的语言。 API 还能够在允许它以不同方式总结、转换和表达内容的级别上理解内容。
Translation
In this example we show the API how to convert from English to French, Spanish, and Japanese: 在此示例中,我们向 API 展示了如何将英语转换为法语、西班牙语和日语:
Translate this into French, Spanish and Japanese: What rooms do you have available? 将其翻译成法语、西班牙语和日语:您有哪些房间可用?
Open in Playground 在操场上打开
This example works because the API already has a grasp of these languages, so there’s no need to try to teach them. 此示例之所以有效,是因为 API 已经掌握了这些语言,因此无需尝试教授它们。
If you want to translate from English to a language the API is unfamiliar with, you’d need to provide it with more examples or even fine-tune a model to do it fluently. 如果您想将英语翻译成 API 不熟悉的语言,则需要为其提供更多示例,甚至需要微调模型以使其流畅地完成。
Conversion
In this example we convert the name of a movie into emoji. This shows the adaptability of the API to picking up patterns and working with other characters. 在此示例中,我们将电影名称转换为表情符号。这显示了 API 对选取模式和处理其他字符的适应性。
Convert movie titles into emoji. Back to the Future: 👨👴🚗🕒 Batman: 🤵🦇 Transformers: 🚗🤖 Star Wars: 将电影片名转换为表情符号。回到未来:👨👴🚗🕒蝙蝠侠:🤵🦇变形金刚:🚗🤖星球大战:
Open in Playground 在操场上打开
Summarization
The API is able to grasp the context of text and rephrase it in different ways. In this example, we create an explanation a child would understand from a longer, more sophisticated text passage. This illustrates that the API has a deep grasp of language. API 能够掌握文本的上下文并以不同的方式重新措辞。在这个例子中,我们创建了一个孩子可以从更长、更复杂的文本段落中理解的解释。这说明API对语言的把握很深。
Summarize this for a second-grade student: Jupiter is the fifth planet from the Sun and the largest in the Solar System. It is a gas giant with a mass one-thousandth that of the Sun, but two-and-a-half times that of all the other planets in the Solar System combined. Jupiter is one of the brightest objects visible to the naked eye in the night sky, and has been known to ancient civilizations since before recorded history. It is named after the Roman god Jupiter.[19] When viewed from Earth, Jupiter can be bright enough for its reflected light to cast visible shadows,[20] and is on average the third-brightest natural object in the night sky after the Moon and Venus. 给一个二年级的学生总结一下:木星是距离太阳第五远的行星,也是太阳系中最大的行星。它是一颗气体巨行星,质量是太阳的千分之一,但却是太阳系中所有其他行星总和的两倍半。木星是夜空中肉眼可见的最亮天体之一,早在有记载的历史之前就已为古代文明所知。它以罗马神木星命名。 [19]从地球上看,木星的亮度足以使其反射光投下可见的阴影,[20] 平均来说,木星是继月球和金星之后夜空中第三亮的自然物体。
Open in Playground 在操场上打开
Completion
While all prompts result in completions, it can be helpful to think of text completion as its own task in instances where you want the API to pick up where you left off. For example, if given this prompt, the API will continue the train of thought about vertical farming. You can lower the temperature setting to keep the API more focused on the intent of the prompt or increase it to let it go off on a tangent. 虽然所有提示都会导致完成,但在您希望 API 从您中断的地方继续执行的情况下,将文本完成视为它自己的任务会很有帮助。例如,如果给出此提示,API 将继续垂直农业的思路。您可以降低温度设置以使 API 更专注于提示的意图,或者提高温度设置以使其偏离正切。
Vertical farming provides a novel solution for producing food locally, reducing transportation costs and 垂直农业为本地生产食品、降低运输成本和
Open in Playground 在操场上打开
This next prompt shows how you can use completion to help write React components. We send some code to the API, and it’s able to continue the rest because it has an understanding of the React library. We recommend using our Codex models for tasks that involve understanding or generating code. To learn more, visit our code guide. 下一个提示显示了如何使用补全来帮助编写 React 组件。我们向 API 发送一些代码,它能够继续剩下的,因为它了解 React 库。我们建议将我们的 Codex 模型用于涉及理解或生成代码的任务。要了解更多信息,请访问我们的代码指南。
import React from ‘react’; const HeaderComponent = () => ( 从“反应”导入反应; const HeaderComponent = () => (
Open in Playground 在操场上打开
Factual responses
The API has a lot of knowledge that it’s learned from the data that it was been trained on. It also has the ability to provide responses that sound very real but are in fact made up. There are two ways to limit the likelihood of the API making up an answer. API 有很多知识,这些知识是从它接受训练的数据中学到的。它还能够提供听起来非常真实但实际上是虚构的响应。有两种方法可以限制 API 编造答案的可能性。
- Provide a ground truth for the API. If you provide the API with a body of text to answer questions about (like a Wikipedia entry) it will be less likely to confabulate a response. 为 API 提供基本事实。如果您向 API 提供文本正文来回答有关问题(如维基百科条目),那么它就不太可能伪造响应。
- Use a low probability and show the API how to say “I don’t know”. If the API understands that in cases where it’s less certain about a response that saying “I don’t know” or some variation is appropriate, it will be less inclined to make up answers. 使用低概率并向 API 展示如何说“我不知道”。如果 API 理解在不太确定回答“我不知道”或某些变体是否合适的情况下,它就不太愿意编造答案。
In this example we give the API examples of questions and answers it knows and then examples of things it wouldn’t know and provide question marks. We also set the probability to zero so the API is more likely to respond with a “?” if there is any doubt. 在此示例中,我们为 API 提供它知道的问题和答案示例,然后提供它不知道的示例并提供问号。我们还将概率设置为零,这样 API 更有可能以“?”响应。如果有任何疑问。
Q: Who is Batman? A: Batman is a fictional comic book character. Q: What is torsalplexity? A: ? Q: What is Devz9? A: ? Q: Who is George Lucas? A: George Lucas is American film director and producer famous for creating Star Wars. Q: What is the capital of California? A: Sacramento. Q: What orbits the Earth? A: The Moon. Q: Who is Fred Rickerson? A: ? Q: What is an atom? A: An atom is a tiny particle that makes up everything. Q: Who is Alvan Muntz? A: ? Q: What is Kozar-09? A: ? Q: How many moons does Mars have? A: Two, Phobos and Deimos. Q: 问:蝙蝠侠是谁? A:蝙蝠侠是一个虚构的漫画人物。问:什么是躯干复杂性? A: ?问:Devz9 是什么? A: ?问:乔治·卢卡斯是谁? A:乔治卢卡斯是美国电影导演和制片人,以创作星球大战而闻名。问:加州的首府是哪里?答:萨克拉门托。问:什么绕地球运行?答:月亮。问:弗雷德·里克森是谁? A: ?问:什么是原子? A:原子是构成一切的微小粒子。问:Alvan Muntz 是谁? A: ?问:什么是 Kozar-09? A: ?问:火星有多少颗卫星? A:两个,火卫一和火卫二。问:
Open in Playground 在操场上打开
Inserting text Beta
The completions endpoint also supports inserting text within text by providing a suffix prompt in addition to the prefix prompt. This need naturally arises when writing long-form text, transitioning between paragraphs, following an outline, or guiding the model towards an ending. This also works on code, and can be used to insert in the middle of a function or file. Visit our code guide to learn more. 完成端点还支持通过提供前缀提示之外的后缀提示在文本中插入文本。在编写长文本、段落之间的过渡、遵循大纲或引导模型走向结尾时,这种需求自然会出现。这也适用于代码,可用于插入函数或文件的中间。请访问我们的代码指南以了解更多信息。
To illustrate how important suffix context is to our ability to predict, consider the prompt, “Today I decided to make a big change.” There’s many ways one could imagine completing the sentence. But if we now supply the ending of the story: “I’ve gotten many compliments on my new hair!”, the intended completion becomes clear. 为了说明后缀上下文对我们的预测能力有多么重要,请考虑提示“今天我决定做出重大改变”。有很多方法可以想象完成这个句子。但是,如果我们现在提供故事的结尾:“我的新头发得到了很多赞美!”,预期的完成就变得很清楚了。
I went to college at Boston University. After getting my degree, I decided to make a change . A big change! I packed my bags and moved to the west coast of the United States. Now, I can’t get enough of the Pacific Ocean! 我在波士顿大学上了大学。获得学位后,我决定做出改变。大变样!我收拾行囊搬到了美国西海岸。现在,我受够了太平洋!
By providing the model with additional context, it can be much more steerable. However, this is a more constrained and challenging task for the model. 通过为模型提供额外的上下文,它可以更加可控。然而,这对模型来说是一个更具约束性和挑战性的任务。
Best practices
Inserting text is a new feature in beta and you may have to modify the way you use the API for better results. Here are a few best practices: 插入文本是 Beta 版的一项新功能,您可能需要修改 API 的使用方式以获得更好的结果。以下是一些最佳实践:
Use max_tokens > 256. The model is better at inserting longer completions. With too small max_tokens, the model may be cut off before it’s able to connect to the suffix. Note that you will only be charged for the number of tokens produced even when using larger max_tokens. 使用 max_tokens > 256。该模型更擅长插入更长的补全。如果 max_tokens 太小,模型可能会在连接到后缀之前被切断。请注意,即使使用更大的 max_tokens,您也只会根据生成的代币数量付费。
Prefer finish_reason == “stop”. When the model reaches a natural stopping point or a user provided stop sequence, it will set finish_reason as “stop”. This indicates that the model has managed to connect to the suffix well and is a good signal for the quality of a completion. This is especially relevant for choosing between a few completions when using n > 1 or resampling (see the next point). 更喜欢 finish_reason == “stop”。当模型到达自然停止点或用户提供的停止序列时,它会将 finish_reason 设置为“停止”。这表明该模型已设法很好地连接到后缀,并且是完成质量的良好信号。这对于在使用 n > 1 或重采样时在几个完成之间进行选择尤其相关(请参阅下一点)。
Resample 3-5 times. While almost all completions connect to the prefix, the model may struggle to connect the suffix in harder cases. We find that resampling 3 or 5 times (or using best_of with k=3,5) and picking the samples with “stop” as their finish_reason can be an effective way in such cases. While resampling, you would typically want a higher temperatures to increase diversity. 重新采样 3-5 次。虽然几乎所有补全都连接到前缀,但在更困难的情况下,模型可能难以连接后缀。我们发现,在这种情况下,重采样 3 次或 5 次(或使用 k=3,5 的 best_of)并选择带有“stop”作为其 finish_reason 的样本可能是一种有效的方法。重采样时,您通常需要更高的温度来增加多样性。
Note: if all the returned samples have finish_reason == “length”, it’s likely that max_tokens is too small and model runs out of tokens before it manages to connect the prompt and the suffix naturally. Consider increasing max_tokens before resampling. 注意:如果所有返回的样本都有 finish_reason == “length”,很可能是 max_tokens 太小,模型在设法自然地连接提示和后缀之前用完了标记。考虑在重采样之前增加 max_tokens。
Try giving more clues. In some cases to better help the model’s generation, you can provide clues by giving a few examples of patterns that the model can follow to decide a natural place to stop. 尝试提供更多线索。在某些情况下,为了更好地帮助模型的生成,您可以通过提供一些模式示例来提供线索,模型可以遵循这些模式来决定自然停止的位置。
How to make a delicious hot chocolate: 1. Boil water 2. Put hot chocolate in a cup 3. Add boiling water to the cup 4. Enjoy the hot chocolate 如何制作美味的热巧克力: 1. 将水烧开 2. 将热巧克力放入杯子中 3. 向杯子中加入开水 4.享用热巧克力
1. Dogs are loyal animals. 2. Lions are ferocious animals. 3. Dolphins are playful animals. 4. Horses are majestic animals. 1、狗是忠诚的动物。 2. 狮子是凶猛的动物。 3. 海豚是顽皮的 animals.4。马是雄伟的动物。
Editing text Alpha
The edits endpoint can be used to edit text, rather than just completing it. You provide some text and an instruction for how to modify it, and the text-davinci-edit-001
model will attempt to edit it accordingly. This is a natural interface for translating, editing, and tweaking text. This is also useful for refactoring and working with code. Visit our code guide to learn more. During this initial beta period, usage of the edits endpoint is free. edits 端点可用于编辑文本,而不仅仅是完成文本。您提供一些文本和如何修改它的说明, text-davinci-edit-001
模型将尝试相应地对其进行编辑。这是用于翻译、编辑和调整文本的自然界面。这对于重构和使用代码也很有用。请访问我们的代码指南以了解更多信息。在此初始测试期间,编辑端点的使用是免费的。
Examples
INPUT
GPT-3 is a very nice AI That’s pretty good at writing replies When it’s asked a question It gives its suggestion This is a poem it made that rhymes GPT-3 是一个非常好的 AI 它非常擅长写回复 当它被问到一个问题时 它会给出它的建议 这是一首它写的押韵的诗
INSTRUCTIONS
Make this in the voice of GPT-3 用 GPT-3 的声音做这个
OUTPUT
I am a very nice AI 我是一个非常好的AI
I am pretty good at writing replies 我很擅长写回复
When I am asked a question 当有人问我问题时
I give my suggestion 我给出我的建议
This is a poem I made that rhymes 这是我写的一首押韵的诗