生成的データ インテリジェンス

Meta Llama 3 モデルが Amazon SageMaker JumpStart | で利用できるようになりました。アマゾン ウェブ サービス

日付:

本日、Meta Llama 3 基礎モデルが以下から入手できることを発表できることを嬉しく思います。 Amazon SageMaker ジャンプスタート 推論をデプロイして実行します。 Llama 3 モデルは、事前にトレーニングされ、微調整された生成テキスト モデルのコレクションです。

この投稿では、SageMaker JumpStart 経由で Llama 3 モデルを検出してデプロイする方法を説明します。

メタラマ3とは

Llama 3 には 8 つのパラメータ サイズ (コンテキスト長が 70K の 8B と 3B) があり、推論、コード生成、および命令のフォローアップが改善され、幅広いユースケースをサポートできます。 Llama 128 は、デコーダー専用のトランスフォーマー アーキテクチャと、3k サイズでモデルのパフォーマンスを向上させる新しいトークナイザーを使用します。さらに、Meta はトレーニング後の手順を改善し、誤った拒否率を大幅に削減し、アライメントを改善し、モデルの応答の多様性を高めました。 SageMaker Pipelines、SageMaker Debugger、コンテナログなどの Amazon SageMaker 機能を使用して、Llama XNUMX のパフォーマンスと MLOps コントロールの利点を組み合わせて活用できるようになりました。さらに、モデルは VPC の制御下にある AWS の安全な環境にデプロイされ、データ セキュリティの提供に役立ちます。

SageMaker JumpStart とは

SageMaker JumpStart を使用すると、公開されている基盤モデルの幅広い選択肢から選択できます。 ML 実践者は、ネットワーク分離された環境から基盤モデルを専用の SageMaker インスタンスにデプロイし、SageMaker を使用してモデルのトレーニングとデプロイメントにモデルをカスタマイズできます。数回クリックするだけで Llama 3 モデルを検出してデプロイできるようになりました。 Amazon SageMakerスタジオ または、SageMaker Python SDK を介してプログラム的に、次のような SageMaker 機能を使用してモデルのパフォーマンスと MLOps コントロールを導き出すことができます。 SageMakerパイプライン, SageMakerデバッガー、またはコンテナーのログ。モデルは AWS の安全な環境にデプロイされ、VPC の制御下に置かれ、データ セキュリティの提供に役立ちます。 Llama 3 モデルは現在、Amazon SageMaker Studio でのデプロイと推論に利用可能です。 us-east-1 (バージニア北部)、 us-east-2 (オハイオ州)、 us-west-2 (オレゴン)、 eu-west-1 (アイルランド)と ap-northeast-1 (東京) AWS リージョン。

モデルを発見する

基礎モデルには、SageMaker Studio UI の SageMaker JumpStart および SageMaker Python SDK を通じてアクセスできます。 このセクションでは、SageMaker Studio でモデルを検出する方法について説明します。

SageMaker Studio は、単一の Web ベースのビジュアル インターフェイスを提供する統合開発環境 (IDE) であり、専用ツールにアクセスして、データの準備から ML モデルの構築、トレーニング、デプロイまで、すべての ML 開発ステップを実行できます。 SageMaker Studio の開始方法とセットアップ方法の詳細については、以下を参照してください。 Amazon SageMakerスタジオ.

SageMaker Studio では、事前トレーニングされたモデル、ノートブック、事前構築されたソリューションを含む SageMaker JumpStart にアクセスできます。 事前に構築された自動化されたソリューション.

SageMaker JumpStart ランディング ページから、モデルプロバイダーにちなんで名付けられたさまざまなハブを参照することで、さまざまなモデルを簡単に見つけることができます。 Llama 3 モデルは Meta Hub で見つけることができます。 Llama 3 モデルが表示されない場合は、シャットダウンして再起動して、SageMaker Studio のバージョンを更新してください。詳細については、以下を参照してください。 Studio Classic アプリをシャットダウンして更新する.

左上の検索ボックスから「Meta-llama-3」を検索すると、Llama 3 モデルを見つけることができます。

[メタ ハブ] をクリックすると、SageMaker JumpStart で利用可能なすべてのメタ モデルを見つけることができます。

モデル カードをクリックすると、対応するモデルの詳細ページが開き、そこからモデルを簡単にデプロイできます。

モデルをデプロイする

選ぶとき 配備します EULA 条項に同意すると、展開が開始されます。

「デプロイ」ボタンをクリックした後に表示されるページで、デプロイメントの進行状況を監視できます。

または、以下を選択できます ノートを開く サンプル ノートブックを通じてデプロイします。サンプル ノートブックは、推論用のモデルをデプロイし、リソースをクリーンアップする方法に関するエンドツーエンドのガイダンスを提供します。

