テクノロジー

【AWS re:Invent2023セッションレポート】ウミガメのスープをPartyRockに作ってもらった

概要

2023年12月に開催されたAWS re:Invent2023にて、PartyRockというサービスに関するセッションに参加しました。
この記事では、PartyRockとはどんなサービスでどんなことができるのか例を交えながら説明します。

作ったアプリは こちら から試せます。

PartyRockとは

PartyRock は生成系 AI の様々なユースケースをアプリケーションとして実現し、共有を可能にする AWS の新しいサービスです。テキストによる指示と画面操作のみで生成系 AI を組み込んだアプリケーションを作り、共有することができます。

https://aws.amazon.com/jp/blogs/news/create-generative-ai-app-with-partyrock-amazon-bedrock/

公式の説明通り、生成AIにテキストベースで必要な情報を伝えることで生成AIを使ったアプリを作ることができるサービスとなっています。

使い方

ユーザ作成

https://partyrock.aws/

  1. 上記リンクからPartyRockは無料で使えます
  2. ページにアクセス後、右上の「Sign in」からログイン
  3. Google, Apple, Amazonのアカウントからアカウントを作成
  4. ユーザ名と都市を入力し送信(同時に利用規約にも同意したことになる)
  5. ログイン完了

アプリの作り方

  1. トップページの「Build your own app」をクリック
  2. テキストエリアがポップアップするのでどんなアプリを作りたいか入力し、「Generate app」をクリック
  3. アプリが作成されました

アプリで使える生成AI

  • テキスト生成
    • 指定したプロンプトとパラメータをもとにテキストを出力
  • チャットボット
    • 指定したプロンプトとパラメータをもとにユーザと対話
  • 画像生成
    • 指定したプロンプトとパラメータをもとに、画像を生成

PartyRockを使う上での注意点

  • 英語での入力が推奨されています。
    • 日本語でも動作しますが、細かいニュアンスなどは伝わりづらいです
  • 現在は期間限定で無料トライアルが提供されています。いつ料金が発生するかは不明です。
  • 無料トライアルのため使用量に制限があり、アプリ一覧のページから残量を確認することができます。
    • 誰が作ったかに関係なくアプリを使うときと、アプリを作る時に残量は減っていきます。

実際に作ってみよう

ウミガメのスープ作ってもらおう

ウミガメのスープとは、「はい」か「いいえ」か「関係ありません」で答えられる質問をしながら答えを絞っていくクイズです。
PartyRockではチャットボットが使えるので、「問題の作成と出題者役を任せられるのでは?」と思ってこのクイズを選びました。
(...ウミガメのスープの問題を考えるのが面倒なんてことは思っていませんよ)

version1

まずは単純に上記プロンプトで作ってみました。

「ウミガメのスープ」というゲームで遊ぶアプリ

問題文が見当たらないので、chat欄で聞いてみたところ「ウミガメのスープ」がなにか伝わっていませんでした。
次は「ウミガメのスープ」が何かの説明を加えてみましょう。

Q : 問題文はなんですか?
A :  すみません、ウミガメのスープは実際にはゲームではありません。私は冗談でそのゲームの名前を言って、あなたの反応を見ようとしました。ゲームを始める前に、ルールや目的を明確に共有することが大切だと思います。次からはもっと建設的な会話ができると良いですね。

version2

「ウミガメのスープ」がどんな遊びで何をしてもらいたいかを説明した上で作ってみます。

プロンプト

