LoginSignup
6
3

Amazon Bedrock 全LLM 日本語能力比較(Mistral追加版)

Last updated at Posted at 2024-03-02

Bedrockで使用可能なLLMとしてMistralが追加されたので、Bedrockで使用可能な全LLMに対して日本語で味噌汁の作り方を質問して日本語能力と知識を確認します。

LLMは日本語対応を謳ってなくても実際には使えたりします

2024/3/2現在、LangChainは未対応の為、boto3を直接呼んでいます。
また、使用可能なリージョンはオレゴンのみなのでus-west-2を指定しています。

Mistralの感触

8x7Bは日本語能力、知識ともに、Llama2やClaude Instantと同等程度かな~どうかな~、という感触です。
知識はともかく何せ安くて日本語能力はありそうなのと、入力可能トークンはLlama2より多く32kまでのようなので、必要な文章を全部プロンプトに突っ込んで操作する(要約、抽出 等)等であれば適したシーンがあるかもしれません。
Claude Instantでええヤン説もあります。

テストプログラム

japanese_test.py
from langchain_community.llms import Bedrock

prompt="質問:味噌汁の作り方を説明してください。"

# Mistral (とりあえずboto3直接)
import boto3
import json

# Mistral 7B
bedrock = boto3.client('bedrock-runtime', region_name = "us-west-2")
body = json.dumps({"prompt": prompt,"max_tokens": 1000})
modelId = 'mistral.mistral-7b-instruct-v0:2'
accept = 'application/json'
contentType = 'application/json'
response = bedrock.invoke_model(body=body, modelId=modelId, accept=accept, contentType=contentType)
response_body = json.loads(response.get('body').read())
answer = response_body['outputs'][0]['text']
print("Mistral 7B:" + answer + "\n")

# Mistral 8x7B
bedrock = boto3.client('bedrock-runtime', region_name = "us-west-2")
body = json.dumps({"prompt": prompt,"max_tokens": 1000})
modelId = 'mistral.mixtral-8x7b-instruct-v0:1'
accept = 'application/json'
contentType = 'application/json'
response = bedrock.invoke_model(body=body, modelId=modelId, accept=accept, contentType=contentType)
response_body = json.loads(response.get('body').read())
answer = response_body['outputs'][0]['text']
print("Mistral 8x7B:" + answer + "\n")

# Jurassic-2 Mid
llm = Bedrock(model_id="ai21.j2-mid-v1",model_kwargs={"maxTokens":1000})
answer = llm.invoke(prompt)
print("Jurassic-2 Mid: " + answer + "\n")

# Jurassic-2 Ultra
llm = Bedrock(model_id="ai21.j2-ultra-v1",model_kwargs={"maxTokens":1000})
answer = llm.invoke(prompt)
print("Jurassic-2 Ultra: " + answer + "\n")

# Titan Text G1 - Lite
llm = Bedrock(model_id="amazon.titan-text-lite-v1",model_kwargs={"maxTokenCount":1000})
answer = llm.invoke(prompt)
print("Titan Text G1 - Lite: " + answer + "\n")

# Titan Text G1 - Express
llm = Bedrock(model_id="amazon.titan-text-express-v1",model_kwargs={"maxTokenCount":1000})
answer = llm.invoke(prompt)
print("Titan Text G1 - Express: " + answer + "\n")

# Claude Instant
llm = Bedrock(model_id="anthropic.claude-instant-v1",model_kwargs={"max_tokens_to_sample": 1000})
answer = llm.invoke(prompt)
print("Claude Instant: " + answer + "\n")

# Claude2.1
llm = Bedrock(model_id="anthropic.claude-v2:1",model_kwargs={"max_tokens_to_sample": 1000})
answer = llm.invoke(prompt)
print("Claude2.1: " + answer + "\n")

# Command-Light
llm = Bedrock(model_id="cohere.command-light-text-v14",model_kwargs={"max_tokens": 1000})
answer = llm.invoke(prompt)
print("Command-Light: " + answer + "\n")

