LoginSignup
2
1

Azure OpenAI Serviceのレスポンスが爆速だった件

Posted at

こちらの記事に応答速度が速いということが記載されていたので、早速Azure環境を用意して実際に検証してみました。
今回は単純にAPIの応答速度のみを検証してみました。

検証方法

VSCodeのREST Clientの拡張機能を使ってAzure OpenAIとOpenAIのAPIをそれぞれ実行してみるというものです。
AzureのリージョンはEast USを選択しました。
ChatGPTのバージョンはともにgpt-3.5-turboにしています。

### Azure OpenAI Service
POST https://<あなたの環境>.openai.azure.com/openai/deployments/gpt-35-deploy/chat/completions?api-version=2023-03-15-preview
Content-Type: application/json
api-key: <API キー>

{
  "messages": [
    {
      "role":"user",
      "content":"走れメロスを140文字で要約してください。"
    }
  ]
}

### OpenAI
POST https://api.openai.com/v1/chat/completions
Content-Type: application/json
Authorization: Bearer <API キー>

{
  "model": "gpt-3.5-turbo",
   "messages": [
    {
      "role":"user",
      "content":"走れメロスを140文字で要約してください。"
    }
  ] 
}

それぞれ実行するとレスポンス内容の差異はありませんでした。

Azure OpenAI Service
{
  "id": "chatcmpl-xxxxxxxxxxxxxxxxxxxxx",
  "object": "chat.completion",
  "created": 1685578236,
  "model": "gpt-35-turbo",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "ティラノス王に反抗した男の無実を証明しようと、友人のセリヌンティウスを助けるため、自分が罪をかぶって死刑になる決意をするメロス。逃げる道を捨て、彼は死を受け入れ、セリヌンティウスの成功を願いつつ、絶望的な運命に向き合う。自由のため、信頼と献身のため、彼の人生は永遠の光を放っている。"
      }
    }
  ],
  "usage": {
    "completion_tokens": 166,
    "prompt_tokens": 24,
    "total_tokens": 190
  }
}
OpenAI
{
  "id": "chatcmpl-xxxxxxxxxxxxxxxxxxxxxxxx",
  "object": "chat.completion",
  "created": 1685578127,
  "model": "gpt-3.5-turbo-0301",
  "usage": {
  },
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "メロスが妹を助けるために罪を背負わされ、処刑される前に友人のセリヌンティウスと出会い、セリヌンティウスが自分の身代わりになってくれた結末が悲劇的に描かれる。友情、正義、自由をテーマにした夏目漱石の一篇。"
      },
      "finish_reason": "stop",
      "index": 0
    }
  ]
}

レスポンス結果

上記検証環境にてそれぞれ5回ずつ実行してみました。結果は以下の通りで、Azure OpenAI Serviceが平均的に上回っており、爆速で返ってくることがわかりました。

利用API 1回目 2回目 3回目 4回目 5回目 平均
Azure OpenAI 4,566ms 4,377ms 6,127ms 4,904ms 4,933ms 4,981ms
OpenAI 7,706ms 11,410ms 9,933ms 11,215ms 8,917ms 9,836ms

まとめ

Azureは2023/06/01現在、申請フォームにて申請する必要があり環境構築に少し苦労しますが、それに引き換えレスポンス速度が圧倒的に速いので、積極的にAzure OpenAI Serviceを使っていきたいと感じました。

システム化のご検討やご相談は弊社までお問い合わせください。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1