ノートブックを使用して展開するには、まず、 model_id。次のコードを使用して、選択したモデルのいずれかを SageMaker にデプロイできます。

from sagemaker.jumpstart.model import JumpStartModel

model = JumpStartModel(model_id = "meta-textgeneration-llama-3-70b-instruct")
predictor = model.deploy(accept_eula=False)

デフォルトでは accept_eula に設定されています False。エンドポイントを正常に展開するには、EULA に手動で同意する必要があります。これにより、ユーザー使用許諾契約および利用規約に同意したことになります。使用許諾契約書もご覧いただけます ラマのウェブサイト。これにより、デフォルトのインスタンス タイプやデフォルトの VPC 構成を含むデフォルト構成でモデルが SageMaker にデプロイされます。これらの構成は、デフォルト以外の値を指定することで変更できます。 JumpStartModel。詳細については、以下を参照してください。 ドキュメント.

次の表は、SageMaker JumpStart で利用可能なすべての Llama 3 モデルと、 model_ids、これらのモデルごとにサポートされているデフォルトのインスタンス タイプと合計トークンの最大数 (入力トークンの数と生成されたトークンの数の合計)。

モデル名 モデルID 最大合計トークン数 デフォルトのインスタンスタイプ
メタラマ-3-8B メタテキス​​ト生成-ラマ-3-8B 8192 ml.g5.12xラージ
メタラマ-3-8B-指示 メタテキス​​ト生成-ラマ-3-8B-命令 8192 ml.g5.12xラージ
メタラマ-3-70B メタテキス​​ト生成-ラマ-3-70b 8192 ml.p4d.24xlarge
メタラマ-3-70B-指示 メタテキス​​ト生成-ラマ-3-70b-命令 8192 ml.p4d.24xlarge

推論を実行する

モデルをデプロイした後、SageMaker プレディクターを介して、デプロイされたエンドポイントに対して推論を実行できます。微調整された指示モデル (Llama 3: 8B 指示および 70B 指示) は、ユーザーとチャット アシスタント間のチャットの履歴を受け入れ、後続のチャットを生成します。事前トレーニングされたモデル (Llama 3: 8B および 70B) には文字列プロンプトが必要で、提供されたプロンプトでテキスト補完を実行します。

predictor.predict(payload)

推論パラメータは、エンドポイントでのテキスト生成プロセスを制御します。新しいトークンの最大数は、モデルによって生成される出力のサイズを制御します。モデルの語彙は英語の語彙と同じではなく、各トークンは英語の単語ではない可能性があるため、これは単語の数と同じではありません。温度パラメータは出力のランダム性を制御します。温度が高いほど、より創造的で幻覚的な出力が得られます。すべての推論パラメーターはオプションです。

70B モデルのプロンプトの例

Llama 3 モデルは、あらゆるテキストのテキスト補完に使用できます。テキスト生成を通じて、質問応答、言語翻訳、感情分析などのさまざまなタスクを実行できます。エンドポイントへの入力ペイロードは次のコードのようになります。

payload = {
    “inputs”: str,
   (optional)"parameters":{"max_new_tokens":int, "top_p":float, "temperature":float}
}

以下は、プロンプトのサンプル例とモデルによって生成されたテキストです。 すべての出力は推論パラメーターを使用して生成されます {"max_new_tokens":64, "top_p":0.9, "temperature":0.6}.

Input: Simply put, the theory of relativity states that
Output: 1) the laws of physics are the same for all observers, and 2) the speed of light is constant for all observers. The first part of the theory is known as the special theory of relativity, and the second part is known as the general theory of relativity.nThe special theory of relativity states

Input: I believe the meaning of life is
Output:  to live a life of purpose, on purpose. I believe that we are all here to make a difference in the world, and that we are all here to make a difference in the lives of others. I believe that we are all here to make a difference in the world, and that we are all here to mak

Input: A brief message congratulating the team on the launch:nnHi everyone,nnI just 
Output: wanted to say congratulations on the launch of the new website! It looks great and I'm sure it will be a valuable resource for our customers. I know that a lot of hard work went into making this happen, so thank you all for your efforts.nnBest regards,nJohn Doen

次の例では、モデルで利用可能なトレーニング サンプルを提供する、少数のショット インコンテキスト学習で Llama 3 モデルを使用する方法を示します。このプロセスでは、デプロイされたモデルに対してのみ推論が実行され、モデルの重みは変更されません。

Input:
Translate English to French:nsea otter => loutre de mernpeppermint => menthe poivréenplush girafe => girafe peluchencheese =>
Output:  fromagenpanda => pandanpenguin => pingouinnpolar bear => ours polairenpuffin => macareuxnsloth => paresseuxnwalrus => morsenwhale => baleinenzebra => zu00e8brenTranslate English to German:n

