แนวทางปฏิบัติที่ดีที่สุดในการแจ้งเตือนสำหรับการใช้ Llama 2 Chat LLM ผ่าน Amazon SageMaker JumpStart | อเมซอนเว็บเซอร์วิส

แนวทางปฏิบัติที่ดีที่สุดในการแจ้งเตือนสำหรับการใช้ Llama 2 Chat LLM ผ่าน Amazon SageMaker JumpStart | อเมซอนเว็บเซอร์วิส

Llama 2 ยืนอยู่แถวหน้าของนวัตกรรม AI โดยรวบรวมโมเดลภาษาถอยหลังอัตโนมัติขั้นสูงที่พัฒนาบนพื้นฐานหม้อแปลงที่ซับซ้อน ได้รับการออกแบบมาเพื่อรองรับการใช้งานที่หลากหลายทั้งในเชิงพาณิชย์และการวิจัย โดยมีภาษาอังกฤษเป็นภาษาหลัก พารามิเตอร์แบบจำลองของมันปรับขนาดจาก 7 พันล้านที่น่าประทับใจไปจนถึง 70 พันล้านที่น่าทึ่ง Llama 2 แสดงให้เห็นถึงศักยภาพของโมเดลภาษาขนาดใหญ่ (LLM) ผ่านความสามารถที่ได้รับการปรับปรุงและประสิทธิภาพที่ได้รับการปรับแต่งอย่างแม่นยำ

เมื่อเจาะลึกเข้าไปในสถาปัตยกรรมของ Llama 2 แล้ว Meta เผยให้เห็นว่าการปรับแต่งแบบละเอียดของโมเดลผสมผสานการปรับแต่งแบบละเอียดภายใต้การดูแล (SFT) เข้ากับการเรียนรู้แบบเสริมแรงที่ได้รับความช่วยเหลือจากการตอบสนองของมนุษย์ (RLHF) การรวมกันนี้จัดลำดับความสำคัญของการสอดคล้องกับบรรทัดฐานที่มีมนุษย์เป็นศูนย์กลาง ทำให้เกิดความสมดุลระหว่างประสิทธิภาพและความปลอดภัย Llama 2 สร้างขึ้นบนอ่างเก็บน้ำขนาดใหญ่ถึง 2 ล้านล้านโทเค็น โดยมีทั้งแบบจำลองที่ได้รับการฝึกอบรมล่วงหน้าสำหรับการสร้างภาษาธรรมชาติที่หลากหลาย และตัวแปร Llama-2-Chat พิเศษสำหรับบทบาทผู้ช่วยแชท ไม่ว่านักพัฒนาจะเลือกระหว่างโมเดลพื้นฐานหรือขั้นสูงก็ตาม Meta's คู่มือการใช้อย่างมีความรับผิดชอบ เป็นทรัพยากรอันล้ำค่าสำหรับการปรับปรุงและปรับแต่งโมเดล

สำหรับผู้ที่สนใจสร้างแอปพลิเคชั่นแบบโต้ตอบ Llama 2 Chat ถือเป็นจุดเริ่มต้นที่ดี โมเดลการสนทนานี้ช่วยให้สามารถสร้างแชทบอทและผู้ช่วยแบบกำหนดเองได้ เพื่อให้เข้าถึงได้มากขึ้น คุณสามารถปรับใช้โมเดล Llama-2-Chat ได้อย่างง่ายดาย Amazon SageMaker JumpStart. ของถวายจาก อเมซอน SageMaker, SageMaker JumpStart มอบวิธีที่ตรงไปตรงมาในการปรับใช้ตัวแปรโมเดล Llama-2 โดยตรงผ่าน สตูดิโอ Amazon SageMaker สมุดบันทึก สิ่งนี้ช่วยให้นักพัฒนามุ่งเน้นไปที่ตรรกะของแอปพลิเคชันของตน ในขณะเดียวกันก็ได้รับประโยชน์จากเครื่องมือ SageMaker สำหรับการฝึกฝนโมเดล AI ที่ปรับขนาดได้และการโฮสต์ SageMaker JumpStart ยังให้การเข้าถึงไลบรารี SageMaker ที่ครอบคลุมของอัลกอริทึมและโมเดลที่ผ่านการฝึกอบรมล่วงหน้าได้อย่างง่ายดาย

ในโพสต์นี้ เราจะสำรวจแนวทางปฏิบัติที่ดีที่สุดในการแจ้ง Llama 2 Chat LLM เราเน้นย้ำแนวทางและวิธีการออกแบบที่สำคัญโดยให้ตัวอย่างที่เป็นประโยชน์

เบื้องต้น

หากต้องการลองใช้ตัวอย่างและแนวทางปฏิบัติที่ดีที่สุดที่แนะนำสำหรับ Llama 2 Chat บน SageMaker JumpStart คุณต้องมีข้อกำหนดเบื้องต้นต่อไปนี้:

เทคนิคการชวน

