Zephyrnet-Logo

Beste Eingabeaufforderungspraktiken für die Verwendung des Llama 2 Chat LLM über Amazon SageMaker JumpStart | Amazon Web Services

Datum:

Llama 2 steht an der Spitze der KI-Innovation und verkörpert ein fortschrittliches autoregressives Sprachmodell, das auf einer hochentwickelten Transformatorbasis entwickelt wurde. Es ist auf eine Vielzahl von Anwendungen sowohl im kommerziellen als auch im Forschungsbereich zugeschnitten, wobei Englisch der primäre sprachliche Schwerpunkt ist. Seine Modellparameter reichen von beeindruckenden 7 Milliarden bis zu beachtlichen 70 Milliarden. Llama 2 demonstriert das Potenzial großer Sprachmodelle (LLMs) durch seine verfeinerten Fähigkeiten und seine präzise abgestimmte Leistung.

Meta taucht tiefer in die Architektur von Llama 2 ein und enthüllt, dass die Feinabstimmung des Modells überwachte Feinabstimmung (SFT) mit durch menschliches Feedback unterstütztes Verstärkungslernen (RLHF) verbindet. Bei dieser Kombination steht die Ausrichtung auf menschenzentrierte Normen im Vordergrund und sorgt für ein Gleichgewicht zwischen Effizienz und Sicherheit. Llama 2 basiert auf einem riesigen Reservoir von 2 Billionen Token und bietet sowohl vorab trainierte Modelle für die Generierung verschiedener natürlicher Sprachen als auch die spezielle Llama-2-Chat-Variante für Chat-Assistentenrollen. Unabhängig von der Wahl eines Entwicklers zwischen dem Basis- oder dem erweiterten Modell, Meta's Leitfaden zur verantwortungsvollen Nutzung ist eine unschätzbare Ressource für die Modellverbesserung und -anpassung.

Für diejenigen, die an der Erstellung interaktiver Anwendungen interessiert sind, ist Llama 2 Chat ein guter Ausgangspunkt. Dieses Konversationsmodell ermöglicht die Erstellung maßgeschneiderter Chatbots und Assistenten. Um es noch zugänglicher zu machen, können Sie Llama-2-Chat-Modelle ganz einfach bereitstellen Amazon SageMaker-JumpStart. Ein Angebot von Amazon Sage Makerbietet SageMaker JumpStart eine unkomplizierte Möglichkeit, Llama-2-Modellvarianten direkt bereitzustellen Amazon SageMaker-Studio Notizbücher. Dadurch können sich Entwickler auf ihre Anwendungslogik konzentrieren und gleichzeitig von den SageMaker-Tools für skalierbares Training und Hosting von KI-Modellen profitieren. SageMaker JumpStart bietet außerdem mühelosen Zugriff auf die umfangreiche SageMaker-Bibliothek mit Algorithmen und vorab trainierten Modellen.

In diesem Beitrag untersuchen wir Best Practices für die Aufforderung zum Llama 2 Chat LLM. Wir beleuchten wichtige Prompt-Design-Ansätze und -Methoden anhand praktischer Beispiele.

Voraussetzungen:

Um die Beispiele und empfohlenen Best Practices für Llama 2 Chat auf SageMaker JumpStart auszuprobieren, benötigen Sie folgende Voraussetzungen:

Aufforderungstechniken

Im Kontext von Sprachmodellen und künstlicher Intelligenz bezeichnet Prompting die Praxis, einem Modell eine bestimmte Eingabe oder einen bestimmten Hinweis zu geben, um eine gewünschte Reaktion hervorzurufen. Diese Eingabe dient dem Modell als Leitfaden oder Hinweis auf die Art der erwarteten Ausgabe. Aufforderungstechniken sind unterschiedlich komplex und können von einfachen Fragen bis hin zu detaillierten Szenarien reichen. Fortgeschrittene Techniken wie Zero-Shot-, Few-Shot- und Chain-of-Denk-Prompting verfeinern die Eingabe auf eine Weise, die das Modell anweist, präzisere oder detailliertere Antworten zu liefern. Durch die Nutzung des inhärenten Wissens und der Denkfähigkeit des Modells trainieren diese Techniken das Modell effektiv, Aufgaben auf bestimmte Weise anzugehen.

Im nächsten Abschnitt unterteilen wir die Eingaben und erläutern verschiedene Komponenten. Wir beginnen mit einigen Beispielen dafür, wie verschiedene Aufforderungstechniken aussehen. Die Beispiele werden immer in zwei Codeblöcken angezeigt. Der erste Codeblock ist die Eingabe und der zweite zeigt die Ausgabe des Modells.

Zero-Shot-Eingabeaufforderung

