Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Amazon Bedrock のはじめ方

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for Takahiro Kubo Takahiro Kubo PRO
November 13, 2023

Amazon Bedrock のはじめ方

Amazon Bedrock のはじめ方を準備、実行、監視の 3 ステップで説明した資料です。
Amazon Bedrock を使い始めるための設定、Playground の使い方、入力したプロンプト等のロギングを行う方法を紹介しています。また、コードの生成が台頭する中重要になるユースケースの発見を支援するワークショップもご紹介しています。

Amazon Bedrock の使い始め方 (動画)
https://www.youtube.com/watch?v=SjB9-x9Ygcw

ML Enablement Workshop
https://github.com/aws-samples/aws-ml-enablement-workshop

Anthropic Claude のプロンプトガイド
https://docs.anthropic.com/claude/docs/introduction-to-prompt-design

Amazon Bedrock Full Access を付与する際の権限 (※実際は適切に権限を制御してください)


{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "BedrockFullAccess",
      "Effect": "Allow",
      "Action": ["bedrock:*"],
      "Resource": "*"
    }
  ]
}

Amazon Bedrock + Kendra で作る RAG のハンズオン
https://catalog.us-east-1.prod.workshops.aws/workshops/6708bce5-6aa3-4acb-89f7-85c39c006c8c/en-US

Avatar for Takahiro Kubo

Takahiro Kubo PRO

November 13, 2023
Tweet

More Decks by Takahiro Kubo

Other Decks in Technology