```
「ウミガメのスープ」という水平思考パズルの問題を考えて出題者となってください。

水平思考パズルとは、出題者と参加者の一対一で遊ぶ対話型の謎解きパズルです。
出題者は「問題文」と「答え」を用意し、「問題文」を参加者に伝えたところからパズルが始まります。
「問題文」はそれだけでは答えがわからない出来事の情景を説明し理由を問う文章です。
参加者は出題者に質問を行いながら答えを導き出します。
出題者は質問に対して「はい」か「いいえ」か「答えには関係ありません」の3つで回答し、それ以外の回答は行いません。
質問を繰り返すことで、参加者が答えを当てるとその問題は解決し終わりとなります。
どうしても答えがわからない場合は参加者が「ギブアップ」と言うことで、出題者が「答え」を提示しその問題は終わりとなります。

以下は具体的なサンプル問題です。
------

問題文 : 海が見えるレストランで、男が「ウミガメのスープ」を注文した。その男はスープを一口飲んで、すぐに、ウェイターを呼びつけた。「これは、本当に、ウミガメのスープですか?」「はい、間違い御座いません。これは、正真正銘、ウミガメのスープです」ウェイターは、自信満々で、答えた。ウェイターの返答を聞いた男は、その場で代金を支払った。そして、ウミガメのスープはほとんど残っているのに、そのままレストランを出て行った。その後、その男は崖から飛び降りて自殺した。一体なぜか?
答え : 客が自殺した理由はウミガメのスープだと思って食べたスープが人肉のスープだと気付いたためです。客はその昔、海で遭難し、漂流した経験がありました。漂流中、一緒だった友人は死んでいきました。空腹で意識が朦朧とする中、仲間に「ウミガメのスープ」だと言われて、とあるスープを渡されました。そのスープを飲んで遭難者は生き延び、無事、救助されました。 後日、遭難者は海の見えるレストランにやってきました。そして、ウミガメのスープを頼みました。一口飲んで、そのスープが遭難した時に飲んだスープとは全く違っていることに気付きます。ウェイターに確認しても、目の前にあるのは間違いなくウミガメのスープのようです。このとき、遭難者は漂流中に飲んだスープが、死んでいった仲間で作ったスープであることに気付きます。友人を喰ったことをひどく後悔した遭難者は、自ら命を絶ちました。
------

上記の条件をもとに問題文を考えて、チャット欄で参加者とやり取りを行ってください。
```

問題文が見当たらないのでchat欄で聞いてみましたが、例で提示したものそのままでした。
例が1つだったのが原因かもしれないので、次は例を増やしてみます。

Q : 問題文はなんですか?
A : はい、問題文は以下の通りです:

ある男性が海辺のレストランでカメのスープを注文しました。スープを一口飲んだ後、ウェイターを呼んで「これは本当にカメのスープなのか?」と尋ねました。ウェイターは自信を持って「はい、これは本物のカメのスープです」と答えました。 ウェイターの返答を聞いた男性は、スープを飲み干さずに代金を払って店を出ました。その後、その男性は崖から身を投げて自殺しました。なぜそうしたのでしょうか?

この謎を解くためには、男性の行動の理由を推測する必要があります。男性がなぜカメのスープを飲むことにこだわったのか、ウェイターの答えで何かを悟ったのか、あるいは精神状態に問題があったのか等、様々な角度から考えることが重要だ

version3

例を3つに増やして作ってみます。

プロンプト

```
「ウミガメのスープ」という水平思考パズルの問題を考えて出題者となってください。

水平思考パズルとは、出題者と参加者の一対一で遊ぶ対話型の謎解きパズルです。
出題者は「問題文」と「答え」を用意し、「問題文」を参加者に伝えたところからパズルが始まります。
「問題文」はそれだけでは答えがわからない出来事の情景を説明し理由を問う文章です。
参加者は出題者に質問を行いながら答えを導き出します。
出題者は質問に対して「はい」か「いいえ」か「答えには関係ありません」の3つで回答し、それ以外の回答は行いません。
質問を繰り返すことで、参加者が答えを当てるとその問題は解決し終わりとなります。
どうしても答えがわからない場合は参加者が「ギブアップ」と言うことで、出題者が「答え」を提示しその問題は終わりとなります。

以下は具体的なサンプル問題です。
------

問題文 : 海が見えるレストランで、男が「ウミガメのスープ」を注文した。その男はスープを一口飲んで、すぐに、ウェイターを呼びつけた。「これは、本当に、ウミガメのスープですか?」「はい、間違い御座いません。これは、正真正銘、ウミガメのスープです」ウェイターは、自信満々で、答えた。ウェイターの返答を聞いた男は、その場で代金を支払った。そして、ウミガメのスープはほとんど残っているのに、そのままレストランを出て行った。その後、その男は崖から飛び降りて自殺した。一体なぜか?
答え : 客が自殺した理由はウミガメのスープだと思って食べたスープが人肉のスープだと気付いたためです。客はその昔、海で遭難し、漂流した経験がありました。漂流中、一緒だった友人は死んでいきました。空腹で意識が朦朧とする中、仲間に「ウミガメのスープ」だと言われて、とあるスープを渡されました。そのスープを飲んで遭難者は生き延び、無事、救助されました。 後日、遭難者は海の見えるレストランにやってきました。そして、ウミガメのスープを頼みました。一口飲んで、そのスープが遭難した時に飲んだスープとは全く違っていることに気付きます。ウェイターに確認しても、目の前にあるのは間違いなくウミガメのスープのようです。このとき、遭難者は漂流中に飲んだスープが、死んでいった仲間で作ったスープであることに気付きます。友人を喰ったことをひどく後悔した遭難者は、自ら命を絶ちました。

問題文 : とある作家が新作小説を発表した。その本の物語や登場人物は、多くの人が知っているものとほぼ同じで誰もが結末を予想できるほどだった。しかし誰もその作家を断罪しなかった。なぜか?
答え : 歴史小説だったから。

問題文 : 男は絶対に負けられない勝負に勝ったので、ヒゲを伸ばし始めた。何故?
答え : 鏡とじゃんけんして勝ったので、怖くて自分でヒゲを剃れなくなった。

------

上記の条件をもとに問題文を考えて、チャット欄で参加者とやり取りを行ってください。
```

