نماذج Meta Llama 3 متاحة الآن في Amazon SageMaker JumpStart | خدمات الويب الأمازون

عقدة المصدر: 2553444

اليوم، يسعدنا أن نعلن عن توفر نماذج كريم الأساس Meta Llama 3 من خلال أمازون سيج ميكر جومب ستارت لنشر وتشغيل الاستدلال. نماذج Llama 3 عبارة عن مجموعة من نماذج النصوص التوليدية المدربة مسبقًا والمضبوطة بدقة.

في هذا المنشور، نتعرف على كيفية اكتشاف نماذج Llama 3 ونشرها عبر SageMaker JumpStart.

ما هو ميتا لاما 3

يأتي Llama 3 بحجمين من المعلمات — 8B و70B مع طول سياق 8k — الذي يمكنه دعم نطاق واسع من حالات الاستخدام مع تحسينات في الاستدلال وتوليد التعليمات البرمجية واتباع التعليمات. يستخدم Llama 3 بنية محولات وحدة فك التشفير فقط وأداة رمزية جديدة توفر أداءً محسنًا للنموذج بحجم 128 كيلو بايت. بالإضافة إلى ذلك، قامت ميتا بتحسين إجراءات ما بعد التدريب مما أدى إلى خفض معدلات الرفض الكاذب بشكل كبير، وتحسين التوافق، وزيادة التنوع في الاستجابات النموذجية. يمكنك الآن استخلاص المزايا المجمعة لأداء Llama 3 وعناصر تحكم MLOps من خلال ميزات Amazon SageMaker مثل SageMaker Pipelines أو SageMaker Debugger أو سجلات الحاوية. بالإضافة إلى ذلك، سيتم نشر النموذج في بيئة AWS الآمنة تحت ضوابط VPC الخاصة بك، مما يساعد على توفير أمان البيانات.

ما هو برنامج SageMaker JumpStart

باستخدام SageMaker JumpStart، يمكنك الاختيار من بين مجموعة واسعة من نماذج الأساس المتاحة للعامة. يمكن لممارسي تعلم الآلة نشر النماذج الأساسية لمثيلات SageMaker المخصصة من بيئة شبكة معزولة وتخصيص النماذج باستخدام SageMaker للتدريب على النماذج ونشرها. يمكنك الآن اكتشاف نماذج Llama 3 ونشرها ببضع نقرات أمازون ساجميكر ستوديو أو برمجيًا من خلال SageMaker Python SDK ، مما يتيح لك اشتقاق أداء النموذج وعناصر تحكم MLOps باستخدام ميزات SageMaker مثل خطوط الأنابيب 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 JumpStart في SageMaker Studio UI و SageMaker Python SDK. في هذا القسم ، ننتقل إلى كيفية اكتشاف النماذج في SageMaker Studio.

SageMaker Studio عبارة عن بيئة تطوير متكاملة (IDE) توفر واجهة مرئية واحدة قائمة على الويب حيث يمكنك الوصول إلى الأدوات المصممة لغرض تنفيذ جميع خطوات تطوير ML ، من إعداد البيانات إلى البناء والتدريب ونشر نماذج ML الخاصة بك. لمزيد من التفاصيل حول كيفية البدء وإعداد SageMaker Studio ، يرجى الرجوع إلى أمازون ساجميكر ستوديو.

في SageMaker Studio، يمكنك الوصول إلى SageMaker JumpStart، الذي يحتوي على نماذج ودفاتر ملاحظات وحلول تم إنشاؤها مسبقًا، ضمن حلول آلية ومبنية مسبقًا.

من الصفحة المقصودة لـ SageMaker JumpStart، يمكنك بسهولة اكتشاف نماذج متنوعة من خلال تصفح المحاور المختلفة التي تم تسميتها بأسماء موفري النماذج. يمكنك العثور على نماذج Llama 3 في Meta hub. إذا لم تشاهد نماذج Llama 3، فيرجى تحديث إصدار SageMaker Studio الخاص بك عن طريق إيقاف التشغيل وإعادة التشغيل. لمزيد من المعلومات، راجع قم بإيقاف تشغيل تطبيقات Studio Classic وتحديثها.

يمكنك العثور على نماذج Llama 3 من خلال البحث عن "Meta-llama-3" من مربع البحث الموجود في أعلى اليسار.

يمكنك اكتشاف جميع نماذج التعريف المتوفرة في SageMaker JumpStart بالنقر فوق Meta hub.

يؤدي النقر فوق بطاقة النموذج إلى فتح صفحة تفاصيل النموذج المقابل، والتي يمكنك من خلالها نشر النموذج بسهولة.

نشر نموذج

عندما تختار نشر والموافقة على شروط اتفاقية ترخيص المستخدم النهائي، سيبدأ النشر.

يمكنك مراقبة تقدم عملية النشر على الصفحة التي تظهر بعد النقر على زر النشر.

بدلاً من ذلك ، يمكنك الاختيار افتح دفتر الملاحظات للنشر من خلال دفتر الملاحظات المثال. يوفر نموذج دفتر الملاحظات إرشادات شاملة حول كيفية نشر النموذج للاستدلال وتنظيف الموارد.