Transcript

  1. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Bedrock のはじめ方 Machine Learning Developer Relations Takahiro Kubo アマゾン ウェブ サービス ジャパン合同会社
  2. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 3 つのステップ 準備 実行 監視
  3. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 3 自己紹介 アマゾン ウェブ サービス ジャパン合同会社 Machine Learning Developer Relations 久保隆宏 (Kubo Takahiro) ミッション 「機械学習を実用するなら AWS 」という認知を拡大すること。 10 年以上の業務コンサルタント経験、また研究開発していたテーマをプロダクトと してリリースした経験をもとにお話しします。
  4. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 準備 実行 監視
  5. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Bedrock : API から利用できる基盤モデル 5 Amazon だけでなく先進的スタートアップ企業の基盤モデルを提供 対話向けの LLM 質問回答、 業務フローの自動化 責任ある AI に 向けた学習 テキスト生成用 多言語対応 LLM 英語、西語、仏語 独語、葡語、伊語 蘭語 Amazon の構築した LLM テキスト要約 テキスト生成 テキスト分類 自由形式の Q&A 情報抽出 Embedding 検索 オープンソースの 画像生成 LLM 独自性、高精細、 リアルなロゴや デザイン生成 インペインティング 業務アプリ向けの テキスト生成モデル 要約、広告文、 対話、情報抽出 質問回答 JU RA S SIC -2 C L A U DE 2 S DXL 1 .0 A M A ZO N T IT A N C O M M AN D L L A M A 2 オープンソースの LLM 質問回答や文書読解 などの自然言語処理 タスク Coming Soon
  6. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 7 汎用的な基盤モデルだけでなく、文書校正や要約に特化したモデルを提供。 ※ Amazon Bedrock では基盤モデルのみ、 JumpStart ( 後述 ) で他のモデルを利用可能 文書の校正を支援する Wordtune などを開発する企業。 AI に より人が読み書きする方法の変革を目指す。 ※日本語は扱えない Bedrock Model Providers 1/6
  7. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 8 Claude は約百ページ超の 100,000 トークンを扱えるだけでなく、GPT-3.5 / GPT 4 と近しい精度を (日本語でも) 持つモデル (※1, 2 参照)。 ※1 https://huggingface.co/spaces/lmsys/chatbot-arena-leaderboard ※2 https://yuzuai.jp/benchmark OpenAI 在籍メンバーが 2021 年に創業。安全かつ制御可能な AI の開発を目指す。Amazon からは 40 億ドルを出資。 Bedrock Model Providers 2/6
  8. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 9 伊藤忠商事の決算報告書読み込ませ て、事業と業績について質問した例 (※1) 。 ① 事業は概ね正しく列挙。 ② 業績について数字と増減要因に 誤りがない。 ※1 :第 100 期 第 1 四半期報告書 Bedrock Model Providers 2/6
  9. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 10 “The enterprise LLM” を掲げ、顧客自身のネットワーク / 環境 へのデプロイ、そこでのカスタマイズ、さらにサポートを提供。 テキスト生成の Command 、ベクトル表現の Embed といった基盤モデルの開 発に加え、マッキンゼーとの協業による導入支援、またサポートの提供も行う。 日本語は、理解しているが英語で返す。 Embedding のモデルは多言語対応している Bedrock Model Providers 3/6
  10. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 11 AI に対しオープンイノベーションのアプローチをとることを支持 し実践する。 Llama2 などのモデルをオープンソースで公開。 Llama2 は単体で高い性能を誇るだけでなく、オープンソースゆえにさまざまな 派生モデルが生まれている。 https://huggingface.co/spaces/lmsys/chatbot-arena-leaderboard Hugging Face の Chatbot Arena ではトップ 10 にオリジナル含め 4 モデルがランクイン。 ELYZA や rinna から日本語データで追加学習されたモデルも公開。 Bedrock Model Providers 4/6
  11. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 12 Stable Diffusion をはじめ、 Stable LM 、Stable Audio など多様なモダリティ のモデルを公開。日本法人を立ち上げ、日本語のモデルも公開。 世界をリードするオープンソースの生成 AI モデルの開発と展開を 行う企業。画像だけでなく言語、音声など多様なモデルを公開。 Japanese StableLM Alpha Bedrock Model Providers 5/6 11/13 商用利用可能な 画像 to テキストの モデルを公開
  12. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 13 オンラインで求めるあらゆるものをいつでも検索・発見できるこ と、地球上で最もお客様を大切にする企業になることを目指す Amazon Titan はコードを含めた幅広なコーパスで学習しているほか、不適切 または有害なコンテンツを減らすことで、責任ある AI の使用を支援。 Bedrock Model Providers 6/6
  13. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. まだ Bedrock 使ったことがない方は Step5 までぜひ一緒にやりましょう! 15 YouTube 動画リンク
  14. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 東京リージョンで使えます! ※利用可能なモデルに制限あり 1.“Amazon Bedrock” を AWS Console で検索
  15. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 3.“Model access” を選択
  16. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 4. Anthropic について “Submit use case details” を押す 表示される フォームに回答
  17. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 20 会社での使用を前提としたフォーム になっています。 所属の会社の情報を入れていただき、 社内検証用の建付けであれば Internal employees を選択、ユース ケースについては検証したい内容を 記載ください。 ( 日本語で書いて Amazon Translate で英 訳すると楽です。 )
  18. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Save Changes のボタン 6. Anthropic も含めて全選択して “Save Changes”!
  19. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 利用料金がかかるのでご注意ください価格は↓をチェック https://aws.amazon.com/jp/bedrock/pricing/ 7. Chat したり Image 生成したりする
  20. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 8. SageMaker Studio から使いたい場合 (1/3) ①SageMaker Domain の settings から Execution role を特定
  21. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 8. SageMaker Studio から使いたい場合 (2/3) ② IAM ロールの画面で Execution role を検索し、Create inline policy を実行
  22. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 8. SageMaker Studio から使いたい場合 (3/3) ③ JSON を選択し↓を張り付け。 { "Version": "2012-10-17", "Statement": [ { "Sid": "BedrockFullAccess", "Effect": "Allow", "Action": ["bedrock:*"], "Resource": "*" } ] }
  23. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 準備 実行 監視
  24. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Playground を使用する 28 Chat Text Image 3 種類を選択可能 ( 選べるモデルによって メニューは変動する )
  25. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Playground を使用する : Chat 29 推論時のパラメーターを設定可能 Temperature: 低いほど確実な単語のみ採用する。 Top P: 出現確率が高い順に並べ合計 P になるまで採用。 Top K: 出現確率が高い上位 N 個から採用する。 Length: 出力長を制限。
  26. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Playground を使用する : Chat 30 回答スタイルを設定可能
  27. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Playground を使用する : Chat 31 インストラクションを設定すると 回答が変化
  28. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Playground を使用する : Chat プロンプトエンジニアリング • 入力するテキストの内容や形式によって期待する返答が得られるよ うチューニングする。 • あるモデルで有効な方法が他のモデルでも有効とは限らない。 32 Anthropic Claude では ガイドラインが公開さ れている。 ※日本語訳版も公開さ れました※ https://docs.anthropic.com/claude/docs/introduction-to-prompt-design
  29. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 準備 実行 監視
  30. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 利用者が重要な秘密情報や特定個人情報を送信してい ないか心配で眠れない夜もある 34 Amazon Bedrock に送信したデータは Amazon および 3rd Party のモデ ルプロバイダーのモデルの学習に使用されることはありません
  31. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Bedrock の実行履歴は CloudTrail に記録される 35 どのモデルをいつ呼び出したかを把握可能 (InvokeModel / InvokeModelWithResponseStrea)
  32. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 具体的なプロンプトの中身を記録する場合は Model invocation logging をオンにする (Preview)。 36 Amazon S3 か CloudWatch に記録可能。 CloudWatch の場合、事前にロググループを作成 しておく (/aws/bedrock など)。 ロールは “Create and use a new role”で作成可能。
  33. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 具体的なプロンプトの中身を記録する場合は Model invocation logging をオンにする (Preview)。 37 入出力だけでなく、設定された パラメーターまで取得可能。
  34. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 準備 実行 監視 Amazon Bedrock どう活かす ?
  35. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 生成系 AI のインパクトが大きいのはサービス開発・運用、営業 39 マッキンゼーのレポートに見る企業応用を促進する大規模言語モデルの評価方法 マッキンゼーの 「The economic potential of generative AI: The next productivity frontier」より。 開発者自身が効果を体験し、 他業務領域へ伝播していくのが 王道と考えられる。
  36. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 開発者の生産性の広がり 40 コードの自動提案 営業メールの提案 稟議書の文言提案 契約書の条項提案 開発者が「当たり前」に享受し ている生産性は他の業務では全 然当たり前ではない。
  37. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 「何を作るか」を考える プロダクトマネージャー へのステップアップは 今後より重要に ? 日本ではエンジニア出身が 33% 、 プロジェクトマネージャーが出身 が 18.5% と合わせて半数以上 (日本で働くプロダクトマネージャー大規模調査レ ポート 2022 by pmconf より) 41 「GitHub CEO トーマス・ドムケ氏が来日。いずれコードの 80% が AI で作成されるようになると予言」より引用 https://www.publickey1.jp/blog/22/github_ceo_80ai.html
  38. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ML Enablement Workshop: AI/ML を製品の成長につなげる計画を立てるワークショップ AI/ML の お試し AI/ML に よるサービスの 継続的成長 ワークショップ終了後から 1~3 か月の間に、最初の効果と学びが得られる計画を アウトプットします。 プロダクトマネージャー ( 製品責任者 ) 、開発者、データサイエンティストが組織 横断で参加し、経営層の支持のもと開催することで本番導入の確度を高めます。 参考 : プロダクトの成長をリードする生成系 AI の活用戦略 42
  39. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ML Enablement Workshop のコンテンツは すべて GitHub で公開中。 https://github.com/aws-samples/aws-ml-enablement-workshop 43 Spotify や Amazon 、 Uber など海外の データサイエンス活用事例をほぼ毎週更新。 ぜひ☆ & Watch をよろしくお願いします!
  40. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. re:Invent 2023 は 11/27 ~ 12/1 開催 44 https://reinvent.awsevents.com/
  41. © 2023, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Thank you! © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.