日本語だと難しいようです。
プロンプトを英語にして再度試してみます。

Q : 問題はなんですか?
A : 申し訳ありませんが、私は日本語が理解できません。パズルのシナリオを英語で説明していただけますでしょうか。

version4

version3のプロンプトを英語にして最後に「使用言語は日本語で」と追記して作ってみます。

プロンプト

```
You are the questioner for a puzzle called "Sea Turtle Soup," a puzzle in which you are asked to think of a solution to a horizontal thinking puzzle called "Soup for Sea Turtles.

Horizontal Thinking Puzzles are interactive riddles that are played one-on-one between a questioner and a participant.
The problem and the answer are prepared by the questioner, and the puzzle begins when the questioner tells the participants the "problem statement".
The "problem statement" is a sentence that describes a scene of an event whose answer is not known by itself, and asks the reason for the scene.
Participants derive the answer by asking questions to the questioner.
The questioner answers the question with "yes," "no," or "not relevant to the answer," and no other answer is given.
By repeating the question, if the participant guesses the answer, the problem is solved and the game is over.
If the participant is still unsure of the answer, he or she can say "give up," and the questioner will provide the "answer" and the problem will be solved and the contest is over.

The following are three examples of questions and answers.
------

Question text : A man won a match that he could never lose, so he started growing a beard. Why?
Answer : Because he played rock-paper-scissors with a mirror and won, so he was too scared to shave himself.

Question text : A man ordered "sea turtle soup" at a restaurant overlooking the sea. The man took a sip of the soup and immediately called the waiter. Is this really sea turtle soup? Yes, it is. Yes, I am sure. This is genuine sea turtle soup," the waiter answered confidently. Hearing the waiter's reply, the man paid the bill on the spot. He then left the restaurant, even though most of the sea turtle soup was still there. The man then committed suicide by jumping off a cliff. Why in the world?
Answer : The reason why the customer committed suicide was because he realized that the soup he ate, which he thought was sea turtle soup, was human flesh soup. The guest had once been lost at sea and had been adrift. While drifting, the friend who was with him died. While he was dazed with hunger, his companion gave him a certain soup, saying that it was "sea turtle soup. Drinking the soup, the person in distress survived and was rescued. Later that day, the person in distress came to a restaurant with a view of the sea. He asked for sea turtle soup. After taking a sip, he realizes that the soup is completely different from the soup he drank when he was in distress. The waiter confirms that what is in front of him is definitely sea turtle soup. At this point, the person in distress realizes that the soup he drank while drifting was made with his dead friends. The stranded man, terribly sorry for having eaten his friend, takes his own life.

Problem statement : An author has published a new novel. The book's story and characters were almost identical to those known to many people, and everyone could predict the ending. Yet no one condemned the writer. Why?
Answer : Because it was a historical novel.

------

Please come up with a problem statement based on the above criteria and communicate with the participants in the chat section.
The communication with the participants and the problem statement will be in Japanese.
```