70B-Instruct モデルのプロンプトの例

対話のユースケース向けに最適化された Llama 3 命令モデルでは、命令モデルのエンドポイントへの入力はチャット アシスタントとユーザーの間の以前の履歴です。これまでの会話に関連した質問をすることができます。チャット アシスタントの動作を定義するペルソナなどのシステム構成を提供することもできます。入力ペイロード形式は基本の事前トレーニング済みモデルと同じですが、入力テキストは次の方法で形式設定する必要があります。

<|begin_of_text|><|start_header_id|>system<|end_header_id|>

[SYSTEM_TEXT]<|eot_id|><|start_header_id|>user<|end_header_id|>

[USER_TEXT]<|eot_id|><|start_header_id|>assistant<|end_header_id|>

この指示テンプレートでは、オプションで、 system ロールを追加し、ターンベースの履歴に必要なだけ交互のロールを含めます。最終的な役割は常に次のようにする必要があります。 assistant 2 つの新しい改行で終わります。

次に、モデルからのプロンプトと応答の例をいくつか考えてみましょう。次の例では、ユーザーがアシスタントに簡単な質問をしています。

Input: <|begin_of_text|><|start_header_id|>user<|end_header_id|>nnwhat is the recipe of mayonnaise?<|eot_id|><|start_header_id|>assistant<|end_header_id|>nn
Output: The classic condiment! Mayonnaise is a thick, creamy emulsion sauce made from a combination of oil, egg yolks, acid (such as vinegar or lemon juice), and seasonings. Here's a simple recipe to make mayonnaise at home:nn**Ingredients:**nn* 2 egg yolksn* 1 tablespoon lemon juice or vinegar (such as apple cider vinegar or white wine vinegar)n* 1/2 teaspoon Dijon mustard (optional, but recommended for flavor)n* 1/2 cup (120 ml) neutral-tasting oil, such as canola, grapeseed, or sunflower oiln* Salt, to tastenn**Instructions:**nn1. **Start with room temperature ingredients**: This is crucial for emulsification to occur.n2. **In a medium-sized bowl**, whisk together the egg yolks, lemon juice or vinegar, and Dijon mustard (if using) until well combined.n3. **Slowly add the oil**: While continuously whisking the egg yolk mixture, slowly pour in the oil in a thin, steady stream. Start with a very slow drizzle and gradually increase the flow as the mixture thickens.n4. **Whisk constantly**: Keep whisking until the mixture has doubled in volume and has a thick, creamy consistency. This should take about 5-7 minutes.n5. **Check the consistency**: Stop whisking when the mayonnaise has reached the desired consistency. It should be smooth, thick, and hold its shape when the whisk is lifted.n6. **Season with salt**: Add salt to taste, and whisk until well combined.n7. **Taste and adjust**: If the mayonnaise is too thick, add a little water. If it's not thick enough, add a little more oil.nn**Tips and Variations:**nn* Use a neutral-tasting oil to avoid flavoring the mayonnaise.n* If you're using a stand mixer, use the whisk attachment and start with a slow speed, increasing as needed.n* Add flavorings like minced garlic, chopped fresh herbs (e.g., parsley, dill, or tarragon), or grated ginger to create different flavor profiles.n* For a lighter mayonnaise, use only 1 egg yolk or add a little water to thin it out.n* If the mayonnaise breaks or separates, don't worry! Simply start again with a new egg yolk and slowly whisk in the broken mayonnaise.nn**Homemade Mayonnaise vs. Store-Bought:**nnWhile store-bought mayonnaise is convenient, homemade mayonnaise offers several advantages:nn* Freshness: Homemade mayonnaise is made to order, ensuring optimal flavor and texture.n* Customization: You can tailor the flavor to your liking with various seasonings and ingredients.n* No preservatives: Homemade mayonnaise doesn't contain added preservatives, making it a healthier option.nnEnjoy your freshly made mayonnaise!

次の例では、ユーザーがアシスタントとパリの観光地について会話しています。次に、ユーザーはチャット アシスタントが推奨する最初のオプションについて質問します。

