LoginSignup
0
0

More than 1 year has passed since last update.

GTP-3 ベースの NLP モデルを手軽に使える OpenAI API を使ってみる (1) Playground でお試し

Posted at

OpenAI API とは

OpenAI API は GTP-3 ベースの NLP(自然言語処理) モデルを、準備など不要で手軽に、 Web API として利用できるサービスで、β版を含めて試用ができるようになっています。(2021年11月末現在1)

20211129_openai_01.png

OpenAI API の種類

Examples を見ると、たくさんの種類があるように見えるのですが、API としては以下の 5 種類になります。
Documentation: Guides ※要サインイン

20211129_openai_03.png

OpenAI API のエンジン

API の種類とは別に、ベースとなるエンジンが用意されています。

  • Base : 一般的な NLP
  • Instruct : Instruction (指導、教育) といった用途に
  • Codex : コーディング用
  • Content filter :

それぞれのエンジンは MLの複雑さやマシンパワーによってさらに細分化されています。(※ない場合もあります。) Davinch > Curie > Babbage > Ada の順で強力(&高価) になります。どのレベルのエンジンを利用するといいのか、というガイドの他、Comparison Tool というモノも用意されています;

  • Davinch : Complex intent, cause and effect, summarization for audience
  • Curie : Language translation, complex classification, text sentiment, summarization
  • Babbage : Moderate classification, semantic search classification
  • Ada : Parsing text, simple classification, address correction, keywords

Documentation: Engines ※要サインイン

ひとまず OpenAI API に触れてみる

まずはサインアップ

メールアドレス or Google | Microsoft アカウントで試用サインアップします。
サインアップすると、ひとまず Free Trial プランが紐づけられるようです。上限$18.00、一番高価な Davinch モデルで $0.0600 / 1K tokens ということなので、"お試し" 程度はできそうです。(Token は投入する単語数で換算2)

20211129_openai_02.png

Playground でお試し

OpenAI API のいくつかの機能は Playground というオンラインツールで試すことができます。全部ではありませんが、日本語の利用も可能な機能もあります。

主な機能は Examples にまとめられています。
以下、いくつか日本語入力 OK だったものを挙げてみます。

Classification

Documentation: Classification ※要サインイン
Playground: Classification ※要サインイン

20211129_openai_04.png

クラス分類(ラベル付け)を行う機能ということで、サンプルはエンティティの自動タグ付け(のようなもの)になっていました。同じ要領で日本語で入力したところ、何となく正しいタグが生成されているのが分かります。

20211129_openai_05.png

Chat (Completion - Conversation)

Documentation: Completion - Conversation ※要サインイン
Playground: Chat ※要サインイン

20211129_openai_06.png

会話を生成する機能、でこれまた日本語で入力したところ、こちらの入力に対して質問を返す文章が生成されました。

20211129_openai_07.png

Generation (Completion - Generation)

Documentation: Completion - Generation ※要サインイン

Examples ではなく Documentation のリンクから Playground を開きます。

20211129_openai_08.png

ある程度の長さの文章を入力すると、それに続く文章が生成されました。生成されたものを必要に応じて修整し、続きを生成させることも可能です。

20211129_openai_09.png


  1. OpenAI Blog: OpenAI’s API Now Available with No Waitlist(2021/11/18) 

  2. "You can think of tokens as pieces of words, where 1,000 tokens is about 750 words.(Pricing ページ引用)" とのことですが、日本語や全角はどのようにカウントしているのか...。! 

0
0
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
0
0