This Python script creates a password-protected ZIP file using the pyzipper library. It allows you to specify the files to include in the ZIP and set a password for encryption. The resulting ZIP file requires the provided password to access its contents, providing an additional layer of security.
In this exercise, you'll practice prompt engineering and compare the responses of different large language models. You'll use the models you set up access to in Amazon Bedrock earlier in the lesson. You can compare the generative text output of multiple large language models using the Text Playground tool in Amazon Bedrock.https://youtu.be/nvyhdUoQxdA
Different open-source LLMs have different numbers of parameters and are trained with different datasets and for different tasks:
Therefore, they'll give different answers to the same prompts. The Amazon Bedrock console playgrounds allow you to experiment with models and prompts and evaluate their output before using them. There are playgrounds for text, chat, and image models.
Within each playground, you can enter prompts and experiment with inference parameters. Prompts are one or more sentences of text that set up a scenario, question, or task for a model. We'll give you some prompts, and you can try some of your own!
Earlier in the lesson, you set up access to the following models in the Accessing Foundation Models exercise:
**Jurassic-2 Mid
Llama Chat 70B**
If you did not set up access to these models in the exercise, please go back and do so now before attempting this exercise.
Step 1: Set up Models in the Chat Playground
Launch the Cloud Gateway and open the AWS Console. Navigate to Amazon Bedrock using the search box in the top of the AWS console. Make sure you can access the Jurrasic-2 Mid and Llama Chat 70B models by choosing Model Access from the Amazon Bedrock left navigation menu. The list of models should show Access granted for these two models.
From the Amazon Bedrock left navigation panel, under Playgrounds, click on Chat to navigate to the Chat Playground.
Click on Select model to open the Select model dialog box.
In the model selection dialog that opens, choose the Jurassic-2 Mid model, then click Apply
Step 2: Practice Some Prompts!
After you click Apply, you'll be in the playground interface, where you'll see a dialog box on the left, and inference parameters on the right. Try your first prompt. In the text box on the left of the Run button, type the prompt "What is the capitol of France" then click Run.
You'll see the model's response, highlighted in purple. Next, type the prompt "What is Paris known for?" and click Run again.
Now, change some of the inference parameters - Change the temperature settings to 0 and 1 and Max completion length to 3000, and the Top P sampling setting to 1 or 0, and run more prompts. Here are some prompts to run, or think of your own. Try prompts for text completion, as well as instructions.
(question answering) "What is Paris known for?"
(text completion) "In Paris, a fish"
(instruction) "Create a story about a fish in Paris"
Based on how the model was trained and its number of parameters, it may be better at some of these tasks than others. Some models are trained on text completion, while others are trained on question answering and instructions. Pay attention to how the model holds context during chat. Does it refer to previous output in the conversation correctly if you use words in your prompt like "it"?
Note:
If the response violates the content moderation policy, Amazon Bedrock doesn't display it.
Step 3: Inspect Model Metrics
Every time you run a prompt, it costs a specific amount of money based on the model and the length of your prompt (tokens) and the amount of output the model generates (tokens). You can see this amount of money, how long the model took to respond (latency), and other metrics like token counts in the Model Metrics section below the prompt dialog.
Step 4: Compare Models
Now, add another model to the chat playground, and run the same prompt against two models to compare their responses. This is a step toward model evaluation - testing models with the same prompts to evaluate their output on tasks like text summarization, question and answer, text classification, and open-ended text generation.
Toggle the Compare Mode setting in the top right of the Chat Playground to "on". Then, click the Select Model button to choose another model.
The model selection dialog opens, and this time you'll choose the Meta Llama 2 Chat 70B model, in order to compare it to the Jurassic-2 Mid model. When you're done choosing the Llama 2 Chat 70B model, click Apply in the bottom right corner of the Select Model dialog.
Now, when you run a prompt, you'll see 2 models and their responses. You can change the inference parameters of each model independently using the parameters icon to the right of each Model dialog
Step 5: Try a Chain-Of-Thought Prompt
A chain-of-thought prompt is a type of input given to a large language model (LLM) that guides it through a step-by-step reasoning process. Instead of simply asking a question or requesting a task, the prompt includes a logical sequence of thoughts or reasoning steps that lead to an answer or conclusion. This method is especially useful for complex queries where breaking down the problem helps the model generate more accurate and coherent responses.
Chain-of-Thought Prompt:
"I want to write a blog post about the basics of video editing for beginners. First, I should start with an introduction that explains why video editing is a valuable skill in today's digital world. Then, I need to outline the key steps in the video editing process, such as importing footage, cutting and arranging clips, adding transitions, working with audio, and applying effects and color correction. Each step should be explained in simple, accessible language. It's also important to suggest some beginner-friendly video editing software options, like Adobe Premiere Pro, Final Cut Pro, and more affordable or free alternatives like DaVinci Resolve and iMovie. Finally, I should wrap up the post with some encouraging words about practice and improvement over time, and possibly suggest some online resources or tutorials for further learning. What would be a good structure and content for such a blog post?"
Compare the responses of each model and their inference settings, which one do you think performed better?
Try Another Chain-Of-Thought Prompt:
"I want to create a captivating social media post for our new product, a state-of-the-art wireless earbud set. First, I should grab attention with a catchy opening line about the freedom of wireless audio. Next, highlight the key features like superior sound quality, long battery life, and seamless connectivity. It's important to mention the compact, ergonomic design that ensures comfort. A call-to-action should be included, encouraging followers to visit our website to learn more or make a purchase. Also, visually, the post should feature high-quality images of the earbuds, preferably showing them in use. How should I craft this social media post to make it engaging and persuasive?"
In this exercise, you'll practice prompt engineering and compare the responses of different large language models. You'll use the models you set up access to in Amazon Bedrock earlier in the lesson. You can compare the generative text output of multiple large language models using the Text Playground tool in Amazon Bedrock. https://youtu.be/nvyhdUoQxdA
Different open-source LLMs have different numbers of parameters and are trained with different datasets and for different tasks:
Question answering Categorization Summarization Domain Knowledge
Therefore, they'll give different answers to the same prompts. The Amazon Bedrock console playgrounds allow you to experiment with models and prompts and evaluate their output before using them. There are playgrounds for text, chat, and image models.
Within each playground, you can enter prompts and experiment with inference parameters. Prompts are one or more sentences of text that set up a scenario, question, or task for a model. We'll give you some prompts, and you can try some of your own!
Earlier in the lesson, you set up access to the following models in the Accessing Foundation Models exercise:
If you did not set up access to these models in the exercise, please go back and do so now before attempting this exercise.
Step 1: Set up Models in the Chat Playground Launch the Cloud Gateway and open the AWS Console. Navigate to Amazon Bedrock using the search box in the top of the AWS console. Make sure you can access the Jurrasic-2 Mid and Llama Chat 70B models by choosing Model Access from the Amazon Bedrock left navigation menu. The list of models should show Access granted for these two models.
From the Amazon Bedrock left navigation panel, under Playgrounds, click on Chat to navigate to the Chat Playground.
Click on Select model to open the Select model dialog box.
In the model selection dialog that opens, choose the Jurassic-2 Mid model, then click Apply
Step 2: Practice Some Prompts! After you click Apply, you'll be in the playground interface, where you'll see a dialog box on the left, and inference parameters on the right. Try your first prompt. In the text box on the left of the Run button, type the prompt "What is the capitol of France" then click Run.
You'll see the model's response, highlighted in purple. Next, type the prompt "What is Paris known for?" and click Run again.
Now, change some of the inference parameters - Change the temperature settings to 0 and 1 and Max completion length to 3000, and the Top P sampling setting to 1 or 0, and run more prompts. Here are some prompts to run, or think of your own. Try prompts for text completion, as well as instructions.
(question answering) "What is Paris known for?" (text completion) "In Paris, a fish" (instruction) "Create a story about a fish in Paris" Based on how the model was trained and its number of parameters, it may be better at some of these tasks than others. Some models are trained on text completion, while others are trained on question answering and instructions. Pay attention to how the model holds context during chat. Does it refer to previous output in the conversation correctly if you use words in your prompt like "it"?
Note:
If the response violates the content moderation policy, Amazon Bedrock doesn't display it.
Step 3: Inspect Model Metrics Every time you run a prompt, it costs a specific amount of money based on the model and the length of your prompt (tokens) and the amount of output the model generates (tokens). You can see this amount of money, how long the model took to respond (latency), and other metrics like token counts in the Model Metrics section below the prompt dialog.
Step 4: Compare Models Now, add another model to the chat playground, and run the same prompt against two models to compare their responses. This is a step toward model evaluation - testing models with the same prompts to evaluate their output on tasks like text summarization, question and answer, text classification, and open-ended text generation.
Toggle the Compare Mode setting in the top right of the Chat Playground to "on". Then, click the Select Model button to choose another model.
The model selection dialog opens, and this time you'll choose the Meta Llama 2 Chat 70B model, in order to compare it to the Jurassic-2 Mid model. When you're done choosing the Llama 2 Chat 70B model, click Apply in the bottom right corner of the Select Model dialog.
Now, when you run a prompt, you'll see 2 models and their responses. You can change the inference parameters of each model independently using the parameters icon to the right of each Model dialog
Step 5: Try a Chain-Of-Thought Prompt A chain-of-thought prompt is a type of input given to a large language model (LLM) that guides it through a step-by-step reasoning process. Instead of simply asking a question or requesting a task, the prompt includes a logical sequence of thoughts or reasoning steps that lead to an answer or conclusion. This method is especially useful for complex queries where breaking down the problem helps the model generate more accurate and coherent responses.
Chain-of-Thought Prompt:
"I want to write a blog post about the basics of video editing for beginners. First, I should start with an introduction that explains why video editing is a valuable skill in today's digital world. Then, I need to outline the key steps in the video editing process, such as importing footage, cutting and arranging clips, adding transitions, working with audio, and applying effects and color correction. Each step should be explained in simple, accessible language. It's also important to suggest some beginner-friendly video editing software options, like Adobe Premiere Pro, Final Cut Pro, and more affordable or free alternatives like DaVinci Resolve and iMovie. Finally, I should wrap up the post with some encouraging words about practice and improvement over time, and possibly suggest some online resources or tutorials for further learning. What would be a good structure and content for such a blog post?"
Compare the responses of each model and their inference settings, which one do you think performed better?
Try Another Chain-Of-Thought Prompt:
"I want to create a captivating social media post for our new product, a state-of-the-art wireless earbud set. First, I should grab attention with a catchy opening line about the freedom of wireless audio. Next, highlight the key features like superior sound quality, long battery life, and seamless connectivity. It's important to mention the compact, ergonomic design that ensures comfort. A call-to-action should be included, encouraging followers to visit our website to learn more or make a purchase. Also, visually, the post should feature high-quality images of the earbuds, preferably showing them in use. How should I craft this social media post to make it engaging and persuasive?"