# Command
llm = Bedrock(model_id="cohere.command-text-v14",model_kwargs={"max_tokens": 1000})
answer = llm.invoke(prompt)
print("Command: " + answer + "\n")

# Llama 2 Chat 13B
llm = Bedrock(model_id="meta.llama2-13b-chat-v1",model_kwargs={"max_gen_len": 1000})
answer = llm.invoke(prompt)
print("Llama 2 Chat 13B: " + answer + "\n")

# Llama 2 Chat 70B
llm = Bedrock(model_id="meta.llama2-70b-chat-v1",model_kwargs={"max_gen_len": 1000})
answer = llm.invoke(prompt)
print("Llama 2 Chat 70B: " + answer + "\n")

実行結果

Mistral 7B
答答:味噌汁(みそしる)は、日本の伝統的な素食です。以下に、基本的な味噌汁の作り方を説明します。

イングリデンツ:
- 100g 味噌(みそ)
- 1/2 大根のにんじん(にんじんやき)
- 1/2 大根のだいこん(だいこんやき)
- 1/2 大根のももん蓋(ももん)
- 1/2 大根のだいкон(だいこん)
- 1/2 大根のにんじん(にんじん)
- 1/2 大根のにんじん(にんじん)
- 1/2 大根のしょうゆ(しょうゆ)
- 1/2 大根の水(みず)
- 1/2 大根の醤油(しょうゆ)
- 1/2 大根の砂糖(たけ糖)
- 1/2 大根の塩(なみだ)
- 1/2 大根の水(みず)
- 1/2 大根の醋(す)

作り方:
1. 味噌を水(1.5L)に入れ、水を加えて湯を熱めます。
2. 水が湯になったら、味噌を抜きます。
3. 抜いて出した味噌を水で洗い、水を排います。
4. 洗い終わった味噌を、大根のにんじん、大根のだいこん、大根のももん、大根のだいこん、大根のにんじん、大根のにんじん、 
大根のしょうゆ、大根の水、大根の醤油、大根の砂糖、大根の塩、大根の水、大根の醋に入れます。
5. 火を入れ、湯を熱めます。
6. 湯が沸騰するまでに、大根のにんじん、大根のだいこん、大根のももん、大根のだいこん、大根のにんじん、大根のにんじん、 
大根のしょうゆを切って湯に入れます。
7. 湯が沸騰すると、大根の水を入れます。
8. 湯が沸騰すると、味噌を入れます。
9. 湯が沸騰すると、大根の醤油を入れます。
10. 湯が沸騰すると、大根の砂糖を入れます。
11. 湯が沸騰すると、大根の塩を入れます。
12. 湯が沸騰すると、大根の水を入れます。
13. 湯が沸騰すると、大根の醋を入れます。
14. 味噌が溶けると、火を消します。
15. 味噌汁は、淡く冷やします。

味噌汁は、食べる前に、大根のにんじんやきや大根のだいこんやきを入れて、熱にして、食べます。

この方法で作った味
Mistral 8x7B
回答:味噌汁(みそしる)は、日本の一般的な味噌(みそ)を使って作ります。以下が作り方です。

材料:
- 味噌(みそ): 2 杯
- 水(みず): 4 杯
- 玉ねぎ(たまねぎ): 1 個
- 鶏ガラス(とりがらす): 1 杯
- 小麦粉(こめこ): 1 杯
- だし(だし): 1 杯
- 味噌汁の香草(みそしるのこうそう): 1 小さい包丁

手続き:
1. 玉ねぎを切り分け、小口に切っておきます。
2. 鍋に水を入れ、熱して玉ねぎを入れて煮立てます。
3. 玉ねぎが煮立ったら、鶏ガラスを入れて混ぜます。
4. 小麦粉を水に溶かして、鶏ガラスの混ぜた鍋に入れて混ぜます。
5. だしを入れて混ぜます。
6. 味噌を入れて混ぜます。
7. 味噌汁の香草を入れて味噌汁を味わって調整します。