Input: <|begin_of_text|><|start_header_id|>user<|end_header_id|>nnI am going to Paris, what should I see?<|eot_id|><|start_header_id|>assistant<|end_header_id|>nnParis, the capital of France, is known for its stunning architecture, art museums, historical landmarks, and romantic atmosphere. Here are some of the top attractions to see in Paris:nn1. The Eiffel Tower: The iconic Eiffel Tower is one of the most recognizable landmarks in the world and offers breathtaking views of the city.n2. The Louvre Museum: The Louvre is one of the world's largest and most famous museums, housing an impressive collection of art and artifacts, including the Mona Lisa.n3. Notre-Dame Cathedral: This beautiful cathedral is one of the most famous landmarks in Paris and is known for its Gothic architecture and stunning stained glass windows.nnThese are just a few of the many attractions that Paris has to offer. With so much to see and do, it's no wonder that Paris is one of the most popular tourist destinations in the world.<|eot_id|><|start_header_id|>user<|end_header_id|>nnWhat is so great about #1?<|eot_id|><|start_header_id|>assistant<|end_header_id|>nn
Output: The Eiffel Tower! It's an iconic symbol of Paris and one of the most recognizable landmarks in the world. Here are some reasons why it's so great:nn1. **Engineering marvel**: When it was built for the 1889 World's Fair, the Eiffel Tower was a groundbreaking feat of engineering. It was the tallest structure in the world at the time, standing at 324 meters (1,063 feet).n2. **Panoramic views**: The Eiffel Tower offers breathtaking 360-degree views of the city from its observation decks. You can see many of Paris' famous landmarks, such as the Seine River, the Louvre, and Montmartre.n3. **Romantic atmosphere**: The Eiffel Tower is often associated with romance and is a popular spot for proposals, weddings, and romantic dinners. The tower's iron latticework and twinkling lights at night add to its romantic ambiance.n4. **Historical significance**: The Eiffel Tower has played a significant role in French history, serving as a communication tower during World War I and a symbol of French culture and engineering.n5. **Accessibility**: The Eiffel Tower is easily accessible by public transportation or on foot, and there are various ways to experience it, including taking the stairs, elevator, or a guided tour.n6. **Nighttime spectacle**: The Eiffel Tower is even more magical at night, when it's illuminated with thousands of twinkling lights. The light show, known as the "Eiffel Tower Sparkle," takes place every hour on the hour from dusk to midnight.n7. **Iconic status**: The Eiffel Tower has been featured in countless films, literature, and art, making it an instantly recognizable symbol of Paris and France.nnOverall, the Eiffel Tower is a must-visit attraction in Paris, offering a unique combination of history, engineering, romance, and stunning views.

次の例では、システムの構成を設定します。

Input: <|begin_of_text|><|start_header_id|>system<|end_header_id|>nnAlways answer with Haiku<|eot_id|><|start_header_id|>user<|end_header_id|>nnI am going to Paris, what should I see?<|eot_id|><|start_header_id|>assistant<|end_header_id|>nn
Output: Eiffel's iron lacenRiver Seine's gentle flow bynMontmartre's charm calls
Input: <|begin_of_text|><|start_header_id|>system<|end_header_id|>nnAlways answer with emojis<|eot_id|><|start_header_id|>user<|end_header_id|>nnHow to go from Beijing to NY?<|eot_id|><|start_header_id|>assistant<|end_header_id|>nn
Output: ✈️🛬️🇺🇸

クリーンアップ

ノートブックの実行が完了したら、請求が停止されるように、プロセス中に作成したすべてのリソースを必ず削除してください。 次のコードを使用します。

predictor.delete_model()
predictor.delete_endpoint()

まとめ

この投稿では、SageMaker Studio で Llama 3 モデルの使用を開始する方法を説明しました。これで、数十億のパラメータを含む 3 つの Llama XNUMX 基礎モデルにアクセスできるようになりました。基礎モデルは事前トレーニングされているため、トレーニングとインフラストラクチャのコストを削減し、ユースケースに合わせたカスタマイズを可能にすることもできます。チェックアウト SageMaker ジャンプスタート 今すぐ SageMaker Studio で開始してください。


著者について

カイル・ウルリッヒ AWS の応用科学者 II です
シンファン AWS の上級応用科学者です
青蘭 AWS のシニア ソフトウェア開発エンジニアです
好天安 AWS のソフトウェア開発エンジニア II です
クリストファー・ウィッテン AWS のソフトウェア開発エンジニア II です
タイラー・オスターバーグ AWS のソフトウェア開発エンジニア I です
マナンシャー AWS のソフトウェア開発マネージャーです
ジョナサン・ギネガニ AWS のシニア ソフトウェア開発エンジニアです
アドリアナ・シモンズ AWS のシニア プロダクト マーケティング マネージャーです
ジューン・ウォン AWS のシニアプロダクトマネージャーです
アシシュ・ケタン AWS の上級応用科学者です
ラクナ チャダ AWS の AI/ML 担当プリンシパル ソリューション アーキテクトです
ディーパック・ルパクラ AWS の主席 GTM スペシャリストです

スポット画像

最新のインテリジェンス

スポット画像