快速入门:开始使用 ChatGPT 和 GPT-4 与 Azure OpenAI Service

  • Azure 订阅 – 免费创建一个
  • 在所需的 Azure 订阅中授予 Azure OpenAI 的访问权限。目前,只能通过应用程序授予对此服务的访问权限。您可以通过填写 https://aka.ms/oai/access 中的表格来申请访问 Azure OpenAI。在此存储库上打开问题,以便在遇到问题时与我们联系。
  • 具有 或gpt-35-turbogpt-41已部署的模型。有关模型部署的更多信息,请参阅资源部署指南

1 GPT-4 型号目前仅应要求提供。若要访问这些模型,现有 Azure OpenAI 客户可以通过填写此表单来申请访问权限

转到 Azure OpenAI Studio

导航到 Azure OpenAI Studio https://oai.azure.com/,并使用有权访问 OpenAI 资源的凭据登录。在登录工作流期间或之后,选择相应的目录、Azure 订阅和 Azure OpenAI 资源。

在 Azure OpenAI Studio 登陆页中,选择“聊天操场”。

chatgpt-playground

操场

通过 Azure OpenAI Studio 聊天操场开始采用无代码方法探索 OpenAI 功能。在此页面中,可以快速迭代和试验这些功能。

chatgpt-playground-load

助手设置

您可以使用“助理设置”下拉列表选择一些预加载的系统消息示例以开始使用。

系统消息为模型提供有关其行为方式以及在生成响应时应引用的任何上下文的说明。你可以描述助手的个性,告诉它应该回答什么,不应该回答什么,并告诉它如何格式化回答。

添加少数镜头示例允许您提供模型用于上下文学习的对话示例。

在使用聊天操场时,您可以随时选择“查看代码”,以查看根据当前聊天会话和设置选择预填充的 Python、curl 和 json 代码示例。然后,您可以获取此代码并编写一个应用程序来完成您当前在操场上执行的相同任务。

聊天会话

选择“发送”按钮会将输入的文本发送到完成 API,结果将返回到文本框。

选择“清除聊天”按钮以删除当前对话历史记录。

设置

名字 描述
部署 与特定模型关联的部署名称。对于 ChatGPT,您需要使用该模型。gpt-35-turbo
温度 控制随机性。降低温度意味着模型会产生更多重复性和确定性的响应。升高温度会导致更多意想不到或创造性的反应。尝试调整温度或顶部P,但不要同时调整两者。
最大长度(令牌) 对每个模型响应的令牌数设置限制。API 支持在提示(包括系统消息、示例、消息历史记录和用户查询)和模型响应之间共享最多 4096 个令牌。对于典型的英语文本,一个标记大约是四个字符。
最高概率 与温度类似,这控制随机性,但使用不同的方法。降低顶部 P 会将模型的令牌选择范围缩小到更有可能的令牌。增加顶部 P 允许模型从具有高可能性和低可能性的令牌中进行选择。尝试调整温度或顶部P,但不要同时调整两者。
多轮对话 选择要包含在每个新 API 请求中的过去消息数。这有助于为新用户查询提供模型上下文。将此数字设置为 10 会导致 <> 个用户查询和 <> 个系统响应。
停止序列 停止序列使模型在所需点结束其响应。模型响应在指定的序列之前结束,因此它不包含停止序列文本。对于 ChatGPT,使用可确保模型响应不会生成后续用户查询。最多可以包含四个停止序列。<|im_end|>

显示面板

默认情况下,有三个面板:助手设置、聊天会话和设置。显示面板允许您添加、删除和重新排列面板。如果您曾经关闭面板并需要将其恢复,请使用“显示面板”来恢复丢失的面板。

启动聊天会话

  1. 从助手设置下拉列表中,选择“Xbox 客户支持代理
  2. 系统将提示你是否要更新系统消息,选择“继续”。
  3. 在聊天会话窗格中,输入以下问题:“我有兴趣购买新的 Xbox”,然后选择“发送”。
  4. 您将收到类似于以下内容的响应:xbox
  5. 输入后续问题,例如:“哪些型号支持 4K?models
  6. Now that you have a basic conversation select View code from under Assistant setup and you’ll have a replay of the code behind the entire conversation so far:

Python

#Note: The openai-python library support for Azure OpenAI is in preview.
import os
import openai
openai.api_type = "azure"
openai.api_base = "https://docs-test-001.openai.azure.com/"
openai.api_version = "2023-05-15"
openai.api_key = os.getenv("OPENAI_API_KEY")

response = openai.ChatCompletion.create(
  engine="gpt-35-turbo", # replace this value with the deployment name you chose when you deployed the associated model.
  messages = [{"role":"system","content":"You are an Xbox customer support agent whose primary goal is to help users with issues they are experiencing with their Xbox devices. You are friendly and concise. You only provide factual answers to queries, and do not provide answers that are not related to Xbox."},{"role":"user","content":"How much is a PS5?"},{"role":"assistant","content":"I apologize, but I do not have information about the prices of other gaming devices such as the PS5. My primary focus is to assist with issues regarding Xbox devices. Is there a specific issue you are having with your Xbox device that I may be able to help with?"},{"role":"user","content":"I am interested in buying an Xbox?"},{"role":"assistant","content":"Great! There are several Xbox models available in the market, including the Xbox Series X, Xbox Series S, and Xbox One. The Xbox Series X is the latest and most powerful console, while the Xbox Series S is a more affordable option that still offers great performance. The Xbox One is the previous generation console, but it still has a large library of games available to play.\n\nBefore purchasing an Xbox, you may want to consider factors such as your budget, the types of games you want to play, and whether you want to play games in 4K resolution. Once you have decided on a console, you can purchase it from a retailer or directly from the Xbox website. Let me know if you have any other questions or concerns!"},{"role":"user","content":"Which models are 4K?"},{"role":"assistant","content":"Both the Xbox Series X and Xbox One X support 4K resolution gaming. The Xbox Series S, on the other hand, supports up to 1440p resolution gaming, but it can upscale games to 4K. It's worth noting that in order to take advantage of 4K gaming, you'll need a 4K TV or monitor that supports HDR (High Dynamic Range) and HDMI 2.0 or higher."}],
  temperature=0,
  max_tokens=350,
  top_p=0.95,
  frequency_penalty=0,
  presence_penalty=0,
  stop=None)

Understanding the prompt structure

如果您检查 View 代码中的示例,您会注意到一些不属于典型 GPT 完成调用的唯一令牌。ChatGPT 被训练使用特殊标记来描述提示的不同部分。内容在令牌之间提供给模型。提示以系统消息开头,该消息可用于通过包含模型的上下文或说明来启动模型。之后,提示包含用户和助手之间的一系列消息。<|im_start|><|im_end|>

然后,助手对提示的响应将在令牌下方返回,并以表示助手已完成响应结束。您还可以使用显示原始语法切换按钮在聊天会话面板中显示这些令牌。<|im_start|>assistant<|im_end|>

ChatGPT 操作指南深入介绍了新的提示结构以及如何有效地使用该模型。gpt-35-turbo

清理资源

完成聊天操场的测试后,如果要清理和删除 OpenAI 资源,可以删除资源或资源组。删除资源组也会删除与其关联的任何其他资源。

后续步骤

原创文章,作者:校长,如若转载,请注明出处:https://www.yundongfang.com/Yun230957.html

(0)
打赏 微信扫一扫不于多少! 微信扫一扫不于多少! 支付宝扫一扫礼轻情意重 支付宝扫一扫礼轻情意重
上一篇 2023年5月29日
下一篇 2023年5月29日

相关推荐