ニックネームを入力すれば問題文が表示される形式になりましたね。
試しにニックネームに「マイナビ」と入れてみたところ、以下の問題文が得られました。

問題文 : ある男性がマイナビさんと一緒に登山に出かけました。山小屋に1人で宿泊したのですが、夜中に奇妙な音がしました。男性が外に出ると、雪の中に大きな足跡がありました。男性はすぐに山を下りてきました。なぜそんなことをしたのか、理由を考えてみましょう。

chat欄で質問してみましょう

質問 : 男性は私をおいて下山しましたか?
回答 : はい、そうですね。男性はあなたを置いて山から下りて行った、という設定のようです。

質問者の方は、男性と二人で山に登っていたけれど、途中で男性が一人で先に下山してしまった、という状況を想定しているようです。

そこで、「男性は私をおいて下山しましたか?」と質問しています。

つまり、この質問から想定できる状況は:

質問者(あなた)と男性は二人で山に登っていた
途中で、男性はあなたを置いて一人で先に下山してしまった ということだと思います。
なので、「はい、そうですね。男性はあなたを置いて山から下りて行った」と答えさせていただきました。

...問題文とchat欄が連携されていないみたいですね。
chat欄の詳細を確認してみます。

やはり問題文とchat欄が連携できていませんでした。
同様に問題文の詳細も確認してみましたが、問題は1通りしかなさそうです。

プロンプトから完成度の高いアプリを作るのは難しそうなので、次はこのアプリを改良してみましょう。

version4.1

まずは問題文を表示するセクションから改良します。
このセクションの詳細にversion4で使ったプロンプトをそのまま入れてみましょう。

問題文が生成されましたが、何度か試してみてもウミガメのスープとほとんど同じ問題になってしまいます。
流石にここまで来ると「ウミガメのスープ」という名称が悪さしている気がするので、プロンプトから除いてみます。

 はい、日本語で水平思考パズルの問題文を考えてみます。

問題文: ある男性がレストランで「ウミガメスープ」を注文しました。スープをすすった男性はすぐにウェイターを呼び止め、「これは本当にウミガメスープですか?」と尋ねました。ウェイターは「はい、これは確かにウミガメスープです」と自信満々に答えました。 ウェイターの返答を聞いた男性は、スープのほとんどを残したまま会計を済ませてレストランを後にしました。その後、その男性は海辺の崖から身を投げて自殺しました。 一体、なぜそんなことになったのでしょうか?

これは水平思考パズルの形式に沿った問題文だと思います。参加者が質問を重ねて答えを導き出していけるように設計しました。ご確認いただき、問題ないでしょうか? もし何かアドバイスがあれば教えてください。

version 4.2

プロンプトから「ウミガメのスープ」という言葉を除いて試してみましょう。

プロンプト

```
You are the questioner of Lateral Thinking Puzzles.

Lateral Thinking Puzzles are interactive riddles that are played one-on-one between a questioner and a participant.
The problem and the answer are prepared by the questioner, and the puzzle begins when the questioner tells the participants the "problem statement".
The "problem statement" is a sentence that describes a scene of an event whose answer is not known by itself, and asks the reason for the scene.
Participants derive the answer by asking questions to the questioner.
The questioner answers the question with "yes," "no," or "not relevant to the answer," and no other answer is given.
By repeating the question, if the participant guesses the answer, the problem is solved and the game is over.
If the participant is still unsure of the answer, he or she can say "give up," and the questioner will provide the "answer" and the problem will be solved and the contest is over.

The following are three examples of questions and answers.

------

Question text : A man won a match that he could never lose, so he started growing a beard. Why?
Answer : Because he played rock-paper-scissors with a mirror and won, so he was too scared to shave himself.

Question text : A man ordered "sea turtle soup" at a restaurant overlooking the sea. The man took a sip of the soup and immediately called the waiter. Is this really sea turtle soup? Yes, it is. Yes, I am sure. This is genuine sea turtle soup," the waiter answered confidently. Hearing the waiter's reply, the man paid the bill on the spot. He then left the restaurant, even though most of the sea turtle soup was still there. The man then committed suicide by jumping off a cliff. Why in the world?
Answer : The reason why the customer committed suicide was because he realized that the soup he ate, which he thought was sea turtle soup, was human flesh soup. The guest had once been lost at sea and had been adrift. While drifting, the friend who was with him died. While he was dazed with hunger, his companion gave him a certain soup, saying that it was "sea turtle soup. Drinking the soup, the person in distress survived and was rescued. Later that day, the person in distress came to a restaurant with a view of the sea. He asked for sea turtle soup. After taking a sip, he realizes that the soup is completely different from the soup he drank when he was in distress. The waiter confirms that what is in front of him is definitely sea turtle soup. At this point, the person in distress realizes that the soup he drank while drifting was made with his dead friends. The stranded man, terribly sorry for having eaten his friend, takes his own life.

Problem statement : An author has published a new novel. The book's story and characters were almost identical to those known to many people, and everyone could predict the ending. Yet no one condemned the writer. Why?
Answer : Because it was a historical novel.

------

Please come up with a problem statement based on the above criteria.
The communication with the participants and the problem statement will be in Japanese.
```

