반응형
블로그 이미지
개발자로서 현장에서 일하면서 새로 접하는 기술들이나 알게된 정보 등을 정리하기 위한 블로그입니다. 운 좋게 미국에서 큰 회사들의 프로젝트에서 컬설턴트로 일하고 있어서 새로운 기술들을 접할 기회가 많이 있습니다. 미국의 IT 프로젝트에서 사용되는 툴들에 대해 많은 분들과 정보를 공유하고 싶습니다.
솔웅

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

카테고리

Guide - Text completion

2023. 1. 9. 07:27 | Posted by 솔웅


반응형

https://beta.openai.com/docs/guides/completion

 

OpenAI API

An API for accessing new AI models developed by OpenAI

beta.openai.com

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.

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:

 

완료 끝점 (Completions endpoint)은 다양한 작업에 사용할 수 있습니다. 모든 모델에 간단하지만 강력한 인터페이스를 제공합니다. 일부 텍스트를 프롬프트로 입력하면 모델은 사용자가 제공한 컨텍스트나 패턴과 일치하도록 시도하는 텍스트 완성을 생성합니다. 예를 들어 API에 "As Descartes said, I think, therefore "라는 프롬프트를 제공하면 높은 확률로 "I am" 완료를 반환합니다.
완료(completions) 탐색을 시작하는 가장 좋은 방법은 Playground를 이용하는 것입니다. 완료(completion)를 생성하기 위해 프롬프트를 제출할 수 있는 텍스트 상자일 뿐입니다. 직접 시도하려면 플레이그라운드에서 다음 예제를 여십시오.

Write a tagline for an ice cream shop.

Once you submit, you'll see something like this:

이것을 submit 하면 아래와 같은 내용을 보실 수 있습니다.

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 stochastic by default. This means that you might get a slightly different completion every time you call it, even if your prompt stays the same. You can control this behavior with the temperature setting.

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.

 

API는 기본적으로 확률적이므로 표시되는 실제 완료(completion)는 다를 수 있습니다. 즉, 프롬프트가 동일하게 유지되더라도 호출할 때마다 약간 다른 완성을 얻을 수 있습니다. 온도(temperature) 설정으로 이 동작을 제어할 수 있습니다.
이 간단한 텍스트 입력, 텍스트 출력 인터페이스는 지시 사항이나 원하는 작업의 몇 가지 예를 제공하여 모델을 "프로그래밍"할 수 있음을 의미합니다. 성공 여부는 일반적으로 작업의 복잡성과 프롬프트의 품질에 따라 달라집니다. 좋은 경험 법칙은 중학생이 풀 수 있는 단어 문제를 어떻게 작성할 것인지 생각하는 것입니다. 잘 작성된 프롬프트는 모델이 사용자가 원하는 것과 응답 방법을 알 수 있도록 충분한 정보를 제공합니다.
이 가이드는 일반적인 프롬프트 디자인 모범 사례 및 예제를 다룹니다. 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.

 

보여주고 말하십시오. 지침, 예 또는 이 둘의 조합을 통해 원하는 것을 명확히 하십시오. 모델이 알파벳순으로 항목 목록의 순위를 매기거나 감정에 따라 단락을 분류하도록 하려면 그것이 원하는 것임을 보여주십시오.

양질의 데이터를 제공합니다. 분류자를 구축하거나 모델이 패턴을 따르도록 하려면 예제가 충분한지 확인하세요. 예제를 반드시 교정하십시오. 모델은 일반적으로 기본 철자 오류를 확인하고 응답을 제공할 만큼 충분히 똑똑하지만 이것이 의도적이며 응답에 영향을 미칠 수 있다고 가정할 수도 있습니다.

설정을 확인하십시오. 온도 및 top_p 설정은 모델이 응답을 생성하는 데 얼마나 결정적인지를 제어합니다. 정답이 하나뿐인 응답을 요청하는 경우 이 값을 더 낮게 설정하는 것이 좋습니다. 보다 다양한 응답을 찾고 있다면 더 높게 설정하는 것이 좋습니다. 사람들이 이러한 설정에서 가장 많이 범하는 실수는 "영리함" 또는 "창의성" 컨트롤이라고 가정하는 것입니다.

 

Troubleshooting