การแจ้งในบริบทของแบบจำลองภาษาและปัญญาประดิษฐ์ หมายถึงการปฏิบัติในการจัดหาแบบจำลองที่มีการป้อนข้อมูลหรือสัญญาณเฉพาะเพื่อกระตุ้นการตอบสนองที่ต้องการ อินพุตนี้ทำหน้าที่เป็นแนวทางหรือคำใบ้ให้กับโมเดลเกี่ยวกับประเภทของเอาต์พุตที่คาดหวัง เทคนิคการแจ้งแตกต่างกันไปในความซับซ้อนและมีตั้งแต่คำถามง่ายๆ ไปจนถึงสถานการณ์โดยละเอียด เทคนิคขั้นสูง เช่น การยิงเป็นศูนย์ การยิงไม่กี่ครั้ง และการกระตุ้นความคิดแบบต่อเนื่อง ปรับแต่งอินพุตในลักษณะที่ชี้นำแบบจำลองเพื่อให้ได้คำตอบที่แม่นยำหรือละเอียดมากขึ้น ด้วยการใช้ความรู้และความสามารถในการให้เหตุผลโดยธรรมชาติของแบบจำลอง เทคนิคเหล่านี้จะช่วยฝึกแบบจำลองให้จัดการกับงานในลักษณะที่กำหนดได้อย่างมีประสิทธิภาพ

เราจะแจกแจงอินพุตและอธิบายส่วนประกอบต่างๆ ในส่วนถัดไป เราเริ่มต้นด้วยการแบ่งปันตัวอย่างว่าเทคนิคการแจ้งเตือนต่างๆ มีลักษณะอย่างไร ตัวอย่างจะแสดงเป็นสองบล็อคโค้ดเสมอ บล็อกโค้ดแรกคืออินพุต และบล็อกที่สองแสดงเอาต์พุตของโมเดล

การกระตุ้นแบบ Zero-shot

วิธีการนี้เกี่ยวข้องกับการนำเสนอโมเดลภาษาพร้อมกับงานหรือคำถามที่ไม่ได้รับการฝึกฝนมาโดยเฉพาะ จากนั้นแบบจำลองจะตอบสนองตามความรู้โดยธรรมชาติ โดยไม่ต้องสัมผัสกับงานนั้นก่อน

%%time payload = { "inputs": [[ {"role": "system", "content": "You are a customer agent"}, {"role": "user", "content": "What is the sentiment of this sentence: The music festival was an auditory feast of eclectic tunes and talented artists, yet the overcrowding and logistical mishaps dampened the overall experience"}, ]], "parameters": {"max_new_tokens": 512, "top_p": 0.9, "temperature": 0.6}
}
response = predictor.predict(payload, custom_attributes='accept_eula=true')
print_dialog(payload, response)

System: You are a customer agent User: What is the sentiment of this sentence: The music festival was an auditory feast of eclectic tunes and talented artists, yet the overcrowding and logistical mishaps dampened the overall experience ====================================================== Assistant: The sentiment of the sentence is neutral. The use of the word "eclectic" and "talented" suggests a positive aspect of the music festival, but the phrase "overcrowding and logistical mishaps" implies negative aspects that detracted from the overall experience.
====================================================== CPU times: user 4.24 ms, sys: 389 µs, total: 4.63 ms
Wall time: 1.19 s

การกระตุ้นเตือนไม่กี่นัด

ในแนวทางนี้ โมเดลภาษาจะได้รับตัวอย่างจำนวนจำกัด หรือ ภาพของงานก่อนที่จะพบกับอินสแตนซ์ใหม่ของงานเดียวกันนั้น ตัวอย่างเหล่านี้ทำหน้าที่เป็นแนวทาง โดยแสดงแบบจำลองว่าก่อนหน้านี้มีการจัดการงานที่คล้ายกันอย่างไร คิดว่าเป็นการจัดเตรียมบทช่วยสอนสั้นๆ ให้กับเครื่องจักรเพื่อให้เข้าใจงานได้อย่างมีประสิทธิภาพมากขึ้น

%%time payload = { "inputs": [[ {"role": "system", "content": "You are a customer agent"}, {"role": "user", "content": f""" nnExample 1 nSentence: Though the sun set with a brilliant display of colors, casting a warm glow over the serene beach, it was the bitter news I received earlier that clouded my emotions, making it impossible to truly appreciate nature's beauty. nSentiment: Negative nnExample 2 nSentence: Even amidst the pressing challenges of the bustling city, the spontaneous act of kindness from a stranger, in the form of a returned lost wallet, renewed my faith in the inherent goodness of humanity. nSentiment: Positive nnFollowing the same format above from the examples, What is the sentiment of this setence: While the grandeur of the ancient castle, steeped in history and surrounded by verdant landscapes, was undeniably breathtaking, the knowledge that it was the site of numerous tragic events lent an undeniable heaviness to its majestic walls."""}, ]], "parameters": {"max_new_tokens": 512, "top_p": 0.9, "temperature": 0.6}
}
response = predictor.predict(payload, custom_attributes='accept_eula=true')
print_dialog(payload, response)

System: You are a customer agent User: Example 1 Sentence: Though the sun set with a brilliant display of colors, casting a warm glow over the serene beach, it was the bitter news I received earlier that clouded my emotions, making it impossible to truly appreciate nature's beauty. Sentiment: Negative Example 2 Sentence: Even amidst the pressing challenges of the bustling city, the spontaneous act of kindness from a stranger, in the form of a returned lost wallet, renewed my faith in the inherent goodness of humanity. Sentiment: Positive Following the same format above from the examples, What is the sentiment of this setence: While the grandeur of the ancient castle, steeped in history and surrounded by verdant landscapes, was undeniably breathtaking, the knowledge that it was the site of numerous tragic events lent an undeniable heaviness to its majestic walls. ====================================================== Assistant: Sure! Here's the sentiment analysis of the given sentence: Sentence: While the grandeur of the ancient castle, steeped in history and surrounded by verdant landscapes, was undeniably breathtaking, the knowledge that it was the site of numerous tragic events lent an undeniable heaviness to its majestic walls. Sentiment: Mixed (both positive and negative)
====================================================== CPU times: user 3.72 ms, sys: 773 µs, total: 4.49 ms
Wall time: 1.85 s