Bei dieser Methode wird einem Sprachmodell eine Aufgabe oder Frage präsentiert, für die es nicht speziell trainiert wurde. Das Modell reagiert dann auf der Grundlage seines inhärenten Wissens, ohne sich zuvor der Aufgabe zu stellen.

%%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

Eingabeaufforderung für wenige Schüsse

Bei diesem Ansatz erhält ein Sprachmodell eine begrenzte Anzahl von wenigen Beispielen, oder Schüsse, einer Aufgabe, bevor auf eine neue Instanz derselben Aufgabe gestoßen wird. Diese Beispiele dienen als Leitfaden und zeigen dem Modell, wie ähnliche Aufgaben zuvor angegangen wurden. Stellen Sie sich das so vor, als würden Sie der Maschine ein kurzes Tutorial geben, um die Aufgabe besser zu verstehen.

%%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

Denkanstoß für eine Kette

Dieser Ansatz erweitert die Argumentationsfähigkeiten von LLMs bei komplizierten Aufgaben. Durch den Einsatz einer Abfolge strukturierter Argumentationsschritte demonstrieren expansive Sprachmodelle häufig eine verbesserte Argumentation durch diese Technik der Gedankenanregung.

%%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

Im vorherigen Beispiel war Llama 2 Chat in der Lage, die Rolle eines Fachmanns anzunehmen, der über Domänenkenntnisse verfügt, und konnte die Argumentation demonstrieren, die zu einer Schlussfolgerung führte.

Lama 2 Chat-Inferenzparameter

Effektive Aufforderungsstrategien können ein Modell dazu führen, bestimmte Ergebnisse zu erzielen. Für diejenigen, die eine genauere Kontrolle über diese Ausgaben wünschen, führt Llama 2 Chat einen umfassenden Satz von Inferenzparametern ein:

  • max_new_tokens – Definiert die Länge der Modellausgabe. Es ist wichtig zu beachten, dass sich dies aufgrund des einzigartigen Vokabulars des Modells nicht direkt auf die Wortzahl übertragen lässt. Ein einzelner Token kann mehr als ein englisches Wort darstellen.
  • Temperatur – Beeinflusst die Zufälligkeit der Ausgabe. Ein höherer Wert fördert kreativere, wenn auch gelegentlich abweichende Ergebnisse.
  • top_p – Mit diesem Parameter können Sie die Konsistenz der Modellantworten optimieren. Ein niedrigerer Wert führt zu direkteren und spezifischeren Antworten, wohingegen ein höherer Wert unterschiedliche Antworten fördert.

Wenn Sie versuchen, die Ausgabe zu optimieren, wird empfohlen, entweder die anzupassen temperature or top_p einzeln, nicht im Tandem. Obwohl diese Parameter optional sind, kann ihre strategische Anwendung die Richtung des Modells in Richtung des beabsichtigten Ergebnisses erheblich beeinflussen.

Einführung in Systemansagen

Llama 2 Chat verwendet eine transformative Funktion namens Systemaufforderungen. Diese Eingabeaufforderungen fungieren als kontextbezogene Rahmenbedingungen und leiten die nachfolgenden Reaktionen des Modells. Durch die Festlegung des Kontexts, Stils oder Tons vor einer primären Abfrage steuern Systemeingabeaufforderungen das Modell effektiv und stellen die Ausrichtung auf die gewünschten Ergebnisse sicher. Diese Fähigkeit erweist sich als unverzichtbar, insbesondere wenn es darum geht, über längere Dialoge hinweg eine bestimmte Persönlichkeit zu bewahren.

In unseren vorherigen Beispielen legt der folgende Teil der Eingabe den Systemkontext fest:

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

Bei der Bereitstellung der Chat-Funktionen von Llama 2 ist es notwendig, die Eingabesyntax an die Feinabstimmung des Modells anzupassen, um optimale Ergebnisse zu gewährleisten. Es ist wie folgt aufgebaut:

  • System – Eine Aufforderung, den Chatbot zu einem Charakterprofil Ihrer Wahl zu führen. Es könnte nach Ihren Wünschen zugeschnitten werden (z. B. „Sie sind ein Diener“). Wenn Sie dies weglassen, verfügt das Modell nicht mehr über ein standardmäßiges generisches Profil. Es werden Antworten ohne spezifische Charakter- oder Verhaltensanweisungen generiert.

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

  • Mitglied – Eine Nachricht von einem Benutzer.

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

  • Assistentin – Das Ausgabeergebnis des Modells.

