Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon Bedrock Beginners Handson の追加 #69

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions README.md
Expand Up @@ -15,6 +15,8 @@ AWS で機械学習をはじめる方法を学ぶことができるリポジト
* 画像のセグメンテーションや物体検知、自然言語処理のQAや要約など、個別具体的なタスクを SageMaker でどのように解けるか学ぶためのコンテンツ。
* `solutions`
* 製造業での異常検知モニタリングやコールセンターの問合せ分析など、特定の業務プロセスを効率化/差別化したい方が、 SageMaker と他のサービスを組み合わせどのようにソリューションを構築できるか学ぶためのコンテンツ。
* `bedrock`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sagemaker の下に入れたいです。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazon Bedrock と SageMaker は目的や機能が異なるサービスなので、それぞれを別個に扱うこと方が適切だと思います。

* 生成 AI を使ったアプリケーション開発を検討されている方が、Amazon Bedrock を使って実現するための方法を学ぶためのコンテンツ。

## :hamburger: AWSの機械学習サービス

Expand Down Expand Up @@ -91,6 +93,14 @@ Amazon SageMaker で機械学習の構築、学習、デプロイをスケール
* [Amazon SageMaker Processing と AWS Step Functions でモデルの学習・評価・更新プロセスを構築する](./sagemaker/mlops/step-functions-data-science-sdk/step_functions_mlworkflow_scikit_learn_data_processing_and_model_evaluation_with_experiments.ipynb)
* [Amazon SageMaker Processing と AWS Step Functions でモデルの学習・評価・更新プロセスを構築する (Studio 版 )](./sagemaker/mlops/step-functions-data-science-sdk/studio_step_functions_mlworkflow_scikit_learn_data_processing_and_model_evaluation_with_experiments.ipynb)

### [Amazon Bedrock](https://aws.amazon.com/jp/bedrock/)
生成 AI を使ったアプリケーションを、構築・運用するための基盤となるサービス