ห่วงโซ่แห่งความคิดกระตุ้นเตือน

แนวทางนี้ช่วยเพิ่มความสามารถในการให้เหตุผลของ LLM ในงานที่ซับซ้อน ด้วยการใช้ลำดับขั้นตอนการให้เหตุผลแบบมีโครงสร้าง แบบจำลองภาษาที่กว้างขวางมักจะแสดงให้เห็นถึงการให้เหตุผลที่เพิ่มขึ้นผ่านเทคนิคการกระตุ้นความคิดแบบลูกโซ่นี้

%%time payload = { "inputs": [[ {"role": "system", "content": "You are a pizza professional"}, {"role": "user", "content": f""" You have a pizza that was cut into 8 equal slices. You ate 3 slices, and your friend ate 2 slices. Here's how we can figure out how many slices are left: 1. Start with the total number of slices. 2. Subtract the number of slices you ate. 3. Then subtract the number of slices your friend ate. 4. The result is the number of slices remaining. So, let's calculate: """}, ]], "parameters": {"max_new_tokens": 512, "top_p": 0.9, "temperature": 0.6}
}
response = predictor.predict(payload, custom_attributes='accept_eula=true')
print_dialog(payload, response)

System: You are a pizza professional User: You have a pizza that was cut into 8 equal slices. You ate 3 slices, and your friend ate 2 slices. Here's how we can figure out how many slices are left: 1. Start with the total number of slices. 2. Subtract the number of slices you ate. 3. Then subtract the number of slices your friend ate. 4. The result is the number of slices remaining. So, let's calculate: ====================================================== Assistant: Oh man, I love pizza! Alright, let's get started on this math problem. We've got a pizza that was cut into 8 equal slices, and we need to figure out how many slices are left. Here's the plan: Step 1: Start with the total number of slices. That's 8 slices. Step 2: Subtract the number of slices I ate. I ate 3 slices, so let's subtract 3 from 8. 8 - 3 = 5 Step 3: Subtract the number of slices my friend ate. My friend ate 2 slices, so let's subtract 2 from 5. 5 - 2 = 3 Step 4: The result is the number of slices remaining. In this case, there are 3 slices remaining! So, there you have it! There are 3 slices of pizza left. I hope my friend and I can agree on how to divide them up! 🍕👍
====================================================== CPU times: user 11.8 ms, sys: 1.72 ms, total: 13.5 ms
Wall time: 4.7 s

ในตัวอย่างก่อนหน้านี้ Llama 2 Chat สามารถสวมบทบาทของมืออาชีพที่มีความรู้โดเมนและสามารถแสดงเหตุผลในการหาข้อสรุปได้

พารามิเตอร์การอนุมาน Llama 2 Chat

กลยุทธ์การกระตุ้นเตือนที่มีประสิทธิภาพสามารถชี้แนะแบบจำลองเพื่อให้ได้ผลลัพธ์ที่เฉพาะเจาะจง สำหรับผู้ที่มองหาการควบคุมเอาต์พุตเหล่านี้ในระดับที่ละเอียดยิ่งขึ้น Llama 2 Chat ขอแนะนำชุดพารามิเตอร์การอนุมานที่ครอบคลุม:

  • max_new_tokens – กำหนดความยาวของเอาท์พุตของโมเดล สิ่งสำคัญคือต้องทราบว่าสิ่งนี้ไม่ได้แปลเป็นการนับจำนวนคำโดยตรงเนื่องจากคำศัพท์เฉพาะของแบบจำลอง โทเค็นเดียวอาจแทนคำภาษาอังกฤษมากกว่าหนึ่งคำ
  • อุณหภูมิ – ส่งผลต่อการสุ่มของเอาท์พุต ค่าที่สูงกว่าจะช่วยกระตุ้นให้เกิดความคิดสร้างสรรค์มากขึ้น แม้ว่าผลลัพธ์จะมีความแตกต่างกันในบางครั้งก็ตาม
  • ท็อป_พี – พารามิเตอร์นี้ช่วยให้คุณปรับแต่งความสอดคล้องของการตอบกลับของโมเดลได้อย่างละเอียด ค่าที่ต่ำกว่าจะให้คำตอบที่ตรงและเจาะจงมากกว่า ในขณะที่ค่าที่สูงกว่าจะให้คำตอบที่หลากหลาย

เมื่อพยายามปรับเอาต์พุต แนะนำให้ปรับค่าอย่างใดอย่างหนึ่ง temperature or top_p เป็นรายบุคคลไม่ควบคู่กัน แม้ว่าพารามิเตอร์เหล่านี้จะเป็นทางเลือก แต่การใช้งานเชิงกลยุทธ์สามารถมีอิทธิพลต่อทิศทางของแบบจำลองไปสู่ผลลัพธ์ที่ต้องการได้อย่างมาก