Um die Leistungsfähigkeit von Systemaufforderungen besser zu verstehen, sollten Sie Llama 2 Chat in Betracht ziehen, der die Rolle eines Minion annimmt, einer Figur aus einem Zeichentrickfilm. Bei herkömmlichen Interaktionen würde jeder Benutzerbefehl mit einem Vorläufer beginnen („Sie sind ein hilfsbereiter Diener“), um sicherzustellen, dass das Modell seinen Charakter behält. Aber mit Systemaufforderungen wird diese Redundanz umgangen, sodass Llama 2 Chat die gegebene Persona nahtlos umarmen und aufrechterhalten kann, was zu flüssigeren und kohärenteren Interaktionen führt.

Praktische Demonstration

Beginnen wir zur Demonstration mit dem folgenden Code:

%%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

Diese Interaktion veranschaulicht die Fähigkeit des Modells, die hilfreiche Minion-Persönlichkeit zu übernehmen und Benutzern ein konsistentes und ansprechendes Erlebnis zu bieten und gleichzeitig die Wiederholung von Eingaben zu reduzieren.

Der Bereich der Systemansagen ist jedoch nicht auf fiktive Charaktere beschränkt. Seine Vielseitigkeit glänzt auch in ernsteren Kontexten. Ganz gleich, ob es darum geht, komplizierte technische Probleme zu lösen oder eine umfassende Dokumentation zu erstellen, die Eingabeaufforderungen des Systems gestalten Interaktionen geschickt so, dass sie der gewünschten Tiefe und dem gewünschten Ton entsprechen. Bei chatbasierten Plattformen ist die Integration von Systemansagen nicht nur ratsam, sondern unerlässlich! Betrachten Sie sie als Blaupause: Sie setzen Grenzen für das Verhalten von Llama 2 Chat, leiten die Reaktionswege und erlegen wesentliche Einschränkungen auf.

Professionelle Kontextdemonstration

In diesem nächsten Beispiel bitten wir das Modell, ein professionelleres Verhalten anzunehmen:

%%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

Die Genauigkeit und Kontrollierbarkeit der Ausgänge sind von entscheidender Bedeutung. Systemaufforderungen in Llama 2 Chat stellen eine fortschrittliche Methode dar, um das Modell sorgfältig zu steuern und sicherzustellen, dass es den Benutzeranforderungen entspricht. Schauen wir uns zwei veranschaulichende Anwendungsfälle genauer an:

  • Szenario 1 – Wenn man sich das Modell als Wissensprofessor für Englisch vorstellt, sucht ein Benutzer nach einer eingehenden Analyse einer bestimmten Zusammenfassung. Die Ausgabe des Modells spiegelt ein Gespräch wider, das man mit einem englischen Gelehrten inmitten klassischer Literatur führen könnte:
%%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
  • Szenario 2 – Der Benutzer legt Wert auf Präzision und weist das Modell an, sich strikt an die vorgegebene Richtlinie zu halten. Das Ergebnis ist eine prägnante, direkte Antwort ohne unnötige Ausarbeitungen:
%%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

Die Unterscheidung zwischen diesen Szenarien unterstreicht den adaptiven Charakter von Systemaufforderungen. Sie haben die Flexibilität, sie zu verfeinern, unabhängig davon, ob das Ziel darin besteht, detaillierte Erzählungen hervorzurufen oder prägnante, direkte Antworten zu erhalten. Durch diese Eingabeaufforderungen können Sie den Ausgabebereich des Modells definieren und so sicherstellen, dass es nahtlos mit der jeweiligen Aufgabe übereinstimmt.

Textzusammenfassung und kontextbezogene Beantwortung von Fragen

Systemaufforderungen können auch unkompliziert sein und den Kontext zur Beantwortung von Fragen erzwingen. In diesem Beispiel bitten wir Llama 2 Chat, die Rolle eines Chatbots anzunehmen und ihn nur Fragen des Symbols beantworten zu lassen Aktionärsbrief von Amazon aus dem Jahr 1997 geschrieben von Jeff Bezos.

Wir lesen den Text und fügen ihn durch String-Interpolation in die Systemeingabeaufforderung ein. Das vollständige Beispiel finden Sie im beiliegenden Notizbuch.

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

Wie gezeigt, kann sich Llama 2 Chat innerhalb von Systemaufforderungen an strenge Leitplanken halten, die es ihm ermöglichen, Fragen aus einem bestimmten Kontext auf sinnvolle Weise zu beantworten. Diese Fähigkeit ebnet den Weg für Techniken wie Retrieval Augmented Generation (RAG), die bei Kunden sehr beliebt sind. Weitere Informationen zum RAG-Ansatz mit SageMaker finden Sie unter Retrieval Augmented Generation (RAG).

Zusammenfassung