#### サンプル
| No | Title | Description | Content |
|:-------| :-----------| :---- | :---- |
| 1 | Amazon Bedrock Beginners Handson | Amazon Bedrock を初めて触る方向けに、質問回答や要約の作成など基盤モデルのユースケースをお試しいただけるような Notebook コンテンツを提供します。 | [![Jupyter Notebook](https://img.shields.io/badge/jupyter-%23FA0F00.svg?style=for-the-badge&logo=jupyter&logoColor=white)](./bedrock/bedrock-beginners-handson/README.md)

### 🚚 ML Frameworks

機械学習フレームワークの実装を SageMaker へ移行する。
Expand Down Expand Up @@ -134,7 +144,8 @@ AWS で画像処理や自然言語処理などの機械学習のタスクを解
* [細胞診 (FNA) 結果からの乳がん診断](./tasks/tabular/classification/BreastCancerPrediction_R.ipynb)


#### 🤖 生成系 AI
#### 🤖 生成 AI


##### `text-to-image`

Expand All @@ -143,7 +154,7 @@ AWS で画像処理や自然言語処理などの機械学習のタスクを解
| [Stable Diffusion Web UI](./tasks/generative-ai/text-to-image/inference/stable-diffusion-webui/) | Stable Diffusion の GUI として人気の [AUTOMATIC1111/stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) を EC2 インスタンスに立てて利用できるようにする CloudFormation です。モデルのトレーニングに [bmaltais/kohya_ss](https://github.com/bmaltais/kohya_ss)、GUI ベースのファイル操作に [filebrowser/filebrowser](https://github.com/filebrowser/filebrowser) を立ち上げる構成も含まれています。SageMaker JumpStart を利用した Fine Tuning については [たった数枚の画像で Stable Diffusion をファインチューニングできる効率的な Amazon SageMaker JumpStart の使い方](https://aws.amazon.com/jp/blogs/news/machine-learning-inpaint-images-with-stable-diffusion-using-amazon-sagemaker-jumpstart/) をご参照ください。 |
| [Inpainting](./tasks/generative-ai/text-to-image/inference/Transformers/StableDiffusionInpainting_Inference_with_ClipSeg.ipynb) | 画像の一部を生成した画像で差し替えるサンプルです。差し替える箇所 ( マスク ) の作成には [CLIPSeg](https://huggingface.co/docs/transformers/model_doc/clipseg) を使用しています。詳細は [Stable Diffusion で画像の部分的な差し替えを行う環境を、 Amazon SageMaker JumpStart で簡単に構築する](https://aws.amazon.com/jp/blogs/news/machine-learning-inpaint-images-with-stable-diffusion-using-amazon-sagemaker-jumpstart/) をご参照ください。|

#### `text-to-text`
##### `text-to-text`

| サンプルコード | 詳細 |
|:-------| :-----------|
Expand All @@ -155,7 +166,7 @@ AWS で画像処理や自然言語処理などの機械学習のタスクを解
SageMaker と他のサービスを組み合わせ、業務プロセスの効率化や差別化を行うためのソリューションを格納/紹介します。

* [JP RAG SOLUTION](https://github.com/aws-samples/jp-rag-sample)
* カスタマーサポートなどで生成系 AI を利用する場合、自然な応答による顧客体験の改善が期待できるものの、誤った発言 ( ハルシネーション ) が発生する恐れがあります。生成元のドキュメントを指定することで誤った発言を抑止することができ、検索エンジンから生成系 AI にドキュメントを与え生成する仕組みを RAG と呼びます。本ソリューションでは、検索エンジンとして `Amazon Kendra` 、生成系 AI として `Anthropic Claude` / [`rinna/japanese-gpt-neox-3.6b-instruction-ppo`](https://huggingface.co/rinna/japanese-gpt-neox-3.6b-instruction-ppo) を用いて RAG を実現します。
* カスタマーサポートなどで生成 AI を利用する場合、自然な応答による顧客体験の改善が期待できるものの、誤った発言 ( ハルシネーション ) が発生する恐れがあります。生成元のドキュメントを指定することで誤った発言を抑止することができ、検索エンジンから生成 AI にドキュメントを与え生成する仕組みを RAG と呼びます。本ソリューションでは、検索エンジンとして `Amazon Kendra` 、生成 AI として `Anthropic Claude` / [`rinna/japanese-gpt-neox-3.6b-instruction-ppo`](https://huggingface.co/rinna/japanese-gpt-neox-3.6b-instruction-ppo) を用いて RAG を実現します。
* 参考記事: [高精度な生成系 AI アプリケーションを Amazon Kendra、LangChain、大規模言語モデルを使って作る](https://aws.amazon.com/jp/blogs/news/quickly-build-high-accuracy-generative-ai-applications-on-enterprise-data-using-amazon-kendra-langchain-and-large-language-models/)
* [コールセンターのリアルタイム会話分析](https://aws.amazon.com/jp/blogs/news/live-call-analytics-and-agent-assist-for-your-contact-center-with-amazon-language-ai-services/)
* コールセンターで会話の文字起こし、翻訳、感情分析、会話内容の要約、オペレーターへのアドバイスをリアルタイムで行うソリューションです。文字起こしは `Amazon Transcribe` 、翻訳は `Amazon Translate` 、 感情分析は `Amazon Comprehend` 、 要約は `Amazon SageMaker` 、 アドバイスは `Amazon Lex` と `Amazon Kendra` で実装しています。
Expand Down
34 changes: 34 additions & 0 deletions bedrock/bedrock-beginners-handson/README.md
@@ -0,0 +1,34 @@
# bedrock-beginners-handson

このリポジトリでは、Amazon Bedrock を初めて触る方向けに、Amazon Bedrock をお試しいただけるような Notebook コンテンツを提供します。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazon Bedrock へのはじめ方などへリンク飛ばしましょうか。最初ならまずセットアップの方法がいるかと。

https://speakerdeck.com/icoxfog417/amazon-bedrock-nohazimefang

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます。確かに入門者向けの解説記事は参考になりますね。ただ、情報が古くなる可能性もあるので、まずはAWS公式ドキュメントのページへリンクを貼ろうと思います。

以下の 3 つのコンテンツを提供予定です。
なお、Amazon Bedrock を利用する際にはモデルの有効化手続きが必要になります。[Amazon Bedrock をセットアップする](https://docs.aws.amazon.com/ja_jp/bedrock/latest/userguide/setting-up.html)の手順をもとにセットアップをお願いします。

## Chapter1: 基盤モデルの基本的な呼び出し
[![Jupyter Notebook](https://img.shields.io/badge/jupyter-%23FA0F00.svg?style=for-the-badge&logo=jupyter&logoColor=white)](./chapter1_introduction.ipynb)
このチャプターでは、Python SDK を用いて Amazon Bedrock 上の基盤モデルを呼び出す方法をご紹介します。

## Chapter2: プロンプトエンジニアリング (作成中)
このチャプターでは実際に基盤モデルを使って、会社の宣伝メールやスローガンを生成するような仕組みを作ります。

## Chapter3: RAG 入門 (作成中)
このチャプターでは、検索拡張生成(Retrieval Augmented Generation) の仕組みや実装方法をご紹介します。

# 始めるにあたっての準備

このハンズオンでは SageMaker Notebook Instance での実行を前提とします。
ノートブックインスタンスに対して、Bedrock の呼び出しを許可するため、次のような Bedrock Full Access 権限を実行ロールに付与してください。

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