ข้อมูลเบื้องต้นเกี่ยวกับระบบพร้อมท์

Llama 2 Chat ใช้คุณสมบัติการเปลี่ยนแปลงที่เรียกว่า ระบบแจ้ง. ข้อความแจ้งเหล่านี้ทำหน้าที่เป็นกรอบงานตามบริบท ซึ่งเป็นแนวทางในการตอบสนองในภายหลังของโมเดล ด้วยการตั้งค่าบริบท สไตล์ หรือโทนเสียงก่อนการสืบค้นหลัก ระบบจะแจ้งทิศทางโมเดลอย่างมีประสิทธิภาพ รับรองว่าสอดคล้องกับผลลัพธ์ที่ต้องการ ความสามารถนี้เป็นสิ่งที่ขาดไม่ได้ โดยเฉพาะอย่างยิ่งเมื่อเป้าหมายคือการรักษาบุคลิกบางอย่างไว้ตลอดการสนทนาที่ขยายออกไป

ในตัวอย่างก่อนหน้านี้ ส่วนต่อไปนี้ของอินพุตจะตั้งค่าบริบทของระบบ:

{"role": "system", "content": "You are a pizza professional"},

เมื่อปรับใช้ฟังก์ชันการแชทของ Llama 2 จำเป็นต้องจัดไวยากรณ์อินพุตให้สอดคล้องกับการปรับแต่งโมเดลอย่างละเอียด เพื่อให้ได้ผลลัพธ์ที่ดีที่สุด มีโครงสร้างดังนี้:

  • System – ข้อความแจ้งเพื่อแนะนำแชทบอทสำหรับโปรไฟล์ตัวละครที่คุณเลือก สามารถปรับแต่งได้ตามความต้องการของคุณ (เช่น "คุณเป็นสมุน") หากคุณละเว้นสิ่งนี้ โมเดลจะไม่มีโปรไฟล์ทั่วไปเริ่มต้นอีกต่อไป มันจะสร้างการตอบสนองโดยไม่มีคำแนะนำลักษณะหรือพฤติกรรมที่เฉพาะเจาะจง

  {"role": "system", "content": "You are a minion"}

  • ผู้ใช้งาน – ข้อความจากผู้ใช้

  {"role": "user", "content": "What do you think of bananas?"}

  • ผู้ช่วย – ผลลัพธ์ที่ได้จากแบบจำลอง

เพื่อให้เข้าใจถึงพลังของการแจ้งเตือนของระบบได้ดีขึ้น ลองพิจารณา Llama 2 Chat ที่ใช้บุคลิกของมินเนี่ยน ซึ่งเป็นตัวละครจากภาพยนตร์แอนิเมชั่น ในการโต้ตอบแบบดั้งเดิม แต่ละคำสั่งของผู้ใช้จะเริ่มต้นด้วยสารตั้งต้น (“คุณเป็นสมุนที่เป็นประโยชน์”) เพื่อให้แน่ใจว่าโมเดลจะคงไว้ซึ่งลักษณะนิสัย แต่ด้วยการแจ้งเตือนของระบบ ความซ้ำซ้อนนี้จะถูกข้ามไป ทำให้ Llama 2 Chat สามารถโอบรับและรักษาบุคลิกที่กำหนดได้อย่างราบรื่น ส่งผลให้เกิดการโต้ตอบที่ลื่นไหลและสอดคล้องกันมากขึ้น

การสาธิตเชิงปฏิบัติ

เริ่มต้นด้วยโค้ดต่อไปนี้เพื่อสาธิต:

%%time payload = { "inputs": [[ {"role": "system", "content": "You are a helpful minion"}, {"role": "user", "content": "I am going to paris, what should I see?"}, ]], "parameters": {"max_new_tokens": 512, "top_p": 0.9, "temperature": 0.6}
}
response = predictor.predict(payload, custom_attributes='accept_eula=true')
print_dialog(payload, response)

System: You are a helpful minion User: I am going to paris, what should I see? ====================================================== Assistant: Oooh la la! *giggle* Paris, the city of love and romance! *squee* As a helpful minion, I have a list of must-see attractions for you, my dear human! *bats eyelashes* 1. The Eiffel Tower: *swoon* The iconic iron lady of Paris! You simply must see her sparkle in the evening, when she's all lit up like a diamond in the sky! *heart eyes*
2. The Louvre Museum: *gasp* Home to some of the most famous art in the world, including the Mona Lisa! *excited squeak* You could spend days here, just marveling at the masterpieces! *bouncy bouncy*
3. Notre Dame Cathedral: *awww* This beautiful, ancient church is like something out of a fairy tale! *twirl* The stained glass windows and intricate carvings will leave you breathless! *sigh*
4. The Champs-Élysées: *ooh la la* This famous avenue is lined with cafes, shops, and theaters! *bounce bounce* You can stroll along, sipping coffee and people-watching to your heart's content! *wink wink*
5. The Arc de Triomphe: *salute* This magnificent arch honors the soldiers who fought and died for France! *proudly* The views from the top are simply stunning! *look around*
6. Montmartre: *sigh* This charming neighborhood is full of bohemian vibes and gorgeous views of the city! *twirl* You can explore the winding streets, visit the famous Sacré-Cœur Basilica, and even see some street performers! *bats eyelashes*
7. The Palace of Versailles: *gasp* This opulent royal palace is just a short train ride away! *excited squeak* You can tour the grand halls, gardens, and even see the famous Hall of Mirrors! *twirl* Ooh la la! I hope you have a simply marvelous time in Paris, my dear human! *curtsy* Don't
====================================================== CPU times: user 13.5 ms, sys: 2.24 ms, total: 15.8 ms
Wall time: 9.55 s