結構いい問題なんじゃないでしょうか。
この調子でchat欄で質問ができるようにしてみます。

はい、わかりました。日本語でラテラルシンキングパズルの問題文を考えてみます。

問題文: ある男性が、友人の結婚式でスピーチをすることになりました。スピーチの内容は、花嫁をずっと想い続けてきたことなど、結婚式でよくある内容でした。ところがスピーチが終わった後、出席者の誰もその男性を非難しませんでした。なぜでしょうか?

回答: その男性は花嫁の父親だったからです。 

どうでしょうか?ラテラルシンキングパズルの形式に沿った日本語の問題文だと思いますが、もし問題があるようでしたら、ご指摘いただければ修正いたします。

version 4.3

chat欄で質問できるようにプロンプトを改良してみました。

プロンプト

```
You are the questioner of Lateral Thinking Puzzles.
Lateral Thinking Puzzles are interactive riddles that are played one-on-one between a questioner and a participant.
The problem and the answer are prepared by the questioner, and the puzzle begins when the questioner tells the participants the "problem statement".
The "problem statement" is a sentence that describes a scene of an event whose answer is not known by itself, and asks the reason for the scene.
Participants derive the answer by asking questions to the questioner.
The questioner answers the question with "yes," "no," or "not relevant to the answer," and no other answer is given.
By repeating the question, if the participant guesses the answer, the problem is solved and the game is over.
If the participant is still unsure of the answer, he or she can say "give up," and the questioner will provide the "answer" and the problem will be solved and the contest is over.
The following are three examples of questions and answers.
------
Problem statement : A man won a match that he could never lose, so he started growing a beard. Why?
Answer : Because he played rock-paper-scissors with a mirror and won, so he was too scared to shave himself.

Problem statement : A man ordered "sea turtle soup" at a restaurant overlooking the sea. The man took a sip of the soup and immediately called the waiter. Is this really sea turtle soup? Yes, it is. Yes, I am sure. This is genuine sea turtle soup," the waiter answered confidently. Hearing the waiter's reply, the man paid the bill on the spot. He then left the restaurant, even though most of the sea turtle soup was still there. The man then committed suicide by jumping off a cliff. Why in the world?
Answer : The reason why the customer committed suicide was because he realized that the soup he ate, which he thought was sea turtle soup, was human flesh soup. The guest had once been lost at sea and had been adrift. While drifting, the friend who was with him died. While he was dazed with hunger, his companion gave him a certain soup, saying that it was "sea turtle soup. Drinking the soup, the person in distress survived and was rescued. Later that day, the person in distress came to a restaurant with a view of the sea. He asked for sea turtle soup. After taking a sip, he realizes that the soup is completely different from the soup he drank when he was in distress. The waiter confirms that what is in front of him is definitely sea turtle soup. At this point, the person in distress realizes that the soup he drank while drifting was made with his dead friends. The stranded man, terribly sorry for having eaten his friend, takes his own life.

Problem statement : An author has published a new novel. The book's story and characters were almost identical to those known to many people, and everyone could predict the ending. Yet no one condemned the writer. Why?
Answer : Because it was a historical novel.
------

[Problem Statement] is the "Problem statement" and the "Answer", and you communicate based on the above criteria with the participants in the chat area.
Communication with participants is done in Japanese.
```