Der Einsatz von Llama 2 Chat zur Erzielung einer starken Leistung erfordert sowohl technisches Fachwissen als auch strategische Einblicke in das Design. Um die umfassenden Fähigkeiten des Modells vollständig nutzen zu können, müssen Sie kreative Aufforderungstechniken verstehen und anwenden sowie Inferenzparameter anpassen. Ziel dieses Beitrags ist es, effektive Methoden zur Integration von Llama 2 Chat mit SageMaker zu skizzieren. Wir haben uns auf praktische Tipps und Techniken konzentriert und Ihnen einen effektiven Weg erklärt, wie Sie die leistungsstarken Funktionen von Llama 2 Chat nutzen können.

Im Folgenden sind die wichtigsten Erkenntnisse aufgeführt:

  • Dynamische Steuerung mit Ambiente – Die Temperaturregelung im Llama 2 Chat spielt eine zentrale Rolle, die weit über einfache Anpassungen hinausgeht. Sie fungieren als Kompass des Modells und leiten seine kreative Breite und analytische Tiefe. Wenn Sie mit diesen Bedienelementen den richtigen Ton treffen, können Sie von einer Welt kreativer Erkundung zu einer Welt präziser und konsistenter Ergebnisse gelangen.
  • Befehlsklarheit – Während wir uns durch das Labyrinth datenintensiver Aufgaben bewegen, insbesondere in Bereichen wie Datenüberprüfungen, wird die Präzision unserer Anweisungen zu unserem Polarstern. Wenn Llama 2 Chat mit Klarheit geführt wird, strahlt es am hellsten und passt seine umfangreichen Fähigkeiten an unsere spezifischen Absichten an.
  • Strukturierte Einblicke – Mit seinem schrittweisen Ansatz ermöglicht Llama 2 Chat die methodische Erkundung großer Datenmengen und ermöglicht es Ihnen, nuancierte Muster und Erkenntnisse zu entdecken, die möglicherweise nicht auf den ersten Blick erkennbar sind.

Bei der Integration von Llama 2 Chat mit SageMaker JumpStart geht es nicht nur um die Nutzung eines leistungsstarken Tools – es geht darum, eine Reihe von Best Practices zu entwickeln, die auf Ihre individuellen Bedürfnisse und Ziele zugeschnitten sind. Sein volles Potenzial ergibt sich nicht nur aus dem Verständnis der Stärken von Llama 2 Chat, sondern auch aus der kontinuierlichen Verfeinerung der Art und Weise, wie wir mit dem Modell arbeiten. Mit dem Wissen aus diesem Beitrag können Sie Llama 2 Chat entdecken und damit experimentieren – Ihre KI-Anwendungen können von dieser praktischen Erfahrung erheblich profitieren.

Downloads


Über die Autoren

Jin Tan Ruan ist ein Prototyping-Entwickler im AWS Industries Prototyping and Customer Engineering (PACE)-Team, spezialisiert auf NLP und generative KI. Mit einem Hintergrund in der Softwareentwicklung und neun AWS-Zertifizierungen bringt Jin einen großen Erfahrungsschatz mit, um AWS-Kunden bei der Verwirklichung ihrer KI/ML- und generativen KI-Visionen mithilfe der AWS-Plattform zu unterstützen. Er hat einen Master-Abschluss in Informatik und Softwaretechnik von der University of Syracuse. Außerhalb der Arbeit spielt Jin gerne Videospiele und taucht in die spannende Welt der Horrorfilme ein. Sie finden Jin auf Linkedln. Lasst uns verbinden!

Dr. Farooq Sabir ist ein leitender Lösungsarchitekt für künstliche Intelligenz und maschinelles Lernen bei AWS. Er hat einen PhD- und MS-Abschluss in Elektrotechnik von der University of Texas at Austin und einen MS in Informatik vom Georgia Institute of Technology. Er hat über 15 Jahre Berufserfahrung und unterrichtet und betreut auch gerne College-Studenten. Bei AWS hilft er Kunden bei der Formulierung und Lösung ihrer Geschäftsprobleme in den Bereichen Datenwissenschaft, maschinelles Lernen, Computer Vision, künstliche Intelligenz, numerische Optimierung und verwandte Bereiche. Er lebt in Dallas, Texas, und seine Familie liebt es zu reisen und lange Autofahrten zu unternehmen.

Pronoy Chopra ist Senior Solutions Architect im Startups AI/ML-Team. Er hat einen Master-Abschluss in Elektro- und Computertechnik und unterstützt mit Leidenschaft Start-ups beim Aufbau der nächsten Generation von Anwendungen und Technologien auf AWS. Er arbeitet gerne im Bereich der generativen KI und des IoT und hat zuvor zwei Startups mitgegründet. In seiner Freizeit spielt er gerne, liest und programmiert Software/Hardware.

spot_img

Neueste Intelligenz

VC-Café

VC-Café

spot_img