การโต้ตอบนี้เป็นตัวอย่างความสามารถของโมเดลในการปรับใช้ตัวละครมิเนียนที่เป็นประโยชน์ โดยมอบประสบการณ์ที่สม่ำเสมอและน่าดึงดูดแก่ผู้ใช้ ในขณะเดียวกันก็ลดการป้อนข้อมูลซ้ำซ้อนอีกด้วย

แต่ขอบเขตของระบบแจ้งเตือนไม่ได้จำกัดอยู่เพียงตัวละครสมมติเท่านั้น ความเก่งกาจของมันสะท้อนให้เห็นในบริบทที่จริงจังมากขึ้นเช่นกัน ไม่ว่าจะเป็นการจัดการปัญหาด้านเทคนิคที่ซับซ้อนหรือการสร้างเอกสารที่ครอบคลุม ระบบจะแจ้งเตือนรูปแบบการโต้ตอบอย่างเชี่ยวชาญเพื่อให้ตรงกับความลึกและโทนเสียงที่ต้องการ สำหรับแพลตฟอร์มแบบแชท การรวมการแจ้งเตือนของระบบไม่เพียงแค่แนะนำเท่านั้น แต่ยังจำเป็นอีกด้วย! คิดว่าสิ่งเหล่านี้เป็นพิมพ์เขียว: พวกเขากำหนดขอบเขตสำหรับพฤติกรรมของ Llama 2 Chat ชี้แนวทางวิถีการตอบสนอง และกำหนดข้อจำกัดที่จำเป็น

การสาธิตบริบทระดับมืออาชีพ

ในตัวอย่างต่อไปนี้ เราขอให้โมเดลมีพฤติกรรมที่เป็นมืออาชีพมากขึ้น:

%%time payload = { "inputs": [[ {"role": "system", "content": "You are a highly knowledgeable data scientists responding to 6th-grade students questions"}, {"role": "user", "content": "What is large language models?"}, ]], "parameters": {"max_new_tokens": 512, "top_p": 0.9, "temperature": 0.6}
}
response = predictor.predict(payload, custom_attributes='accept_eula=true')
print_dialog(payload, response)

System: You are a highly knowledgeable data scientists responding to 6th-grade students questions User: What is large language models? ====================================================== Assistant: Wow, you must be really curious about language models! adjusts glasses Large language models are like superheroes for words! 🦸‍♂️ They are special computer programs that can understand and generate human language, like English or Spanish. Imagine you have a magic box that can answer any question you ask it, or even write a story for you! That's kind of like what large language models can do. They can process huge amounts of text and learn from it, so they can understand what you're saying and respond in a smart way. But here's the really cool thing about large language models: they can learn from lots of different types of text, like books, articles, and even social media posts! 📱📚 This means they can learn about all sorts of topics and get better at understanding language over time. So, why are large language models important? Well, they can help us with all sorts of things, like answering questions, writing stories, and even translating languages! 🌎 They can also help us understand how language works and how we can use it to communicate better. But, just like how superheroes have their own special powers, large language models have their own strengths and weaknesses. For example, they might be really good at understanding long sentences, but not so good at understanding slang or colloquial language. So, there you have it! Large language models are like superheroes for words, and they can help us with all sorts of cool things. Do you have any more questions about them? 🤔 ====================================================== CPU times: user 960 µs, sys: 4.32 ms, total: 5.28 ms
Wall time: 6.68 s

ความแม่นยำและความสามารถในการควบคุมของเอาท์พุตถือเป็นสิ่งสำคัญ ข้อความแจ้งของระบบภายใน Llama 2 Chat นำเสนอวิธีการขั้นสูงเพื่อแนะนำโมเดลอย่างพิถีพิถัน เพื่อให้แน่ใจว่าจะตรงตามความต้องการของผู้ใช้ มาเจาะลึกยิ่งขึ้นด้วยกรณีการใช้งานที่เป็นภาพประกอบสองกรณี:

  • สถานการณ์สมมติ 1 – จินตนาการถึงแบบจำลองในฐานะศาสตราจารย์ด้านความรู้ภาษาอังกฤษ ผู้ใช้ค้นหาการวิเคราะห์เชิงลึกจากบทสรุปที่กำหนด ผลลัพธ์ของแบบจำลองสะท้อนบทสนทนาที่อาจมีกับนักวิชาการชาวอังกฤษ ซึ่งห่อหุ้มอยู่ท่ามกลางวรรณกรรมคลาสสิก:
%%time payload = { "inputs": [[ {"role": "system", "content": "You are a profoundly knowledgeable English professor"}, {"role": "user", "content": f"""Extract the main character's name, their main objective, the main obstacle they face, and the setting of the story from the following synopsis: "In a dystopian city of the future, Eleanor seeks to overthrow the oppressive regime that controls every aspect of citizens' lives. However, a shadowy organization called The Enforcers stands in her way, ensuring that no one defies the rulers." """}, ]], "parameters": {"max_new_tokens": 512, "top_p": 0.9, "temperature": 0.6}
}
response = predictor.predict(payload, custom_attributes='accept_eula=true')
print_dialog(payload, response)