للنشر باستخدام دفتر الملاحظات، عليك أن تبدأ بتحديد النموذج المناسب، المحدد بواسطة 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) يدويًا لنشر نقطة النهاية بنجاح، ومن خلال القيام بذلك، فإنك تقبل اتفاقية ترخيص المستخدم وسياسة الاستخدام المقبول. يمكنك أيضًا العثور على اتفاقية الترخيص موقع لاما. يؤدي هذا إلى نشر النموذج على SageMaker مع التكوينات الافتراضية بما في ذلك نوع المثيل الافتراضي وتكوينات VPC الافتراضية. يمكنك تغيير هذه التكوينات عن طريق تحديد قيم غير افتراضية في JumpStartModel. لمعرفة المزيد، يرجى الرجوع إلى ما يلي توثيق.

يسرد الجدول التالي كافة نماذج Llama 3 المتوفرة في SageMaker JumpStart بالإضافة إلى model_idsوأنواع المثيلات الافتراضية والحد الأقصى لعدد الرموز المميزة (مجموع عدد الرموز المميزة للإدخال وعدد الرموز المميزة التي تم إنشاؤها) المدعومة لكل من هذه النماذج.

نموذج الاسم معرف النموذج ماكس إجمالي الرموز نوع المثيل الافتراضي
ميتا لاما-3-8ب meta-textgeneration-llama-3-8B 8192 ml.g5.12xlarge
Meta-Llama-3-8B-Instruct meta-textgeneration-llama-3-8B-instruct 8192 ml.g5.12xlarge
ميتا لاما-3-70ب جيل النص الفوقي-اللاما-3-70 ب 8192 ml.p4d.24xlarge
Meta-Llama-3-70B-Instruct meta-textgeneration-llama-3-70b-instruct 8192 ml.p4d.24xlarge

تشغيل الاستدلال

بعد نشر النموذج، يمكنك تشغيل الاستدلال مقابل نقطة النهاية المنشورة من خلال أداة التوقع SageMaker. نماذج التعليمات المضبوطة (Llama 3: 8B Instruct و70B Instruct) تقبل سجل المحادثات بين المستخدم ومساعد الدردشة، وتقوم بإنشاء الدردشة اللاحقة. تتطلب النماذج المدربة مسبقًا (Llama 3: 8B و70B) موجه سلسلة وتقوم بإكمال النص على الموجه المقدم.

predictor.predict(payload)

تتحكم معلمات الاستدلال في عملية إنشاء النص عند نقطة النهاية. تتحكم الرموز المميزة Max الجديدة في حجم الإخراج الناتج عن النموذج. وهذا ليس نفس عدد الكلمات لأن مفردات النموذج ليست هي نفس مفردات اللغة الإنجليزية، وقد لا يكون كل رمز مميز كلمة لغة إنجليزية. تتحكم معلمة درجة الحرارة في العشوائية في الإخراج. يؤدي ارتفاع درجة الحرارة إلى المزيد من المخرجات الإبداعية والهلوسة. جميع معلمات الاستدلال اختيارية.

يطالب المثال لنموذج 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 وتنتهي بخلاصتين جديدتين.

بعد ذلك، فكر في بعض أمثلة المطالبات والاستجابات من النموذج. في المثال التالي، يقوم المستخدم بطرح سؤال بسيط على المساعد.

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()

وفي الختام

في هذا المنشور، أوضحنا لك كيفية البدء باستخدام نماذج Llama 3 في SageMaker Studio. يمكنك الآن الوصول إلى أربعة نماذج أساسية من Llama 3 تحتوي على مليارات المعلمات. نظرًا لأن النماذج الأساسية تم تدريبها مسبقًا، فيمكنها أيضًا المساعدة في تقليل تكاليف التدريب والبنية التحتية وتمكين التخصيص لحالة الاستخدام الخاصة بك. الدفع سيج ميكر جومب ستارت في SageMaker Studio الآن للبدء.


حول المؤلفين

كايل أولريش هو عالم تطبيقي II في AWS
شين هوانغ هو أحد كبار العلماء التطبيقيين في AWS
تشينغ لان هو مهندس مطور برامج أول في AWS
هاوتيان آن هو مهندس مطور برامج II في AWS
كريستوفر ويتن هو مهندس تطوير البرمجيات الثاني في AWS
تايلر أوستربيرج هو مهندس تطوير برمجيات في AWS
منان شاه هو مدير تطوير البرمجيات في AWS
جوناثان جينيجان هو مهندس مطور برامج أول في AWS
أدريانا سيمونز هو مدير أول لتسويق المنتجات في AWS
وون يونيو هو مدير منتج أول في AWS
اشيش خيتان هو أحد كبار العلماء التطبيقيين في AWS
راتشنا شادا هو مهندس الحلول الرئيسي - AI/ML في AWS
ديباك روباكولا هو متخصص رئيسي في GTM في AWS

الطابع الزمني:

اكثر من التعلم الآلي من AWS