If you're having trouble getting the API to perform as expected, follow this checklist:

  1. Is it clear what the intended generation should be?
  2. Are there enough examples?
  3. Did you check your examples for mistakes? (The API won't tell you directly)
  4. Are you using temperature and top_p correctly?

API가 예상대로 작동하는 데 문제가 있는 경우 다음 체크리스트를 따르십시오.


1. 의도된 세대(generation)가 무엇이어야 하는지가 명확합니까?
2. 충분한 예가 있습니까?
3. 예제에서 실수를 확인했습니까? (API는 직접 알려주지 않습니다)
4. 온도와 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.

Decide whether a Tweet's sentiment is positive, neutral, or negative. Tweet: I loved the new Batman movie! Sentiment:
Open in Playground

API로 텍스트 분류자를 생성하기 위해 작업에 대한 설명과 몇 가지 예를 제공합니다. 이 예에서는 트윗의 감정을 분류하는 방법을 보여줍니다.
트윗의 감정이 긍정적인지, 중립적인지, 부정적인지 결정합니다. 트윗: 새로운 배트맨 영화가 너무 좋았어요! 감정:
플레이그라운드에서 열기

 

It's worth paying attention to several features in this example:

  1. 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.
  2. 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.
  3. 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.

이 예에서 몇 가지 기능에 주의를 기울일 가치가 있습니다.


1. 일반 언어를 사용하여 입력 및 출력을 설명하십시오. 입력 "Tweet" 및 예상 출력 "Sentiment"에 일반 언어를 사용합니다. 가장 좋은 방법은 일반 언어 설명으로 시작하는 것입니다. 속기 또는 키를 사용하여 입력 및 출력을 표시할 수 있지만 가능한 한 설명적인 것으로 시작한 다음 거꾸로 작업하여 추가 단어를 제거하고 성능이 일관되게 유지되는지 확인하는 것이 가장 좋습니다.

 

2. 모든 사례에 대응하는 방법을 API에 보여줍니다. 이 예에서는 지침에 가능한 감정 레이블을 포함합니다. 사람도 긍정적인지 부정적인지 판단하기 힘든 경우가 많고, 둘 다 아닌 상황도 많기 때문에 중립적인 꼬리표가 중요하다.

 

3. 익숙한 작업에는 더 적은 예가 필요합니다. 이 분류자에 대해서는 어떤 예도 제공하지 않습니다. 이는 API가 이미 트윗의 감정과 개념을 이해하고 있기 때문입니다. API가 익숙하지 않을 수 있는 것에 대한 분류자를 빌드하는 경우 더 많은 예제를 제공해야 할 수 있습니다.

 

Improving the classifier's efficiency

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.

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:
Open in Playground

이제 분류기를 구축하는 방법을 이해했으므로 해당 예제를 사용하여 한 번의 API 호출에서 여러 결과를 반환하는 데 사용할 수 있도록 훨씬 더 효율적으로 만들어 보겠습니다.
다음 트윗에서 감정을 분류하세요. 1. "숙제를 참을 수 없어" 2. "이거 짜증나. 지루해 😠" 3. "할로윈이 너무 기다려져!!!" 4. "내 고양이는 사랑스러워 ❤️❤️" 5. "나는 초콜릿이 싫어" 트윗 감정 평가:
플레이그라운드에서 열기

 

We provide a numbered list of Tweets so the API can rate five (and even more) Tweets in just one API call.

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.

  1. Make sure your probability setting is calibrated correctly by running multiple tests.
  2. Don't make your list too long or the API is likely to drift.

 

API가 단 한 번의 API 호출로 5개(또는 그 이상)의 트윗을 평가할 수 있도록 번호가 매겨진 트윗 목록을 제공합니다.
목록을 만들거나 텍스트를 평가하도록 API에 요청할 때 드리프트를 방지하기 위해 확률 설정(상단 P 또는 온도)에 각별한 주의를 기울여야 한다는 점에 유의해야 합니다.
1. 여러 테스트를 실행하여 확률 설정이 올바르게 보정되었는지 확인하십시오.
2. 목록을 너무 길게 만들지 마십시오. 그렇지 않으면 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.

Brainstorm some ideas combining VR and fitness:
Open in Playground

If needed, you can improve the quality of the responses by including some examples in your prompt.

 

API로 수행할 수 있는 가장 강력하면서도 가장 간단한 작업 중 하나는 새로운 아이디어 또는 입력 버전을 생성하는 것입니다. 스토리 아이디어부터 사업 계획, 캐릭터 설명 및 마케팅 슬로건에 이르기까지 무엇이든 요청할 수 있습니다. 이 예에서는 API를 사용하여 피트니스에서 가상 현실을 사용하기 위한 아이디어를 생성합니다.
VR과 피트니스를 결합한 몇 가지 아이디어를 브레인스토밍합니다.
플레이그라운드에서 열기


필요한 경우 프롬프트에 몇 가지 예를 포함하여 응답의 품질을 개선할 수 있습니다.


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.

Here's an example of the API playing the role of an AI answering questions:

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:
Open in Playground

API는 사람과 대화하는 데 매우 능숙합니다. 몇 줄의 지침만으로 우리는 API가 당황하지 않고 지능적으로 질문에 대답하는 고객 서비스 챗봇 또는 농담과 말장난을 하는 현명한 대화 파트너로 작동하는 것을 보았습니다. 핵심은 API가 어떻게 동작해야 하는지 알려주고 몇 가지 예를 제공하는 것입니다.


다음은 AI가 질문에 답하는 역할을 하는 API의 예입니다.


다음은 AI 비서와의 대화입니다. 조수는 도움이 되고 창의적이며 영리하고 매우 친절합니다. 인간: 안녕, 누구세요? AI: 저는 OpenAI가 만든 AI입니다. 무엇을 도와드릴까요? 인간:


플레이그라운드에서 열기

 

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:

  1. 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."
  2. 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.
  3. 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.

대화를 이어갈 수 있는 챗봇을 만드는 데 필요한 모든 것입니다. 단순함 아래에는 주의를 기울일 가치가 있는 몇 가지 사항이 있습니다.


1. 우리는 API에 의도를 알릴 뿐 아니라 행동 방법도 알려줍니다. 다른 프롬프트와 마찬가지로 API에 예제가 나타내는 내용을 입력하지만 또 다른 주요 세부 정보도 추가합니다. "어시스턴트는 유용하고 창의적이며 영리하고 매우 친절합니다. "

 

2. 이 명령이 없으면 API가 길을 잃고 상호 작용하는 인간을 모방하고 비꼬거나 피하고 싶은 다른 동작이 될 수 있습니다.

 

3. 우리는 API에 ID를 부여합니다. 처음에는 API가 AI 비서로 응답하도록 합니다. API에는 본질적인 ID가 없지만 가능한 한 진실에 가까운 방식으로 응답하는 데 도움이 됩니다. 다른 방식으로 ID를 사용하여 다른 종류의 챗봇을 만들 수 있습니다. 생물학 연구 과학자로 일하는 여성으로 응답하도록 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?
Open in Playground

Marv는 마지못해 비꼬는 답변으로 질문에 대답하는 챗봇입니다.
당신: 1킬로그램은 몇 파운드인가요?
마브: 또? 킬로그램에는 2.2파운드가 있습니다. 이를 메모해 두십시오.
당신: HTML은 무엇을 의미합니까?
Marv: Google이 너무 바빴나요? 하이퍼텍스트 마크업 언어. T는 앞으로 더 나은 질문을 하기 위한 것입니다.
당신: 최초의 비행기는 언제 날았나요?
마브: 1903년 12월 17일에 Wilbur와 Orville Wright가 첫 비행을 했습니다. 그들이 와서 나를 데려갔으면 좋겠다. 

당신: 삶의 의미는 무엇입니까?
마브: 잘 모르겠습니다. 내 친구 구글에게 물어볼게.
당신: 하늘이 왜 파란색이야?
플레이그라운드에서 열기

 

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:

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.

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에 보여줍니다.
이것을 프랑스어, 스페인어 및 일본어로 번역하십시오: 어떤 방이 있습니까?
플레이그라운드에서 열기
이 예제는 API가 이미 이러한 언어를 이해하고 있으므로 이를 가르치려고 할 필요가 없기 때문에 작동합니다.
영어에서 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.
Open in Playground        
2학년 학생을 위해 이것을 요약하십시오:
목성은 태양에서 다섯 번째 행성이며 태양계에서 가장 큰 행성입니다. 그것은 질량이 태양의 1000분의 1이지만 태양계의 다른 모든 행성을 합친 것의 2.5배인 가스 거성입니다. 목성은 밤하늘에서 육안으로 볼 수 있는 가장 밝은 물체 중 하나로, 역사가 기록되기 이전부터 고대 문명에 알려졌습니다. 그것은 로마 신 Jupiter의 이름을 따서 명명되었습니다.[19] 지구에서 볼 때 목성은 반사광이 눈에 보이는 그림자를 드리울 만큼 충분히 밝을 수 있으며[20] 평균적으로 밤하늘에서 달과 금성 다음으로 세 번째로 밝은 자연 물체입니다.
플레이그라운드에서 열기
 

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 = () => (
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.

  1. 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.
  2. 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가 답변을 구성할 가능성을 제한하는 두 가지 방법이 있습니다.

1. API에 대한 실측 정보를 제공합니다. Wikipedia 항목과 같은 질문에 답하기 위해 API에 텍스트 본문을 제공하면 응답을 구성할 가능성이 줄어듭니다.

2. 낮은 확률을 사용하고 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에 제공한 다음 알 수 없는 항목의 예를 제공하고 물음표를 제공합니다. 또한 API가 "?"로 응답할 가능성이 더 높도록 확률을 0으로 설정했습니다. 의심의 여지가 있다면.

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:
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.

 

완성 끝점(completions endpoint)은 또한 접두사 프롬프트 외에 접미사 프롬프트를 제공하여 텍스트 내에 텍스트 삽입을 지원합니다. 이러한 필요성은 긴 형식의 텍스트를 작성하거나, 단락 사이를 전환하거나, 개요를 따르거나, 모델을 결말로 안내할 때 자연스럽게 발생합니다. 이는 코드에서도 작동하며 함수 또는 파일 중간에 삽입하는 데 사용할 수 있습니다. 자세한 내용은 코드 가이드를 참조하세요.
접미사 컨텍스트가 우리의 예측 능력에 얼마나 중요한지 설명하기 위해 "오늘 나는 큰 변화를 주기로 결정했습니다."라는 프롬프트를 고려하십시오. 문장 완성을 상상할 수 있는 방법에는 여러 가지가 있습니다. 그러나 이제 이야기의 결말을 "내 새로운 머리에 대해 많은 찬사를 받았습니다!"라고 하면 의도한 완성이 분명해집니다.

 

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:

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.

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).

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.

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.

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.

 

텍스트 삽입은 베타의 새로운 기능이며 더 나은 결과를 위해 API 사용 방식을 수정해야 할 수도 있습니다. 다음은 몇 가지 모범 사례입니다.


max_tokens > 256을 사용하십시오. 모델은 더 긴 완료를 삽입하는 데 더 좋습니다. max_token이 너무 작으면 접미사에 연결하기 전에 모델이 잘릴 수 있습니다. 더 큰 max_tokens를 사용하는 경우에도 생성된 토큰 수에 대해서만 비용이 청구됩니다.


finish_reason == "중지"를 선호합니다. 모델이 자연스러운 중지 지점 또는 사용자가 제공한 중지 시퀀스에 도달하면 finish_reason을 "중지"로 설정합니다. 이것은 모델이 접미사에 잘 연결되었음을 나타내며 완성 품질에 대한 좋은 신호입니다. 이것은 특히 n > 1 또는 리샘플링을 사용할 때 몇 가지 완성 중에서 선택하는 것과 관련이 있습니다(다음 지점 참조).


3-5회 리샘플링. 거의 모든 완료가 접두사에 연결되지만 어려운 경우에는 모델이 접미사를 연결하는 데 어려움을 겪을 수 있습니다. 우리는 3번 또는 5번 리샘플링(또는 k=3,5와 함께 best_of를 사용)하고 finish_reason으로 "stop"을 사용하여 샘플을 선택하는 것이 이러한 경우에 효과적인 방법이 될 수 있음을 발견했습니다. 리샘플링하는 동안 일반적으로 다양성을 높이기 위해 더 높은 온도를 원할 것입니다.


참고: 반환된 모든 샘플에 finish_reason == "길이"가 있는 경우 max_tokens가 너무 작고 모델이 프롬프트와 접미사를 자연스럽게 연결하기 전에 토큰이 부족할 수 있습니다. 리샘플링하기 전에 max_tokens를 늘리는 것이 좋습니다.


더 많은 단서를 제공하십시오. 경우에 따라 모델 생성을 더 잘 돕기 위해 모델이 따라야 할 자연스러운 위치를 결정하기 위해 따라갈 수 있는 패턴의 몇 가지 예를 제공하여 단서를 제공할 수 있습니다.

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. Dogs are loyal animals. 2. Lions are ferocious animals. 3. Dolphins are playful animals. 4. Horses are majestic animals.

 

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 모델이 그에 따라 수정을 시도합니다. 텍스트 번역, 편집 및 조정을 위한 자연스러운 인터페이스입니다. 이는 리팩토링 및 코드 작업에도 유용합니다. 자세한 내용은 코드 가이드를 참조하세요. 이 초기 베타 기간 동안 edits 엔드포인트 사용은 무료입니다.

 

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
INSTRUCTIONS
Make this in the voice of GPT-3
OUTPUT
I am a very nice AI
반응형

'Open AI > GUIDES' 카테고리의 다른 글

Guide - Rate limits  (0) 2023.03.05
Guide - Speech to text  (0) 2023.03.05
Guide - Chat completion (ChatGPT API)  (0) 2023.03.05
Guides - Production Best Practices  (0) 2023.01.10
Guides - Safety best practices  (0) 2023.01.10
Guides - Moderation  (0) 2023.01.10
Guides - Embeddings  (0) 2023.01.10
Guides - Fine tuning  (0) 2023.01.10
Guide - Image generation  (0) 2023.01.09
Guide - Code completion  (0) 2023.01.09