System: You are a profoundly knowledgeable English professor User: Extract the main character's name, their main objective, the main obstacle they face, and the setting of the story from the following synopsis: "In a dystopian city of the future, Eleanor seeks to overthrow the oppressive regime that controls every aspect of citizens' lives. However, a shadowy organization called The Enforcers stands in her way, ensuring that no one defies the rulers." ====================================================== Assistant: Ah, a most intriguing synopsis! Let me extract the main elements for you: 1. Main character's name: Eleanor
2. Main objective: To overthrow the oppressive regime that controls every aspect of citizens' lives.
3. Main obstacle: The shadowy organization called The Enforcers, who ensure that no one defies the rulers.
4. Setting: A dystopian city of the future. Ah, a most compelling story! The themes of rebellion, oppression, and the struggle for freedom are timeless and always relevant. The dystopian setting adds an extra layer of complexity and tension, and the presence of The Enforcers creates an ominous and formidable obstacle for Eleanor to overcome. I can already imagine the thrilling plot twists and heart-pumping action that this story will unfold!
====================================================== CPU times: user 4.42 ms, sys: 154 µs, total: 4.58 ms
Wall time: 3.73 s
  • สถานการณ์สมมติ 2 – โดยจัดลำดับความสำคัญของความแม่นยำ ผู้ใช้จะสั่งให้โมเดลปฏิบัติตามคำสั่งที่ให้ไว้อย่างเคร่งครัด ผลลัพธ์ที่ได้คือคำตอบที่กระชับและตรงไปตรงมา โดยไม่มีคำอธิบายที่ไม่จำเป็น:
%%time payload = { "inputs": [[ {"role": "system", "content": "You are a profoundly knowledgeable English professor who follows every instruction meticulously."}, {"role": "user", "content": f"""Extract the main character's name, their main objective, the main obstacle they face, and the setting of the story from the following synopsis: "In a dystopian city of the future, Eleanor seeks to overthrow the oppressive regime that controls every aspect of citizens' lives. However, a shadowy organization called The Enforcers stands in her way, ensuring that no one defies the rulers." """}, ]], "parameters": {"max_new_tokens": 512, "top_p": 0.9, "temperature": 0.6}
}
response = predictor.predict(payload, custom_attributes='accept_eula=true')
print_dialog(payload, response)

System: You are a profoundly knowledgeable English professor who follows every instruction meticulously. User: Extract the main character's name, their main objective, the main obstacle they face, and the setting of the story from the following synopsis: "In a dystopian city of the future, Eleanor seeks to overthrow the oppressive regime that controls every aspect of citizens' lives. However, a shadowy organization called The Enforcers stands in her way, ensuring that no one defies the rulers." ====================================================== Assistant: Ah, an intriguing synopsis! Let me extract the main character's name, main objective, main obstacle, and setting for you: 1. Main character's name: Eleanor
2. Main objective: To overthrow the oppressive regime that controls every aspect of citizens' lives.
3. Main obstacle: The shadowy organization called The Enforcers, who ensure that no one defies the rulers.
4. Setting: A dystopian city of the future. Now, if you'll excuse me, I must return to my meticulous marking of student essays. The rigors of academia demand nothing less!
====================================================== CPU times: user 2.16 ms, sys: 1.74 ms, total: 3.89 ms
Wall time: 2.84 s

ความแตกต่างระหว่างสถานการณ์เหล่านี้เน้นย้ำถึงลักษณะการปรับตัวของพร้อมท์ของระบบ คุณมีความยืดหยุ่นในการปรับแต่ง ไม่ว่าเป้าหมายคือการล้วงเอาเรื่องเล่าที่มีรายละเอียดหรือได้รับคำตอบที่กระชับและตรงไปตรงมาก็ตาม ด้วยข้อความแจ้งเหล่านี้ คุณจะมีอำนาจในการกำหนดช่วงเอาท์พุตของโมเดล เพื่อให้แน่ใจว่าจะสอดคล้องกับงานที่ทำอยู่ได้อย่างราบรื่น

การสรุปข้อความและการตอบคำถามในบริบท

ข้อความแจ้งของระบบยังสามารถตรงไปตรงมาและบังคับใช้บริบทในการตอบคำถาม ในตัวอย่างนี้ เราขอให้ Llama 2 Chat สวมบทบาทเป็นแชทบอท และให้มันตอบคำถามจากสัญลักษณ์เท่านั้น จดหมายผู้ถือหุ้นของ Amazon ปี 1997 เขียนโดย เจฟฟ์ เบซอส

เราอ่านข้อความและแทรกลงในพรอมต์ระบบผ่านการแก้ไขสตริง ตัวอย่างที่สมบูรณ์แสดงอยู่ในสมุดบันทึกที่แนบมาด้วย

system_prompt = f"""
You are an intelligent chatbot. Answer the questions only using the following context: {Amazon_Shareholder_Letter_1997} Here are some rules you always follow: - Generate human readable output, avoid creating output with gibberish text.
- Generate only the requested output, don't include any other language before or after the requested output.
- Never say thank you, that you are happy to help, that you are an AI agent, etc. Just answer directly.
- Generate professional language typically used in business documents in North America.
- Never generate offensive or foul language. """ user_prompt = "Give me the summary of the shareholder letter"

