DEV Community

Cover image for 同學們,快來Azure 一起學習 OpenAI(一)
Jambo
Jambo

Posted on • Updated on

同學們,快來Azure 一起學習 OpenAI(一)

大家好我是微軟學生大使 Jambo , 在剛結束的微軟學生開發者峰會 2023中我們了解到微軟為學生提供了 Azure for Student 大禮包,通過 Azure for Student 除了學習和部署雲原生的應用外,還可以申請使用 Microsoft OpenAI Service 。在這個 AIGC 火熱的年代,作為學生別錯過這個千載難逢的機會。下面我會介紹一下我是如何申請到 Microsoft Azure for Student 和 Azure OpenAI Service 的

註冊 Azure for Student

註冊只需要準備好學校提供的 edu 郵箱,不需要信用卡

進入 Azure 主頁:https://azure.microsoft.com/zh-cn/free/students/ , 點擊開始使用。

Image description
登錄已有的 Microsoft 賬號,如果沒有可以新建一個。

Image description
之後進入驗證頁面,注意切換國家/地區代碼,電話號的部分無需加上地區碼。

Image description
然後進學生驗證,填入你的 edu 郵箱。

Image description
進入你的 edu 郵箱,進行郵箱驗證。

Image description
進入頁面後,勾選“同意協議”,第二個選項可不勾。

Image description
這部分可以全空。

Image description

點擊註冊後完成註冊,之後就會自動跳轉到 Azure 的控制面板中。

Image description
以上就是Azure for Students註冊的完整流程。需要注意的是,註冊時必須使用學校提供的edu郵箱,否則無法申請成功。

進入主頁,點擊“導航”下的“訂閱”,即可看到 “Azure for Students”。

Image description

申請 Azure OpenAI

在申請 Azure OpenAI 前一定要有 Azure 賬號。

目前 Azure OpenAI 只能通過填寫表格 申請的方式獲取訪問權限,https://aka.ms/oai/access

First Name 和 Last Name 通常對應 名 和 姓。

Image description
因為我們只有一個 Azure for Student 的訂閱,因此選 1 個即可。 Subscription ID 填寫 Azure 訂閱界面裡的 Azure for Student 訂閱 ID。

Image description

Image description
5 填寫你的 edu 郵箱,私人郵箱會被拒絕。

Image description
6~13 填寫學校信息即可。

14 選擇“其他”並填寫“University”, 16 選擇“Government”, 17 選擇“Education”。

Image description
18,19 如果你有微軟方面的聯繫人,就填 Ta 的名字和聯繫方式。

Image description
21 勾選你需要的區域,可全選,如果只勾選其中一個也可使用其他區域。
22 勾選 OpenAI 的功能,還要額外勾選預計用這些功能做哪些方面的事,按照自身情況勾選即可。
勾選剩下選項後,點擊提交。之後 edu 郵箱會收到微軟發來的郵件來驗證郵箱地址,點擊驗證。

Image description
以上就是申請 Azure OpenAI 的流程。申請之後會在 10 個工作日內給出答复(我在第二天就收到結果)。如果申請通過,即可在 Azure 使用 OpenAI 服務。

Image description

簡單的演示

在創建好 OpenAI 服務後,我們可以進入 https://oai.azure.com/ Playground 進行線上測試。
首先要部署模型,我這裡選擇了 text-davinci-003 模型進行示範。

Image description
在 GPT-3 頁面裡,選擇好部署的模型後就可以進行測試了。我這裡用了一道高等微积分的題目作為測試(但眾所周知gpt的邏輯分析能力還不夠好)。

Image description
在讓他重複生成了兩次後,終於還是給了一個比較好的答案。

我們還可以用 Python 調用接口來生成文字。

Image description

import os
import requests
import json
import openai

openai.api_key = "REPLACE_WITH_YOUR_API_KEY_HERE"
openai.api_base =  "REPLACE_WITH_YOUR_ENDPOINT_HERE" # your endpoint should look like the following https://YOUR_RESOURCE_NAME.openai.azure.com/
openai.api_type = 'azure'
openai.api_version = '2022-12-01' # this may change in the future

deployment_name='REPLACE_WITH_YOUR_DEPLOYMENT_NAME' #This will correspond to the custom name you chose for your deployment when you deployed a model. 

# Send a completion call to generate an answer
print('Sending a test completion job')
start_phrase = 'Write a tagline for an ice cream shop. '
response = openai.Completion.create(engine=deployment_name, prompt=start_phrase, max_tokens=10)
text = response['choices'][0]['text'].replace('\n', '').replace(' .', '.').strip()
print(start_phrase+text)
Enter fullscreen mode Exit fullscreen mode

最後這裡整理一份給大學生們的免費資源:

  1. Azure 免費資源:https://aka.ms/studentgetazure
  2. GitHub Education Pack:https://aka.ms/GitHubStudentDevPackSS23
  3. Azure OpenAI 申請表格:https://aka.ms/oai/access

Top comments (0)