Openai API 文档- Key Concepts 核心概念

Overview 概述

The OpenAI API can be applied to virtually any task that involves understanding or generating natural language, code, or images. We offer a spectrum of models with different levels of power suitable for different tasks, as well as the ability to fine-tune your own custom models. These models can be used for everything from content generation to semantic search and classification.

OpenAI API 可以应用于理解或者生成自然语言,代码或者图像。我们可以提供适用于不同能力级别的任务的模型,也可以调优你自己的模型。这些模型可以用于任何语义搜索分类的内容生成。

OpenAI has trained cutting-edge language models that are very good at understanding and generating text. Our API provides access to these models and can be used to solve virtually any task that involves processing language.

OpenAI 有一个训练过的擅长理解和生成文字的cutting-edge语言模型。我们的API 就是提供给你使用这些模型完成任何有关语言处理任务的入口。


Introduction 核心概念简介

The completions endpoint is the core of our API and provides a simple interface that’s extremely flexible and powerful. You input some text as a prompt, and the API will return a text completion that attempts to match whatever instructions or context you gave it.

Completions (语义完整的回答)是我们API的核心,提供了简单但是非常灵活并且强大的接口。你可以输入一个段文字作文 prompt (提示性质的问题),API会返回匹配你任何提示或内容的回答 Completions。

Prompt Write a tagline for an ice cream shop.

Prompt 给我的冰激凌店写句广告语

Completion We serve up smiles with every scoop!

Completion 每一勺都都有一个微笑

You can think of this as a very advanced autocomplete — the model processes your text prompt and tries to predict what’s most likely to come next.

你可以把这看成一个高级自动生成的模型,它可以处理你的提问然后预测下面最可能发生的事情。


Start with an instruction 从一个提示开始

Imagine you want to create a pet name generator. Coming up with names from scratch is hard!

现在你准备创建一个宠物名字生成器。凭空想象可是很难的哦。

First, you’ll need a prompt that makes it clear what you want. Let’s start with an instruction.

首先,你需要一个提示来表达你想要的。

Suggest one name for a horse.

帮我给马起个名字吧

Not bad! Now, try making your instruction more specific.

不赖!现在,试着让你的提示更具体一些。

Suggest one name for a black horse.

帮我给一匹黑马起个名字吧

As you can see, adding a simple adjective to our prompt changes the resulting completion. Designing your prompt is essentially how you “program” the model.

有时一个简单的形容词就能改变结果。所以设计好你的提问词,是运用模型的关键。


Add some examples 加一些例子

Crafting good instructions is important for getting good results, but sometimes they aren’t enough. Let’s try making your instruction even more complex.

给出好的提示对得到好的结果非常重要,但是有时还不足够。下面我们试着让你的提示更复杂一些。

Suggest three names for a horse that is a superhero.

帮我给一匹超人一样的马取三个名字吧。

This completion isn't quite what we want. These names are pretty generic, and it seems like the model didn't pick up on the horse part of our instruction. Let’s see if we can get it to come up with some more relevant suggestions.

回答也许不是你想要的,给出的名字也许太普通了,模型好像没有提取出你问题中马的部分。那我们来试一试加一些相关的提示吧。

In many cases, it’s helpful to both show and tell the model what you want. Adding examples to your prompt can help communicate patterns or nuances. Try submitting this prompt which includes a couple examples.

很多情况下,它对于展示和告诉模型你想要的都很重要。给一些例子可以帮助交流更规范和细致。下面是一个示例:

Suggest three names for an animal that is a superhero.

帮我给一匹超人一样的马取三个名字

Animal: Cat

动物:猫

Names: Captain Sharpclaw, Agent Fluffball, The Incredible Feline

名字:尖爪船长,毛球特工,大牛猫

Animal: Dog

动物:狗

Names: Ruff the Protector, Wonder Canine, Sir Barks-a-Lot

名字:进击保卫者,神奇狗狗,狂叫先生

Animal: Horse

动物:马

Names:

名字

Nice! Adding examples of the output we’d expect for a given input helped the model provide the types of names we were looking for.

很好!这些例子可以帮助模型给出真正你想要的回答。

Adjust your settings 调整你的设置

Prompt design isn’t the only tool you have at your disposal. You can also control completions by adjusting your settings. One of the most important settings is called temperature.

提问设计不是你唯一的手段。你还可以通过你的设置调整你的回答。一个最重要的设置就是 temperature 温度。

You may have noticed that if you submitted the same prompt multiple times in the examples above, the model would always return identical or very similar completions. This is because your temperature was set to 0.

你也许会注意到,你使用上面相同的提示词很多次,总是得到一样或者近似的答案。这是因为你的temperature设置的是0.

Try re-submitting the same prompt a few times with temperature set to 1.

你可以把temperature 设置成1,再试几次。

See what happened? When temperature is above 0, submitting the same prompt results in different completions each time.

会发生什么呢?温度设置为大于0后,同样的提问每次都会得到不同的回答。

Remember that the model predicts which text is most likely to follow the text preceding it. Temperature is a value between 0 and 1 that essentially lets you control how confident the model should be when making these predictions. Lowering temperature means it will take fewer risks, and completions will be more accurate and deterministic. Increasing temperature will result in more diverse completions.

记住,模型会根据之前的文字预测之后的文体。温度是一个0-1的值,让你可以控制模型预测的可信度。温度越低,意味着风险越低,回答越准确和有确定性。增大温度会得到多样化的回答。

For your pet name generator, you probably want to be able to generate a lot of name ideas. A moderate temperature of 0.6 should work well.

对于这个宠物起名器而言,我们想要有更多的名字,所以温度设为0.6会更好。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值