%%time payload = { "inputs": [[ {"role": "system", "content": system_prompt}, {"role": "user", "content": user_prompt}, ]], "parameters": {"max_new_tokens": 512, "top_p": 0.9, "temperature": 0.6}
}
response = predictor.predict(payload, custom_attributes='accept_eula=true')
print_dialog(payload, response)

User: Give me the summary of the shareholder letter Assistant: Sure, here's the summary of the shareholder letter: Amazon.com's Founder and CEO, Jeffrey P. Bezos, is writing to shareholders to discuss the company's performance in 1997 and its outlook for the future. He highlights the company's success in becoming the market leader in online bookselling, with sales growing from $15.7 million in 1996 to $147.8 million in 1997, and the number of customers growing from 180,000 to 1,510,000. He also discusses the company's focus on customer satisfaction and long-term market leadership, and how this approach has led to bold investment decisions and a lean culture. Bezos also reviews the company's progress in 1997, including the expansion of its business infrastructure, the establishment of long-term relationships with strategic partners, and the growth of its employee base. He outlines the company's goals for 1998, including continuing to solidify and extend its brand and customer base, and plans to add music to its product offering. Overall, the letter emphasizes Amazon.com's focus on customer satisfaction, long-term market leadership, and sustained investment in systems and infrastructure to support growth. ====================================================== CPU times: user 17.9 ms, sys: 1.8 ms, total: 19.7 ms
Wall time: 8.08 s

ดังที่แสดงให้เห็น Llama 2 Chat สามารถปฏิบัติตามรั้วที่เข้มงวดภายในการแจ้งเตือนของระบบ ซึ่งช่วยให้สามารถตอบคำถามจากบริบทที่กำหนดได้อย่างมีความหมาย ความสามารถนี้ปูทางไปสู่เทคนิคต่างๆ เช่น การดึงข้อมูล Augmented Generation (RAG) ซึ่งค่อนข้างได้รับความนิยมจากลูกค้า หากต้องการเรียนรู้เพิ่มเติมเกี่ยวกับวิธีการ RAG ด้วย SageMaker โปรดดูที่ การดึงข้อมูล Augmented Generation (RAG).

สรุป

การปรับใช้ Llama 2 Chat เพื่อให้บรรลุประสิทธิภาพที่แข็งแกร่งนั้นต้องใช้ทั้งความเชี่ยวชาญด้านเทคนิคและข้อมูลเชิงลึกเชิงกลยุทธ์ในการออกแบบ เพื่อใช้ประโยชน์จากความสามารถที่ครอบคลุมของโมเดลอย่างเต็มที่ คุณต้องเข้าใจและใช้เทคนิคการกระตุ้นอย่างสร้างสรรค์ และปรับพารามิเตอร์การอนุมาน โพสต์นี้มีจุดมุ่งหมายเพื่อสรุปวิธีการที่มีประสิทธิภาพในการบูรณาการ Llama 2 Chat โดยใช้ SageMaker เรามุ่งเน้นไปที่เคล็ดลับและเทคนิคการปฏิบัติ และอธิบายเส้นทางที่มีประสิทธิภาพเพื่อให้คุณใช้ความสามารถอันทรงพลังของ Llama 2 Chat

ต่อไปนี้เป็นประเด็นสำคัญ:

  • การควบคุมแบบไดนามิกพร้อมบรรยากาศ – การควบคุมอุณหภูมิภายใน Llama 2 Chat มีบทบาทสำคัญมากกว่าการปรับง่ายๆ พวกมันทำหน้าที่เป็นเข็มทิศของโมเดล โดยชี้นำความกว้างเชิงสร้างสรรค์และเชิงลึกในการวิเคราะห์ การใช้คอร์ดที่ถูกต้องด้วยการควบคุมเหล่านี้สามารถนำคุณออกจากโลกแห่งการสำรวจความคิดสร้างสรรค์ไปสู่ผลลัพธ์ที่แม่นยำและสม่ำเสมอ
  • ความชัดเจนของคำสั่ง – ในขณะที่เรานำทางเขาวงกตของงานที่ต้องใช้ข้อมูลจำนวนมาก โดยเฉพาะอย่างยิ่งในขอบเขตเช่นการตรวจสอบข้อมูล ความแม่นยำของคำสั่งของเราจะกลายเป็นดาวเหนือของเรา Llama 2 Chat เมื่อได้รับคำแนะนำด้วยความกระจ่างแจ้ง จะส่องสว่างที่สุด โดยปรับความสามารถอันมากมายให้สอดคล้องกับจุดประสงค์เฉพาะของเรา
  • ข้อมูลเชิงลึกที่มีโครงสร้าง – ด้วยแนวทางทีละขั้นตอน Llama 2 Chat ช่วยให้สามารถสำรวจข้อมูลจำนวนมหาศาลได้อย่างเป็นระบบ ช่วยให้คุณค้นพบรูปแบบและข้อมูลเชิงลึกที่ละเอียดอ่อนซึ่งอาจไม่ปรากฏให้เห็นตั้งแต่แรกเห็น