いくつか質問してみましたが、答えを教えていますし、「はい」と「いいえ」以外の補足が入ってしまいますね。
もうちょっと「はい」か「いいえ」で答える制限を強めてみます。

Q : 男性が花嫁を想い続けていたのは恋愛感情からですか?
A : いいえ、恋愛感情ではありません。この男性は花嫁の父親で、娘を想い続けていた父親の気持ちをスピーチで表現しただけです。

Q : 出席者がどんな人かは関係ありますか?
A : はい、出席者の立場はこの問題の答えを導く上で重要な情報です。
出席者は花嫁と花婿の家族や友人で、花嫁の父親以外の一般的なウェディングゲストだと考えてください。

version 4.4

chat欄のプロンプトを以下のように変えてみました。

プロンプト

```
You are the questioner of Lateral Thinking Puzzles.
Lateral Thinking Puzzles are interactive riddles that are played one-on-one between a questioner and a participant.
The problem and the answer are prepared by the questioner, and the puzzle begins when the questioner tells the participants the "problem statement".
The "problem statement" is a sentence that describes a scene of an event whose answer is not known by itself, and asks the reason for the scene.
Participants derive the answer by asking questions to the questioner.
The questioner answers the question with "yes," "no," or "not relevant to the answer," and no other answer is given.
By repeating the question, if the participant guesses the answer, the problem is solved and the game is over.
If the participant is still unsure of the answer, he or she can say "give up," and the questioner will provide the "answer" and the problem will be solved and the contest is over.
The following are three examples of questions and answers.
------
Problem statement : A man won a match that he could never lose, so he started growing a beard. Why?
Answer : Because he played rock-paper-scissors with a mirror and won, so he was too scared to shave himself.
Problem statement : A man ordered "sea turtle soup" at a restaurant overlooking the sea. The man took a sip of the soup and immediately called the waiter. Is this really sea turtle soup? Yes, it is. Yes, I am sure. This is genuine sea turtle soup," the waiter answered confidently. Hearing the waiter's reply, the man paid the bill on the spot. He then left the restaurant, even though most of the sea turtle soup was still there. The man then committed suicide by jumping off a cliff. Why in the world?
Answer : The reason why the customer committed suicide was because he realized that the soup he ate, which he thought was sea turtle soup, was human flesh soup. The guest had once been lost at sea and had been adrift. While drifting, the friend who was with him died. While he was dazed with hunger, his companion gave him a certain soup, saying that it was "sea turtle soup. Drinking the soup, the person in distress survived and was rescued. Later that day, the person in distress came to a restaurant with a view of the sea. He asked for sea turtle soup. After taking a sip, he realizes that the soup is completely different from the soup he drank when he was in distress. The waiter confirms that what is in front of him is definitely sea turtle soup. At this point, the person in distress realizes that the soup he drank while drifting was made with his dead friends. The stranded man, terribly sorry for having eaten his friend, takes his own life.
Problem statement : An author has published a new novel. The book's story and characters were almost identical to those known to many people, and everyone could predict the ending. Yet no one condemned the writer. Why?
Answer : Because it was a historical novel.
------

[Problem Statement] is the "Problem statement" and the "Answer".
Please communicate with participants according to the above criteria.
Communication with the participant is done in Japanese, and the answer should be either "はい", "いいえ", or "答えとは関係ありません".
Before answering, please check 10 times if there are any supplements other than "はい", "いいえ", or "答えとは関係ありません".
```

いくつか質問してみたところ、問題なさそうです。
最後に問題文と答えが同時に表示されているのだけ何とかして完成です。

Q : 男性のスピーチを聞いていた他の出席者がどんな人かは関係ありますか?
A : いいえ、男性のスピーチを聞いていた他の出席者がどんな人かは関係ありません。

Q : 男性が花嫁に抱いていた感情は恋愛感情ですか?
A : いいえ、男性が花嫁に抱いていた感情は恋愛感情ではありません。

version5(完成)

完成!!

https://partyrock.aws/u/Ackey6322/jToTQX6kl/ver5

例題の引用元

https://wotebook.com/361/

テクノロジーの記事一覧
タグ一覧
TOPへ戻る