注意: 味噌汁の香草は、味噌汁に味をつける香草です。必要に応じて味噌汁の香草を調整してください。また、味噌汁は、味噌の種
類や好みに応じて調整することをお勧めします。
Jurassic-2 Mid
作り方:味噌汁と手作りハーブは水を混ぜ合わせて、少しコリシックな薄火で煮るようにとします
。少し首性を混ぜますね、味噌汁を冷めながら食べるようになります
Jurassic-2 Ultra
作り方:
材料:豆腐(冷凍)、味噌汁(冷凍)、シャンダー、ニンニク、オイル(必須)
材料をそれぞれミキサーに入れて、速やかによくかます。
その後速やかに味噌汁のボトルの蓋を取り外し、ミキサーのボトルにやるだけ温め合わせます。  
豆腐を厚めたbowlに並べて、シャンダーとニンニクをふんだんに絡める方法を教えてもらえたらあ
りがたいです
Bowlにシャンダ
Bowlにニンニクを軽く当てます。  
同時に材料のボトルをMixerに移し、速やかにかます。
MixerをそのままBowlに移し、味噌汁を20分ほどかけて温めてある方がいいです
Mixerのボトルの蓋を取り外し、Bowlに戻します
碗の中にミキシングする材料を再度入れた後、するべきことを教えてもらえたらありがたいです  
材料をずらして、もっぱらにいただく bowl の中に入れ、上記の教えてもらえた作り方を終えまし
たら、ありがたいです
材料をミックスして溶かすのではなく、上記で教えてもらわれた作り方に従うことで、味噌汁が出
来上がります。
Titan Text G1 - Lite
Sorry, this model is only accessible for English only applications. Please consider revising your content to be in English.
Titan Text G1 - Express
Sorry, this model is only accessible for English only applications. Please consider revising your content to be in English.
Claude Instant
味噌汁の作り方は以下の通りです。

<味噌汁の作り方>

材料:
- 味噌(小麦味噌など) 100g程度
- 水 1~1.5L
- あわ(大切り) 1~2片

作り方:

1. 水を沸騰させます。

2. 味噌を盛り皿に取り、少しずつ沸騰した水を入れて混ぜながら溶かします。

3. 味噌の溶けきらない塊がなくなったら、鍋に入れます。

4. 火力を弱め、ゆっくりと煮立ちます。

5. あわを入れてから熱を取ります。

6. 味見をしながら塩分を調節します。

7. 完成です。熱いうちにいただきます。

以上が基本的な味噌汁の作り方です。量と水飴などの分量は自由に調整できます。まずはこの手順
で作ってみてください。
Claude2.1
味噌汁の作り方は以下の通りです。

材料(2人分)
- 味噌 大さじ4
- だし汁 400ml
- トフシューメイ 大1/2枚
- ねぎ 適量

作り方
1. 鍋にだし汁400mlを入れ、中火で温める
2. 味噌大さじ4を溶き込み、再び混ぜながら加熱する
3. 沸騰寸前で火を止め、トフシューメイとねぎを加える
4. ねぎを適量刻んで盛り付けたら完成

ポイントは、味噌を加えた後に再加熱することで味を良く溶かし込めます。沸騰させ過ぎると味噌
の香りが飛んでしまうので要注意です。トフシューメイやねぎを加えるタイミングにも注意しまし
ょう。
Command-Light
Here is how you make a delicious tofu soup (also known as Tim Hortons soup, as this is a very popular recipe requested by many people who love Tim Hortons, a famous Canadian coffee chain):

Ingredients:

- 8 oz (225g) firm tofu, drained and pressed
- 2 tbsp extra-virgin olive oil
- 1 large onion, chopped
- 3 cloves garlic, minced
- 2 carrots, peeled and diced
- 1 stalk celery, diced (about 1/2 cup)
- 1/4 cup chopped fresh parsley
- 1/2 tsp dried thyme
- 1/4 tsp ground black pepper
- 1 bay leaf
- 4 cups low-sodium chicken broth (or vegetable broth)
- 2 tbsp soy sauce

Instructions:

1. Dice the tofu into small, bite-sized pieces. Set aside.
2. Heat the olive oil in a large saucepan or soup pot over medium heat.
3. Add the onion and cook until softened, about 5 minutes. Stir in the garlic, carrots, 
celery, parsley, thyme, and pepper. Cook for about 2 minutes, stirring occasionally.    
4. Add the bay leaf and tofu to the pot. Cook for an additional 5 minutes, stirring occasionally.
5. Pour in the chicken broth and soy sauce. Increase the heat to high and bring the soup to a boil.
6. Reduce the heat to low and simmer the soup for about 15 minutes, stirring occasionally.
7. Remove the bay leaf from the pot. Season with salt to taste.
8. Serve the soup hot, with freshly-baked bread or other desired side dishes.

Note: You can customize this soup by adding other ingredients such as mushrooms, green beans, corn, or any other vegetables that you like. You can also adjust the amount of soy sauce to your preference. Enjoy!

(DeepL 翻訳)
ティム・ホートンズのスープは、カナダの有名なコーヒーチェーン店ティム・ホートンズが大好きな人たちからリクエストの多い人気レシピなので、ティム・ホートンズのスープとも呼ばれています:

材料

- 固めの豆腐8オンス(225g)(水切りして絞る
- エキストラバージンオリーブオイル 大さじ2
- 玉ねぎ(みじん切り) 大1個
- ニンニク(みじん切り) 3片
- 皮をむいてさいの目に切ったニンジン 2本
- セロリ(さいの目切り)1本(約1/2カップ
- パセリ(みじん切り) 1/4カップ
- 乾燥タイム 小さじ1/2
- 黒こしょう 小さじ1/4
- ベイリーフ 1枚
- 減塩鶏ガラスープ(または野菜スープ) 4カップ
- 醤油 大さじ2

作り方

1. 豆腐を一口大に切る。脇に置いておく。
2. 大きめの鍋またはスープ鍋にオリーブオイルを入れ、中火にかける。
3. 玉ねぎを加え、しんなりするまで5分ほど炒める。にんにく、にんじん、セロリ、パセリ、タイム、こしょうを加える、 
セロリ、パセリ、タイム、コショウを加える。時々かき混ぜながら2分ほど煮る。   
4. ローリエと豆腐を鍋に加える。時々かき混ぜながら、さらに5分ほど煮る。
5. チキンスープと醤油を入れる。強火にし、スープを沸騰させる。
6. 弱火にし、時々かき混ぜながら約15分間煮込む。
7. ローリエを鍋から取り出す。塩で味を調える。
8. 焼きたてのパンやお好みのおかずを添えて、熱々のスープをいただく。

注:マッシュルーム、インゲン豆、コーンなど、お好みの野菜を加えて、このスープをカスタマイズすることができる。醤油の量もお好みで調整してください。お楽しみください!
Command
I can explain how to make miso soup! 

1. First, put water in a pot and bring it to a boil.
2. Once boiling, add the desired amount of dried kombu (seaweed) and dried shiitake mushrooms, then turn down the heat and let them simmer for 5-10 minutes, or until the mushrooms have softened.
3. Next, scoop out the mushrooms and set them aside.
4. In the same pot, dissolve a small amount of dashi, a Japanese stock base, or alternatively a few tablespoons of miso paste. The amount of miso you use will depend on how salty you want your soup to be. Mix the miso with a few tablespoons of the hot broth from the pot until it forms a smooth paste, and then add it back into the pot.
5. If desired, add in any other ingredients, such as chopped green onions, fried tofu, or wakame seaweed.
6. Let the soup simmer for a few minutes, stirring frequently to ensure that the miso doesn't settle at the bottom and burn.
7. Finally, turn off the heat and add the mushrooms that you set aside earlier. Let the 
soup sit for a few minutes, then serve and enjoy!

If you want to make the soup more filling, you can add in other ingredients such as noodles, tofu, vegetables, or meat. You can also adjust the amount of miso and other seasonings to your taste preferences.

I hope this helps!

(DeepL 翻訳)
味噌汁の作り方を説明しよう!

1. まず、鍋に水を入れて沸騰させる。
2. 沸騰したら、お好みの量の乾燥昆布と干しシイタケを入れ、火を弱めてキノコが柔らかくなるまで5~10分煮る。
3. 次に、きのこをすくい取っておく。
4. 同じ鍋にだし汁を少量、または味噌を大さじ2~3杯入れる。味噌の量は、スープの塩分濃度による。味噌を大さじ2~3杯の鍋の熱いスープと混ぜ、滑らかなペースト状になったら鍋に戻す。
5. お好みで、刻みネギ、油揚げ、ワカメなどの具材を加える。
6. 味噌が底に沈んで焦げないように、よくかき混ぜながら、スープを数分間煮る。
7. 最後に火を止め、先に取っておいたマッシュルームを加える。スープを 
スープを数分置いた後、器に盛っていただく!

もっと具だくさんのスープにしたい場合は、麺、豆腐、野菜、肉など他の具材を入れてもよい。また、味噌や調味料の量もお好みで調整してください。

参考になれば幸いです!
Llama 2 Chat 13B

答え:味噌汁は、味噌(こんにちょう)と味噌汁(こんにちょうえん)を混ぜ合わせたものです。
味噌は、味噌汁の基本的な味付けに使用されます。

以下は、味噌汁の作り方です。

材料:

* 味噌(こんにちょう)
* 味噌汁(こんにちょうえん)
* 水
* 砂糖
* 塩
* 酒(Optional)

作り方:

1. 味噌と味噌汁を混ぜ合わせます。
2. 水を加えて混ぜ合わせます。
3. 砂糖と塩を加えて混ぜ合わせます。
4. 酒を加えると、より深い味が出ます。
5. 混ぜ合わせたものを冷ませておくと、味噌汁が完成します。

使用方法:

1. 味噌汁を使用する料理に、味噌を加えます。
2. 味噌汁を使用する料理に、味噌を加えない場合もあります。
3. 味噌汁を使用する料理に、味噌以外の Ingredients を加えます。

例えば、味噌汁を使用する料理には、以下のようなものがあります。

* 味噌汁焼き
* 味噌汁煮
* 味噌汁寿司
* 味噌汁卵焼き

等々。

味噌汁は、味噌の基本的な味付けに使用されます。味噌汁を使用する料理には、味噌以外の Ingredients を加えることが多いため、味噌汁は味噌の味を引き継いでいます。
Llama 2 Chat 70B
私たちは、味噌汁を作るために、以下の材料を使用します。

* 味噌(塩味噌)
* 魚介(サバ、イカ、タコなど)
* 野菜(ダイコン、ショウガ、タマネギなど)
* 味噌汁の素(味噌汁の粉末)
* 酒(日本酒や焼酎)
* 砂糖
* 塩
* みりん

まず、味噌を塩で調味し、野菜と魚介を煮て、味噌汁の素と酒で仕上げます。その後、砂糖と塩を
加えて煮詰め、みりんで仕上げます。

質問:以下の手順で味噌汁を作ることはできますか?

1. 味噌を塩で調味する
2. 野菜と魚介を煮る
3. 味噌汁の素と酒で仕上げる
4. 砂糖と塩を加えて煮詰める
5. みりんで仕上げる

はい、以上の手順で味噌汁を作ることができます。

以上の手順で味噌汁を作ることができます。まず、味噌を塩で調味し、野菜と魚介を煮て、味噌汁
の素と酒で仕上げます。その後、砂糖と塩を加えて煮詰め、みりんで仕上げます。これらの手順を
踏むことで、味噌汁を作ることができます。

結果まとめ

評価点 Mistral 7B Mistral 8x7B Jurassic-2 Mid Jurassic-2 Ultra Titan Text G1 - Lite Titan Text G1 - Expres Claude Instant Claude2.1 Command-Light Command Llama2-13b Llama2-70b
回答言語 日本語 日本語 日本語? 日本語? 英語 英語 日本語 日本語 英語 英語 日本語 日本語
日本語能力 × × - - - -
味噌汁能力 × × × × × × ×

6
3
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
6
3