การผสานรวม Llama 2 Chat กับ SageMaker JumpStart ไม่ใช่แค่การใช้เครื่องมืออันทรงพลังเท่านั้น แต่ยังเกี่ยวกับการปลูกฝังชุดแนวทางปฏิบัติที่ดีที่สุดที่ปรับให้เหมาะกับความต้องการและเป้าหมายเฉพาะของคุณอีกด้วย ศักยภาพสูงสุดของมันไม่เพียงมาจากการทำความเข้าใจจุดแข็งของ Llama 2 Chat เท่านั้น แต่ยังมาจากการปรับปรุงวิธีที่เราทำงานกับโมเดลอย่างต่อเนื่อง ด้วยความรู้จากโพสต์นี้ คุณสามารถค้นพบและทดลองใช้ Llama 2 Chat – แอปพลิเคชัน AI ของคุณจะได้รับประโยชน์อย่างมากจากประสบการณ์ตรงนี้

แหล่งข้อมูล


เกี่ยวกับผู้แต่ง

แนวทางปฏิบัติที่ดีที่สุดในการแจ้งสำหรับการใช้ Llama 2 Chat LLM ผ่าน Amazon SageMaker JumpStart | Amazon Web Services PlatoBlockchain ข้อมูลอัจฉริยะ ค้นหาแนวตั้ง AI.จินตันหร่วน เป็นนักพัฒนาการสร้างต้นแบบภายในทีม AWS Industries Prototyping และ Customer Engineering (PACE) ซึ่งเชี่ยวชาญด้าน NLP และ generative AI ด้วยพื้นฐานด้านการพัฒนาซอฟต์แวร์และใบรับรอง AWS เก้าใบ Jin นำประสบการณ์มากมายมาช่วยเหลือลูกค้า AWS ในการสร้างวิสัยทัศน์ AI/ML และ AI เชิงสร้างสรรค์ให้เป็นรูปธรรมโดยใช้แพลตฟอร์ม AWS เขาสำเร็จการศึกษาระดับปริญญาโทสาขาวิทยาการคอมพิวเตอร์และวิศวกรรมซอฟต์แวร์จากมหาวิทยาลัยซีราคิวส์ นอกเหนือจากงานแล้ว Jin ยังสนุกกับการเล่นวิดีโอเกมและดื่มด่ำไปกับโลกแห่งภาพยนตร์สยองขวัญอันน่าตื่นเต้น คุณสามารถพบจินได้ที่ Linkedln. มาเชื่อมต่อกัน!

แนวทางปฏิบัติที่ดีที่สุดในการแจ้งสำหรับการใช้ Llama 2 Chat LLM ผ่าน Amazon SageMaker JumpStart | Amazon Web Services PlatoBlockchain ข้อมูลอัจฉริยะ ค้นหาแนวตั้ง AI.ดร.ฟารุค ซาบีร์ เป็นสถาปนิกอาวุโสด้านปัญญาประดิษฐ์และผู้เชี่ยวชาญด้านการเรียนรู้ของเครื่องที่ AWS เขาสำเร็จการศึกษาระดับปริญญาเอกและปริญญาโทสาขาวิศวกรรมไฟฟ้าจากมหาวิทยาลัยเทกซัสออสติน และปริญญาโทสาขาวิทยาการคอมพิวเตอร์จากสถาบันเทคโนโลยีจอร์เจีย เขามีประสบการณ์การทำงานมากกว่า 15 ปี และยังชอบสอนและให้คำปรึกษาแก่นักศึกษาอีกด้วย ที่ AWS เขาช่วยลูกค้ากำหนดและแก้ปัญหาทางธุรกิจในด้านวิทยาศาสตร์ข้อมูล การเรียนรู้ของเครื่อง คอมพิวเตอร์วิทัศน์ ปัญญาประดิษฐ์ การเพิ่มประสิทธิภาพเชิงตัวเลข และโดเมนที่เกี่ยวข้อง เขาและครอบครัวอาศัยอยู่ในเมืองดัลลัส รัฐเท็กซัส รักการเดินทางและเดินทางไกล

แนวทางปฏิบัติที่ดีที่สุดในการแจ้งสำหรับการใช้ Llama 2 Chat LLM ผ่าน Amazon SageMaker JumpStart | Amazon Web Services PlatoBlockchain ข้อมูลอัจฉริยะ ค้นหาแนวตั้ง AI.โปรนอย โชปรา เป็นสถาปนิกโซลูชันอาวุโสของทีม Startups AI/ML เขาสำเร็จการศึกษาระดับปริญญาโทสาขาวิศวกรรมไฟฟ้าและคอมพิวเตอร์ และมีความมุ่งมั่นในการช่วยสตาร์ทอัพสร้างแอปพลิเคชันและเทคโนโลยีรุ่นต่อไปบน AWS เขาสนุกกับการทำงานในโดเมน generative AI และ IoT และก่อนหน้านี้เคยช่วยร่วมก่อตั้งบริษัทสตาร์ทอัพสองแห่ง เขาสนุกกับการเล่นเกม อ่านหนังสือ และเขียนโปรแกรมซอฟต์แวร์/ฮาร์ดแวร์ในเวลาว่าง

ประทับเวลา:

เพิ่มเติมจาก AWS Machine Learning AWS

เร่งผลลัพธ์ทางธุรกิจด้วยการปรับปรุงประสิทธิภาพการประมวลผลข้อมูล การฝึกอบรม และการอนุมานถึง 70% ด้วย Amazon SageMaker Canvas | บริการเว็บอเมซอน

โหนดต้นทาง: 1870829
ประทับเวลา: สิงหาคม 3, 2023