From 70549261dfaeb1c80165c0bc6b2df3aa1998568f Mon Sep 17 00:00:00 2001 From: Alexis Cook Date: Mon, 15 Apr 2024 18:23:14 -0600 Subject: [PATCH 1/3] changes to chapters 2, 3, 4 --- notebooks/llmu/Building_a_Chatbot.ipynb | 418 ++++++++++++------ .../Parameters_for_Controlling_Outputs.ipynb | 100 +++-- .../llmu/Prompt_Engineering_Basics.ipynb | 198 +++++++-- 3 files changed, 515 insertions(+), 201 deletions(-) diff --git a/notebooks/llmu/Building_a_Chatbot.ipynb b/notebooks/llmu/Building_a_Chatbot.ipynb index 59cc8d1d8..70a11ab21 100644 --- a/notebooks/llmu/Building_a_Chatbot.ipynb +++ b/notebooks/llmu/Building_a_Chatbot.ipynb @@ -67,7 +67,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -88,14 +88,34 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 27, "metadata": { "id": "cDwP5nHwO0Ap" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "import uuid\n", "import cohere\n", + "import json\n", "from cohere import ChatMessage" ] }, @@ -108,9 +128,28 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "# Paste your API key here. Remember to not share publicly\n", "co = cohere.Client(\"COHERE_API_KEY\") " @@ -124,12 +163,14 @@ "source": [ "## Step 1: Quickstart\n", "\n", - "The `message` parameter is the only required parameter for the Chat endpoint. We call the endpoint with `co.chat()`, and get the main content of the response from the `text` value." + "The `message` parameter is the only required parameter for the Chat endpoint. \n", + "\n", + "We call the endpoint with `co.chat()`, and get the main content of the response from the `text` value." ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 19, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -138,11 +179,29 @@ "outputId": "1504ef60-cccd-4a9b-f708-ea4f23404af7" }, "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "name": "stdout", "output_type": "stream", "text": [ - "Hi! Hello there! How's it going? I hope you're having a fantastic day so far. Is there anything I can help you with?\n" + "Hello! How can I help you today?\n" ] } ], @@ -166,7 +225,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 22, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -175,19 +234,35 @@ "outputId": "93741452-f257-43e1-969f-344ae9ec91bd" }, "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "name": "stdout", "output_type": "stream", "text": [ - "Hello! It's great to connect with you. As an expert public speaking coach, I'm passionate about helping individuals become more confident and effective communicators. Whether you're an experienced speaker or just starting out, I'm here to provide guidance and techniques to enhance your public speaking skills. \n", - "\n", - "What brings you here today? Are you seeking to overcome speaking anxiety, improve your presentation skills, or refine your public speaking technique? Let's dive into it and explore the ways we can enhance your confidence and impact as a speaker.\n" + "I'm here to help you improve your public speaking skills and build your confidence. What would you like to work on today?\n" ] } ], "source": [ "response = co.chat(message=\"Hello\",\n", - " preamble=\"You are an expert public speaking coach\")\n", + " preamble=\"You are an expert public speaking coach. Don't use any greetings.\")\n", "print(response.text)" ] }, @@ -208,7 +283,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 23, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -217,33 +292,53 @@ "outputId": "33ca5c3d-4cc7-49cc-c1ed-22936f1eef3d" }, "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "name": "stdout", "output_type": "stream", "text": [ - "Hello there! Engaging with your audience is a crucial aspect of public speaking. Here are some techniques to help you capture and sustain your audience's attention:\n", + "Sure! Here are some techniques for effective audience engagement:\n", "\n", - "1. Begin with a Bang: Start your speech with an attention-grabbing opening. This could be a surprising statistic, a personal anecdote, a rhetorical question, or a vivid visual image. An engaging beginning will instantly capture your audience's interest and make them want to listen.\n", + "- **Make Eye Contact:** Look at different individuals in the audience and try to maintain eye contact for a few seconds at a time. This helps create a sense of connection and makes your speech more intimate.\n", "\n", - "2. Know Your Audience: Understanding your audience is vital. Tailor your content and delivery to their interests, knowledge level, and expectations. Use language and references relevant to your audience to establish a connection.\n", + "- **Use Gestures:** Incorporate natural hand gestures to emphasize your points and add variety to your delivery. This helps to keep your audience focused and engaged.\n", "\n", - "3. Use Stories and Anecdotes: People love stories. Incorporate personal or relatable anecdotes to make your speech more memorable. Stories add a human touch, making it easier for the audience to connect with your message.\n", + "- **Vary Your Tone and Volume:** Avoid monotony by varying your tone and volume. Emphasize important words or phrases, and use pauses for effect to highlight key points.\n", "\n", - "4. Interactive Elements: Consider incorporating interactive activities or polls to engage your audience actively. You could ask questions, invite feedback, or conduct a short quiz related to your topic.\n", + "- **Ask Questions:** Pose rhetorical questions to your audience to get them thinking about your topic. You can also directly ask for their opinions or input, which encourages active participation.\n", "\n", - "5. Visual Aids: Utilize visual aids like slides, infographics, videos, or props to enhance your presentation. Visual elements can help convey information more engagingly and break up the monotony of a spoken-only presentation.\n", + "- **Tell Stories:** Incorporate relevant anecdotes or personal stories to illustrate your points. Stories are memorable and help your audience connect with you on a deeper level.\n", "\n", - "6. Vary Your Tone and Pace: Modulate your voice, changing its volume, tone, and pace to emphasize key points and add variety. For instance, slow down during emotional parts or speed up when sharing exciting facts.\n", + "- **Use Humor:** Depending on the context, appropriate humor can lighten the mood, engage your audience, and make your speech more enjoyable.\n", "\n", - "7. Body Language and Eye Contact: Use your body language to engage the audience. Maintain good posture, make deliberate gestures, and establish eye contact with different parts of the audience to create a connection.\n", + "- **Incorporate Visual Aids:** Use slides, props, or demonstrations to enhance your presentation. Visual aids can help simplify complex concepts and keep your audience visually engaged.\n", "\n", - "8. Personal Touch: Share your passion and enthusiasm for the topic. Your genuine excitement can be contagious and help capture the audience's interest.\n", + "- **Encourage Interaction:** If appropriate, involve your audience in activities or exercises related to your topic. This could be a simple show of hands, a group discussion, or a more involved activity.\n", "\n", - "9. Humor: A well-placed joke or lighthearted moment can break the ice and engage your audience. Ensure the humor aligns with your topic and doesn't offend anyone.\n", + "- **Use Strategic Pauses:** Pauses give your audience a chance to absorb your message and emphasize important points. They also help you to take a breath and maintain a relaxed pace.\n", "\n", - "10. Call to Action: End with a compelling call to action. Provide the audience with a tangible takeaway, inspiring them to reflect on your message and act upon it.\n", + "- **Tailor Your Content:** Know your audience and tailor your content to their interests and expectations. Use examples and references that are relevant to them to increase engagement.\n", "\n", - "Remember, engaging audience interaction is an art that develops over time. Pay attention to your audience's body language and adapt your techniques accordingly. Good luck, and happy speaking!" + "- **Be Passionate and Energetic:** Your enthusiasm for your topic can be contagious. Let your passion show through your body language, tone of voice, and facial expressions.\n", + "\n", + "Remember, effective audience engagement is about creating a connection and making your speech memorable. By using these techniques, you can make your presentation dynamic and enjoyable for your audience." ] } ], @@ -282,14 +377,16 @@ "\n", "The Chat endpoint supports state management by persisting the conversation history. As a conversation progresses, the endpoint continuously updates the conversation history. This means developers don’t have to deal with the complexity and inconvenience of managing conversation history in their application.\n", "\n", - "To use this feature, use the `conversation_id` parameter, which is a unique string you assign to a conversation. \n", + "To use this feature, use the `conversation_id` parameter, which is a unique string you assign to a conversation. We'll use the `uuid` library to do this.\n", + "\n", + "Putting everything together, let’s now build a simple chat interface that takes in a user message, generates the chatbot response, automatically updates the conversation history, and repeats these steps until the user quits the conversation. \n", "\n", - "We use the `uuid` library to generate a unique `conversation_id` for each conversation. " + "As described before, in streaming mode, the Chat endpoint generates a series of objects. To get the conversation history, we take the object with `event_type` of `\"stream-end\"` and save it as a new variable `chat_history`." ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 34, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -298,6 +395,24 @@ "outputId": "381b17da-9902-44dc-de2a-6893c5b792c3" }, "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "name": "stdout", "output_type": "stream", @@ -305,77 +420,35 @@ "Starting the chat. Type \"quit\" to end.\n", "\n", "User: Hello\n", - "Chatbot: Hello! It's great to connect with you. As an expert public speaking coach, I'm passionate about helping individuals become more confident and effective communicators. Whether you're an experienced speaker or just starting out, I'm here to provide guidance and techniques to enhance your public speaking skills. \n", - "\n", - "What brings you to seek public speaking coaching? Are you looking to overcome anxiety, improve your presentation skills, or refine your messaging? Understanding your goals will help me tailor our sessions to your specific needs. \n", - "\n", - "I'm excited to embark on this journey with you and support you in achieving your public speaking objectives. Let's get started!\n", + "Chatbot: Hello! How can I help you today?\n", "----------------------------------------------------------------------------------------------------\n", "\n", "User: I'd like to learn about techniques for effective audience engagement\n", - "Chatbot: Excellent! Engaging your audience is a crucial aspect of public speaking, and there are several effective techniques to achieve that. Here are some strategies to help you captivate and maintain your audience's attention: \n", - "\n", - "1. Begin with a Bang: Start your speech with an attention-grabbing opening. This could be a surprising statistic, a personal anecdote, a thought-provoking question, or a vivid visual image. A powerful opening will pique your audience's interest and make them want to listen.\n", - "\n", - "2. Humanize Your Message: Connect with your audience by sharing personal stories or anecdotes relevant to your topic. Adding a human element makes your speech more relatable and engaging. People are more likely to stay invested if they can relate to your experience.\n", - "\n", - "3. Use Visual Aids Effectively: Visual aids, such as slides or props, can enhance your message and keep your audience engaged. Ensure your visuals are clear, concise, and appealing. Avoid cluttering your slides with too much text. Instead, use images, graphs, or diagrams that support your points.\n", - "\n", - "4. Vary Your Vocal Volume and Tone: Modulate your voice by changing your volume and tone to emphasize key points and add emphasis. A well-placed pause can also create drama and draw your audience's focus. Avoid monotone delivery, as it can make your speech dull.\n", - "\n", - "5. Body Language and Eye Contact: Use your body language to engage the audience. Maintain good posture, gesture naturally, and make deliberate eye contact with different individuals in the crowd. This demonstrates confidence and encourages others to follow your lead.\n", - "\n", - "6. Interactive Elements: Incorporate interactive activities or questions that involve the audience. This could be in the form of polls, quizzes, or thought exercises. Allowing time for audience participation keeps them actively engaged.\n", - "\n", - "7. Tell Stories, Not Just Facts: Storytelling captures attention and helps your audience connect emotionally with your message. Share stories that illustrate your points, making them more memorable.\n", - "\n", - "8. Humor and Laughter: Appropriate humor can lighten the mood and engage your audience. Ensure the jokes are relevant, tasteful, and appropriate for the setting and audience.\n", - "\n", - "9. Visualize Data: If you're presenting data or statistics, find creative ways to visualize them. Infographics, charts, or graphs can make complex information more digestible and engaging.\n", - "\n", - "10. End with a Bang: Just as you began with a powerful opening, finish with a memorable closing. Summarize your key points, leave the audience with a compelling call to action, or pose a thought-provoking question. This will leave a lasting impression.\n", - "\n", - "Remember, each audience is different, so observe their body language and adapt your techniques accordingly. Engaging audiences can be a challenge, but with these strategies and some practice, you'll become a master at capturing and sustaining their attention. \n", - "\n", - "If you wish to further refine these skills, I'd be delighted to offer more tailored guidance and provide feedback. Public speaking is a journey, and improving your audience engagement techniques is an ongoing process.\n", + "Chatbot: Sure! Here are some techniques for effective audience engagement:\n", + "\n", + "- Make eye contact with your audience and use hand gestures to emphasize your points.\n", + "- Use a clear and concise language that your audience can easily understand.\n", + "- Vary your tone and pace to keep your audience interested.\n", + "- Use visual aids such as slides, props, or demonstrations to help illustrate your points.\n", + "- Tell stories or anecdotes to help your audience connect with your message on a personal level.\n", + "- Ask questions to involve your audience and encourage them to think about your topic.\n", + "- Use humor appropriately to lighten the mood and engage your audience.\n", + "- Be enthusiastic and passionate about your topic to show your audience that you care about what you're speaking about.\n", + "- Practice your speech or presentation beforehand to ensure that you are comfortable and confident when delivering it.\n", + "- Pay attention to your audience's body language and adjust your delivery accordingly.\n", + "\n", + "Remember, effective audience engagement is about creating a connection with your audience and making your message memorable and meaningful for them.\n", "----------------------------------------------------------------------------------------------------\n", "\n", "User: Could you elaborate on the third point.\n", - "Chatbot: Certainly! Using visual aids is a powerful way to enhance your presentation and keep your audience engaged. Visual aids refer to any visual elements you incorporate into your speech to illustrate and support your message. These can include slides, images, videos, infographics, props, or even your own body language. Here's a more detailed breakdown of this point:\n", - "\n", - "Effective Use of Slides:\n", - "\n", - "Keep It Simple: When creating slides, ensure they are clean, clear, and easy to read. Avoid cramming too much text or unnecessary images. Each slide should convey one main idea or concept.\n", - "\n", - "Visual Appeal: Choose color schemes that are visually appealing and align with your topic. Use high-quality images, diagrams, or charts that are relevant to your message. Avoid using generic clipart, as it may distract or detract from your presentation.\n", - "\n", - "Size and Legibility: Ensure the font size is large enough to be visible from all areas of the venue. Use simple font styles that are legible even from a distance.\n", - "\n", - "Slide Transition: Transition slides smoothly and seamlessly. Avoid using distracting animations or excessive transitions that could divert attention from your message.\n", - "\n", - "Concise Points: Each slide should support a specific point you're making. Avoid including unnecessary details or information overload. Slides are meant to enhance your speech, not distract from it.\n", - "\n", - "Incorporating Props:\n", - "\n", - "Props can make your presentation more tangible and memorable. They can help illustrate your points in a physical, concrete way.\n", - "\n", - "Be creative and choose props related to your topic. For instance, if discussing the importance of recycling, you might bring a recycling bin and demonstrate the process.\n", - "\n", - "Ensure the props are clean, well-maintained, and easy to manage. You don't want the focus to shift from your message to the prop itself.\n", + "Chatbot: Certainly! Varying your tone and pace is an important technique to keep your audience engaged. Here are some ways to do this:\n", "\n", - "Prop transitions should also be smooth. Have an assistant help you if needed, so you can focus on your delivery.\n", + "- Change your tone of voice to emphasize important points or to reflect the emotion of what you're saying. For example, you might raise your voice to show excitement or lower it to show seriousness.\n", + "- Speed up your pace to create a sense of urgency or excitement, and slow down to emphasize important points or to allow your audience to absorb complex information.\n", + "- Use pauses to give your audience time to reflect on what you've just said and to create a sense of anticipation for what's coming next.\n", + "- Try to avoid monotony by varying your intonation and volume. This will help to keep your audience interested and engaged.\n", "\n", - "Gestures and Body Language:\n", - "\n", - "Your body language, including gestures, can also serve as a visual aid. Use deliberate and purposeful movements to emphasize your points.\n", - "\n", - "Practice your gestures and body movements so they appear natural and authentic.\n", - "\n", - "Maintain good posture and avoid standing stiffly. Move around the stage or podium to engage different areas of the audience.\n", - "\n", - "Remember, the goal is to make your presentation visually appealing and engaging. Visual aids should complement and support your message, aiding in better audience comprehension and enjoyment. \n", - "\n", - "When used effectively, visual aids can help you connect with your audience, make your speech more memorable, and leave a lasting impact.\n", + "By varying your tone and pace, you can add interest and emphasis to your speech, and help your audience to stay focused and engaged.\n", "----------------------------------------------------------------------------------------------------\n", "\n", "User: quit\n", @@ -412,10 +485,60 @@ " for event in stream:\n", " if event.event_type == \"text-generation\":\n", " print(event.text, end='')\n", + " if event.event_type == \"stream-end\":\n", + " chat_history = event.response.chat_history\n", "\n", " print(f\"\\n{'-'*100}\\n\")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Next, we print the full conversation history." + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "role='USER' message='Hello' generation_id='ab9f458a-d4c9-4fb5-917d-a9ec4c2fdaad' response_id='c023b477-00dc-4444-b725-d1b02af356c0'\n", + "role='CHATBOT' message='Hello! How can I help you today?' generation_id='a87b88b0-596b-4c63-a297-5213cf0da507' response_id='c023b477-00dc-4444-b725-d1b02af356c0'\n", + "role='USER' message=\"I'd like to learn about techniques for effective audience engagement\" generation_id='437b1b3e-b558-4283-b35a-4525ef3a28d4' response_id='e75e7393-4b13-48fc-9611-bd33740ffa21'\n", + "role='CHATBOT' message=\"Sure! Here are some techniques for effective audience engagement:\\n\\n- Make eye contact with your audience and use hand gestures to emphasize your points.\\n- Use a clear and concise language that your audience can easily understand.\\n- Vary your tone and pace to keep your audience interested.\\n- Use visual aids such as slides, props, or demonstrations to help illustrate your points.\\n- Tell stories or anecdotes to help your audience connect with your message on a personal level.\\n- Ask questions to involve your audience and encourage them to think about your topic.\\n- Use humor appropriately to lighten the mood and engage your audience.\\n- Be enthusiastic and passionate about your topic to show your audience that you care about what you're speaking about.\\n- Practice your speech or presentation beforehand to ensure that you are comfortable and confident when delivering it.\\n- Pay attention to your audience's body language and adjust your delivery accordingly.\\n\\nRemember, effective audience engagement is about creating a connection with your audience and making your message memorable and meaningful for them.\" generation_id='cca053dd-cf75-4c64-9b75-05ece3e79897' response_id='e75e7393-4b13-48fc-9611-bd33740ffa21'\n", + "role='USER' message='Could you elaborate on the third point.'\n", + "role='CHATBOT' message=\"Certainly! Varying your tone and pace is an important technique to keep your audience engaged. Here are some ways to do this:\\n\\n- Change your tone of voice to emphasize important points or to reflect the emotion of what you're saying. For example, you might raise your voice to show excitement or lower it to show seriousness.\\n- Speed up your pace to create a sense of urgency or excitement, and slow down to emphasize important points or to allow your audience to absorb complex information.\\n- Use pauses to give your audience time to reflect on what you've just said and to create a sense of anticipation for what's coming next.\\n- Try to avoid monotony by varying your intonation and volume. This will help to keep your audience interested and engaged.\\n\\nBy varying your tone and pace, you can add interest and emphasis to your speech, and help your audience to stay focused and engaged.\"\n" + ] + } + ], + "source": [ + "for chat in chat_history:\n", + " print(chat)" + ] + }, { "cell_type": "markdown", "metadata": { @@ -429,7 +552,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 32, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -438,6 +561,24 @@ "outputId": "b2f4173f-a1c8-4e50-9b48-2cb0bedd0847" }, "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "name": "stdout", "output_type": "stream", @@ -445,63 +586,38 @@ "Starting the chat. Type \"quit\" to end.\n", "\n", "User: Hello\n", - "Chatbot: Hello! It's great to connect with you. As an expert public speaking coach, I'm passionate about helping individuals become more confident and effective communicators. Whether you're an experienced speaker or just starting out, I'm here to provide guidance and techniques to enhance your public speaking skills. \n", - "\n", - "What brings you here today? Are you seeking to overcome speaking anxiety, improve your presentation skills, or refine your messaging? Let's dive into it and explore the ways we can enhance your public speaking journey.\n", + "Chatbot: Hello! How can I help you today?\n", "\n", "User: I'd like to learn about techniques for effective audience engagement\n", - "Chatbot: Excellent! Engaging with your audience is a crucial aspect of public speaking. Here are some effective techniques to help you capture and sustain your audience's attention:\n", - "\n", - "1. Begin with a Bang: Start your speech with an attention-grabbing opening. This could be a compelling story, a surprising statistic, a rhetorical question, or a visual aid that immediately captures their interest. An engaging beginning sets the tone and focuses the audience's attention on your message.\n", - "\n", - "2. Use Storytelling: Stories are a powerful tool to connect with your audience. Share relatable anecdotes or experiences that bring your message to life. Stories make your speech memorable and help the audience relate to your ideas on a deeper level.\n", - "\n", - "3. Personalize Your Content: Tailor your message to your audience's interests, experiences, or challenges. Show that you understand their world and are speaking directly to them. This creates a sense of inclusion and engagement.\n", - "\n", - "4. Interactive Elements: Incorporate interactive activities or polls to involve the audience actively. You can ask questions, seek their opinions, or have them participate in discussions. Just ensure the activities are relevant to your topic and don't slow down the pace of your presentation.\n", - "\n", - "5. Visual Aids and Multimedia: Utilize visuals, infographics, videos, or slides to illustrate your points. Visual elements can enhance your message, keep the audience engaged, and make complex concepts more accessible.\n", - "\n", - "6. Vary Your Pace and Tone: Modulate your speaking pace and use pauses effectively to emphasize key points. Throw in some variety in your tone, moving between slow and deliberate statements and lively explanations to hold their attention.\n", + "Chatbot: Sure! Here are some techniques for effective audience engagement:\n", "\n", - "7. Eye Contact and Body Language: Make deliberate eye contact with different audience members. It makes them feel included and helps you connect with the audience. Use appropriate body language to project confidence and engage your listeners.\n", + "- Make eye contact with your audience and use hand gestures to emphasize your points.\n", + "- Use a clear and concise language that your audience can easily understand.\n", + "- Vary your tone and volume to keep your audience interested.\n", + "- Use stories, examples, and analogies to illustrate your points and make your message more memorable.\n", + "- Ask questions to involve your audience and encourage them to think about your topic.\n", + "- Use humor appropriately to lighten the mood and engage your audience.\n", + "- Use visuals, such as slides, photos, or props, to break up your speech and add interest.\n", + "- Move around the stage or room to change your position and keep your audience focused.\n", + "- Use pauses to emphasize important points and give your audience time to absorb your message.\n", + "- Finally, be passionate and enthusiastic about your topic. Your enthusiasm will be contagious and will help to engage your audience.\n", "\n", - "8. Address Objections: Anticipate potential objections or questions from your audience and address them proactively. This shows you've considered different perspectives and helps ease any concerns they might have.\n", - "\n", - "9. Call to Action: End with a clear and concise call to action. It could be a simple task or a thought-provoking challenge for the audience to ponder. A strong ending leaves a lasting impression and encourages reflection.\n", - "\n", - "10. Practice and Rehearse: Rehearse your presentation beforehand, preferably in front of a small audience or mirror. Practice engaging techniques to ensure they feel natural and authentic.\n", - "\n", - "Remember, engaging an audience is an art that develops over time. Keep experimenting with different techniques, observe the responses of your audiences, and refine your approach based on feedback and your own experiences. \n", - "\n", - "If you want more specific advice or have further questions about public speaking, feel free to ask!\n", + "Remember, effective audience engagement is about connecting with your audience and making your message memorable. By using these techniques, you can deliver a speech that is both informative and engaging.\n", "\n", "User: Could you elaborate on the fourth point.\n", - "Chatbot: Absolutely! Interactive elements can significantly enhance audience engagement and make your presentation more lively and memorable. Here's a more detailed breakdown of the fourth point about incorporating interactive elements:\n", - "\n", - "1. Polls and Surveys: Conduct real-time polls or surveys to gather insights from your audience. You can use online tools or apps that allow audience members to respond to questions anonymously. These responses can spark discussions or shape your presentation based on their inputs. \n", - "\n", - "2. Rhetorical Questions: Ask thought-provoking questions to the audience throughout your speech. These questions should be related to your topic and encourage critical thinking. For instance, \"How many of you have experienced this issue personally?\" or \"What do you think might be a potential solution?\" Let the audience contemplate and discuss their answers.\n", + "Chatbot: Certainly! The fourth point is about using stories, examples, and analogies to illustrate your points and make your message more memorable.\n", "\n", - "3. Small Group Discussions: Divide your audience into smaller groups and assign them tasks or questions to discuss. This creates a sense of involvement and fosters a collaborative environment. After a set time, reconvene as a larger group and share the outcomes of these discussions. \n", + "Stories, examples, and analogies are powerful tools for engaging your audience and helping them to understand and remember your message. Here's how you can use them effectively:\n", "\n", - "4. Q&A Sessions: Encourage audience members to ask questions throughout your presentation or set aside a dedicated Q&A session at the end. Be prepared to answer their queries thoroughly and thoughtfully. This shows your expertise and encourages a two-way conversation.\n", + "- Stories: A well-told story can capture your audience's imagination and make your message more relatable and memorable. Look for stories from your own life or from current events that illustrate the points you want to make. For example, if you're giving a speech about the importance of perseverance, you might tell a story about a time when you faced a challenge and how you overcame it.\n", "\n", - "5. Demonstrations or Activities: If relevant to your topic, consider hands-on demonstrations or interactive activities. For instance, if you're talking about team building, you could have the audience engage in a brief team-building exercise. \n", + "- Examples: Examples can help to clarify your points and make them more concrete for your audience. Look for specific examples that illustrate the principles or concepts you're discussing. For example, if you're talking about the benefits of a particular product or service, provide specific examples of how it has helped your customers.\n", "\n", - "6. Live Surveys or Feedback: Use live survey tools to gather real-time feedback on your presentation or specific topics you cover. This not only provides you with valuable insights but also shows the audience that their opinions are valued.\n", + "- Analogies: Analogies can help your audience understand a complex or abstract concept by comparing it to something more familiar. For example, if you're explaining a technical process, you might compare it to a recipe or a sports game. Look for analogies that are relevant to your audience's interests and experiences.\n", "\n", - "7. Interactive Presentations: Utilize presentation software that allows audience interaction. You can embed interactive features, such as quizzes, within your slides. Audience members can use their devices to respond, creating a more engaging experience.\n", + "When using stories, examples, and analogies, it's important to keep them brief and to the point. You don't want to lose your audience's attention by rambling on. Also, make sure that your stories and examples are authentic and relevant to your topic.\n", "\n", - "8. Storytelling with Audience Participation: Involve the audience in storytelling by asking them to share their experiences or anecdotes related to your topic. This makes your narrative more collaborative and personal.\n", - "\n", - "9. Games and Competitions: Create fun games or competitions related to your message. This approach is especially effective when presenting to younger audiences or in more casual settings. Ensure the activities are inclusive and aligned with your content.\n", - "\n", - "10. Social Media Integration: Leverage social media platforms to create a dedicated hashtag for your event or presentation. Encourage the audience to share their thoughts, observations, or questions online throughout the session. You can even display these live social media feeds during your presentation.\n", - "\n", - "When incorporating interactive elements, it's essential to ensure they align seamlessly with your content and flow smoothly within your presentation. Also, consider the time constraints and the nature of your audience. Not all techniques will work for every audience or setting, so tailor the interactivity to suit your specific context. \n", - "\n", - "The key is to make the experience enjoyable, insightful, and relevant for both you and your audience. Interactive presentations require careful planning and practice, but the payoff can be immense in terms of audience engagement and satisfaction.\n", + "By incorporating stories, examples, and analogies into your speech, you can make your message more engaging and memorable for your audience.\n", "\n", "User: quit\n", "Ending chat.\n" @@ -557,7 +673,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 33, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -566,16 +682,34 @@ "outputId": "a84b7f14-682b-4eea-8ddb-ffca091b9f06" }, "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "name": "stdout", "output_type": "stream", "text": [ "role='USER' message='Hello'\n", - "role='CHATBOT' message=\"Hello! It's great to connect with you. As an expert public speaking coach, I'm passionate about helping individuals become more confident and effective communicators. Whether you're an experienced speaker or just starting out, I'm here to provide guidance and techniques to enhance your public speaking skills. \\n\\nWhat brings you here today? Are you seeking to overcome speaking anxiety, improve your presentation skills, or refine your messaging? Let's dive into it and explore the ways we can enhance your public speaking journey.\"\n", + "role='CHATBOT' message='Hello! How can I help you today?'\n", "role='USER' message=\"I'd like to learn about techniques for effective audience engagement\"\n", - "role='CHATBOT' message=\"Excellent! Engaging with your audience is a crucial aspect of public speaking. Here are some effective techniques to help you capture and sustain your audience's attention:\\n\\n1. Begin with a Bang: Start your speech with an attention-grabbing opening. This could be a compelling story, a surprising statistic, a rhetorical question, or a visual aid that immediately captures their interest. An engaging beginning sets the tone and focuses the audience's attention on your message.\\n\\n2. Use Storytelling: Stories are a powerful tool to connect with your audience. Share relatable anecdotes or experiences that bring your message to life. Stories make your speech memorable and help the audience relate to your ideas on a deeper level.\\n\\n3. Personalize Your Content: Tailor your message to your audience's interests, experiences, or challenges. Show that you understand their world and are speaking directly to them. This creates a sense of inclusion and engagement.\\n\\n4. Interactive Elements: Incorporate interactive activities or polls to involve the audience actively. You can ask questions, seek their opinions, or have them participate in discussions. Just ensure the activities are relevant to your topic and don't slow down the pace of your presentation.\\n\\n5. Visual Aids and Multimedia: Utilize visuals, infographics, videos, or slides to illustrate your points. Visual elements can enhance your message, keep the audience engaged, and make complex concepts more accessible.\\n\\n6. Vary Your Pace and Tone: Modulate your speaking pace and use pauses effectively to emphasize key points. Throw in some variety in your tone, moving between slow and deliberate statements and lively explanations to hold their attention.\\n\\n7. Eye Contact and Body Language: Make deliberate eye contact with different audience members. It makes them feel included and helps you connect with the audience. Use appropriate body language to project confidence and engage your listeners.\\n\\n8. Address Objections: Anticipate potential objections or questions from your audience and address them proactively. This shows you've considered different perspectives and helps ease any concerns they might have.\\n\\n9. Call to Action: End with a clear and concise call to action. It could be a simple task or a thought-provoking challenge for the audience to ponder. A strong ending leaves a lasting impression and encourages reflection.\\n\\n10. Practice and Rehearse: Rehearse your presentation beforehand, preferably in front of a small audience or mirror. Practice engaging techniques to ensure they feel natural and authentic.\\n\\nRemember, engaging an audience is an art that develops over time. Keep experimenting with different techniques, observe the responses of your audiences, and refine your approach based on feedback and your own experiences. \\n\\nIf you want more specific advice or have further questions about public speaking, feel free to ask!\"\n", + "role='CHATBOT' message='Sure! Here are some techniques for effective audience engagement:\\n\\n- Make eye contact with your audience and use hand gestures to emphasize your points.\\n- Use a clear and concise language that your audience can easily understand.\\n- Vary your tone and volume to keep your audience interested.\\n- Use stories, examples, and analogies to illustrate your points and make your message more memorable.\\n- Ask questions to involve your audience and encourage them to think about your topic.\\n- Use humor appropriately to lighten the mood and engage your audience.\\n- Use visuals, such as slides, photos, or props, to break up your speech and add interest.\\n- Move around the stage or room to change your position and keep your audience focused.\\n- Use pauses to emphasize important points and give your audience time to absorb your message.\\n- Finally, be passionate and enthusiastic about your topic. Your enthusiasm will be contagious and will help to engage your audience.\\n\\nRemember, effective audience engagement is about connecting with your audience and making your message memorable. By using these techniques, you can deliver a speech that is both informative and engaging.'\n", "role='USER' message='Could you elaborate on the fourth point.'\n", - "role='CHATBOT' message='Absolutely! Interactive elements can significantly enhance audience engagement and make your presentation more lively and memorable. Here\\'s a more detailed breakdown of the fourth point about incorporating interactive elements:\\n\\n1. Polls and Surveys: Conduct real-time polls or surveys to gather insights from your audience. You can use online tools or apps that allow audience members to respond to questions anonymously. These responses can spark discussions or shape your presentation based on their inputs. \\n\\n2. Rhetorical Questions: Ask thought-provoking questions to the audience throughout your speech. These questions should be related to your topic and encourage critical thinking. For instance, \"How many of you have experienced this issue personally?\" or \"What do you think might be a potential solution?\" Let the audience contemplate and discuss their answers.\\n\\n3. Small Group Discussions: Divide your audience into smaller groups and assign them tasks or questions to discuss. This creates a sense of involvement and fosters a collaborative environment. After a set time, reconvene as a larger group and share the outcomes of these discussions. \\n\\n4. Q&A Sessions: Encourage audience members to ask questions throughout your presentation or set aside a dedicated Q&A session at the end. Be prepared to answer their queries thoroughly and thoughtfully. This shows your expertise and encourages a two-way conversation.\\n\\n5. Demonstrations or Activities: If relevant to your topic, consider hands-on demonstrations or interactive activities. For instance, if you\\'re talking about team building, you could have the audience engage in a brief team-building exercise. \\n\\n6. Live Surveys or Feedback: Use live survey tools to gather real-time feedback on your presentation or specific topics you cover. This not only provides you with valuable insights but also shows the audience that their opinions are valued.\\n\\n7. Interactive Presentations: Utilize presentation software that allows audience interaction. You can embed interactive features, such as quizzes, within your slides. Audience members can use their devices to respond, creating a more engaging experience.\\n\\n8. Storytelling with Audience Participation: Involve the audience in storytelling by asking them to share their experiences or anecdotes related to your topic. This makes your narrative more collaborative and personal.\\n\\n9. Games and Competitions: Create fun games or competitions related to your message. This approach is especially effective when presenting to younger audiences or in more casual settings. Ensure the activities are inclusive and aligned with your content.\\n\\n10. Social Media Integration: Leverage social media platforms to create a dedicated hashtag for your event or presentation. Encourage the audience to share their thoughts, observations, or questions online throughout the session. You can even display these live social media feeds during your presentation.\\n\\nWhen incorporating interactive elements, it\\'s essential to ensure they align seamlessly with your content and flow smoothly within your presentation. Also, consider the time constraints and the nature of your audience. Not all techniques will work for every audience or setting, so tailor the interactivity to suit your specific context. \\n\\nThe key is to make the experience enjoyable, insightful, and relevant for both you and your audience. Interactive presentations require careful planning and practice, but the payoff can be immense in terms of audience engagement and satisfaction.'\n" + "role='CHATBOT' message=\"Certainly! The fourth point is about using stories, examples, and analogies to illustrate your points and make your message more memorable.\\n\\nStories, examples, and analogies are powerful tools for engaging your audience and helping them to understand and remember your message. Here's how you can use them effectively:\\n\\n- Stories: A well-told story can capture your audience's imagination and make your message more relatable and memorable. Look for stories from your own life or from current events that illustrate the points you want to make. For example, if you're giving a speech about the importance of perseverance, you might tell a story about a time when you faced a challenge and how you overcame it.\\n\\n- Examples: Examples can help to clarify your points and make them more concrete for your audience. Look for specific examples that illustrate the principles or concepts you're discussing. For example, if you're talking about the benefits of a particular product or service, provide specific examples of how it has helped your customers.\\n\\n- Analogies: Analogies can help your audience understand a complex or abstract concept by comparing it to something more familiar. For example, if you're explaining a technical process, you might compare it to a recipe or a sports game. Look for analogies that are relevant to your audience's interests and experiences.\\n\\nWhen using stories, examples, and analogies, it's important to keep them brief and to the point. You don't want to lose your audience's attention by rambling on. Also, make sure that your stories and examples are authentic and relevant to your topic.\\n\\nBy incorporating stories, examples, and analogies into your speech, you can make your message more engaging and memorable for your audience.\"\n" ] } ], diff --git a/notebooks/llmu/Parameters_for_Controlling_Outputs.ipynb b/notebooks/llmu/Parameters_for_Controlling_Outputs.ipynb index 30126ab14..9eb964ca6 100644 --- a/notebooks/llmu/Parameters_for_Controlling_Outputs.ipynb +++ b/notebooks/llmu/Parameters_for_Controlling_Outputs.ipynb @@ -68,7 +68,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -96,9 +96,28 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "import cohere\n", "\n", @@ -144,13 +163,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "Hi! Hello there! How's it going? I hope you're having a fantastic day so far. Is there anything I can help you with?\n" + "Hello! How can I help you today?\n" ] } ], "source": [ "response = co.chat(message=\"Hello\",\n", - " model=\"command-r\")\n", + " model=\"command-r-plus\")\n", "print(response.text)" ] }, @@ -169,7 +188,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -194,11 +213,11 @@ "name": "stdout", "output_type": "stream", "text": [ - "\"Unleashing the Power of Generation: A Guide to the Exciting World of Retrieval-Augmented Creation\"\n", - "\"Unleashing the Power of Generation: A Guide to the Exciting World of Retrieval-Augmented Creation\"\n", - "\"Unleashing the Power of Generation: A Guide to the Exciting World of Retrieval-Augmented Creation\"\n", - "\"Unleashing the Power of Generation: A Guide to the Exciting World of Retrieval-Augmented Creation\"\n", - "\"Unleashing the Power of Generation: A Guide to the Exciting World of Retrieval-Augmented Creation\"\n" + "The Future of AI: Unlocking the Power of Retrieval-Augmented Generation\n", + "The Future of AI: Unlocking the Power of Retrieval-Augmented Generation\n", + "The Future of AI: Unlocking the Power of Retrieval-Augmented Generation\n", + "The Future of AI: Unlocking the Power of Retrieval-Augmented Generation\n", + "The Future of AI: Unlocking the Power of Retrieval-Augmented Generation\n" ] } ], @@ -208,7 +227,8 @@ "\n", "for _ in range(5):\n", " response = co.chat(message=message,\n", - " temperature=0)\n", + " temperature=0,\n", + " model=\"command-r-plus\")\n", " print(response.text)" ] }, @@ -221,7 +241,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -246,11 +266,11 @@ "name": "stdout", "output_type": "stream", "text": [ - "\"Unleashing the Power of Generation: A Guide to the Future of Retrieval-Augmented Creation\"\n", - "\"Unleashing the Power of Generation: A Guide to the Exciting World of Retrieval-Augmented Creation\"\n", - "\"Unleashing the Power of RAG: A Guide to the Future of Generation\"\n", - "\"Unleashing the Power of Augmented Generation: A Guide to the Future of AI Text Generation\"\n", - "\"Unleashing the Power of Generation: A Guide to the Exciting World of Retrieval-Augmented Creation\"\n" + "Unleashing the Power of Retrieval-Augmented Generation: A Comprehensive Guide\n", + "The Exciting Future of AI: How Retrieval-Augmented Generation Will Transform the Way We Interact With Machines\n", + "The Magic of AI: Unlocking the Power of Retrieval-Augmented Generation\n", + "The Future of AI: Unlocking the Power of Retrieval-Augmented Generation\n", + "\"Unleashing the Power of AI: The Rise of Retrieval-Augmented Generation.\"\n" ] } ], @@ -260,7 +280,8 @@ "\n", "for _ in range(5):\n", " response = co.chat(message=message,\n", - " temperature=1)\n", + " temperature=1,\n", + " model=\"command-r-plus\")\n", " print(response.text)" ] }, @@ -270,12 +291,12 @@ "source": [ "## Conciseness\n", "\n", - "Sometimes, the model provides more context than you need to address a query. For instance, consider what happens when we ask the model a simple question: \"How many eggs are in one dozen?\"." + "Sometimes, the model provides more context than you need to address a query. For instance, consider what happens when we ask the model to generate code." ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -300,12 +321,27 @@ "name": "stdout", "output_type": "stream", "text": [ - "There are 12 eggs in one dozen. The term \"dozen\" is used to represent the number 12, and it's commonly used when referring to measurements or quantities, especially for eggs. So, when you buy or hear about a dozen eggs, it means you're dealing with 12 eggs.\n" + "Here is an example of how to load a CSV file as a Pandas DataFrame:\n", + "```python\n", + "import pandas as pd\n", + "\n", + "# Load the CSV file into a Pandas DataFrame\n", + "df = pd.read_csv('filename.csv')\n", + "\n", + "# Display the first few rows of the DataFrame\n", + "print(df.head())\n", + "```\n", + "\n", + "In this example, we use the `pd.read_csv()` function to load the CSV file into a Pandas DataFrame. The `read_csv()` function takes the file path or URL of the CSV file as an argument and returns a Pandas DataFrame object.\n", + "\n", + "We then use the `head()` function to display the first few rows of the DataFrame, which can be useful for quickly inspecting the data.\n", + "\n", + "Note that you need to replace `'filename.csv'` with the actual file path or URL of your CSV file.\n" ] } ], "source": [ - "response = co.chat(message=\"How many eggs are in one dozen?\")\n", + "response = co.chat(message=\"Generate code for loading a csv file as a pandas dataframe\", model=\"command-r-plus\")\n", "print(response.text)" ] }, @@ -313,7 +349,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The model answers the question, but it uses multiple sentences when the first sentence would have been sufficient.\n", + "The model answers the question, and the response is relatively detailed.\n", "\n", "We can get the model to shorten its response by setting the `preamble` parameter to an empty string." ] @@ -345,12 +381,24 @@ "name": "stdout", "output_type": "stream", "text": [ - "There are 12 eggs in one dozen.\n" + "Here is an example of how to load a CSV file as a Pandas DataFrame:\n", + "```python\n", + "import pandas as pd\n", + "\n", + "# Load the CSV file into a Pandas DataFrame\n", + "df = pd.read_csv('filename.csv')\n", + "\n", + "# Display the first few rows of the DataFrame\n", + "print(df.head())\n", + "```\n", + "\n", + "This code uses the `pd.read_csv()` function to load the CSV file into a Pandas DataFrame. The `print(df.head())` function then displays the first few rows of the DataFrame.\n" ] } ], "source": [ - "response = co.chat(message=\"How many eggs are in one dozen?\",\n", + "response = co.chat(message=\"Generate code for loading a csv file as a pandas dataframe\",\n", + " model=\"command-r-plus\",\n", " preamble=\"\")\n", "print(response.text)" ] diff --git a/notebooks/llmu/Prompt_Engineering_Basics.ipynb b/notebooks/llmu/Prompt_Engineering_Basics.ipynb index c554f2f83..280ea2ac2 100644 --- a/notebooks/llmu/Prompt_Engineering_Basics.ipynb +++ b/notebooks/llmu/Prompt_Engineering_Basics.ipynb @@ -75,7 +75,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "9e0895df", "metadata": {}, "outputs": [], @@ -105,10 +105,29 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "id": "c465a580", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "import cohere\n", "\n", @@ -126,13 +145,32 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 10, "id": "0d4130e9", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "def generate_text(message):\n", - " stream = co.chat_stream(message=message)\n", + " stream = co.chat_stream(message=message, model=\"command-r-plus\", preamble=\"\")\n", " for event in stream:\n", " if event.event_type == \"text-generation\":\n", " print(event.text, end='')" @@ -158,15 +196,35 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 11, "id": "3802a5b5", "metadata": {}, "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "name": "stdout", "output_type": "stream", "text": [ - "Experience the freedom of wireless audio with our state-of-the-art earbuds! Designed to deliver exceptional sound quality and all-day comfort, these earbuds are the perfect companion for your on-the-go lifestyle. Enjoy seamless connectivity, easy controls, and a secure fit, making them your go-to for both work and play." + "Wireless Earbuds:\n", + "\n", + "Experience true wireless freedom with our latest earbuds. Immerse yourself in your favorite tunes or take calls with crystal-clear clarity, all without the hassle of tangled cords. Our earbuds offer a secure and comfortable fit, ensuring they stay put during any activity. With a sleek and compact design, these earbuds are the perfect companion for your on-the-go lifestyle." ] } ], @@ -192,25 +250,43 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 12, "id": "a542f651", "metadata": {}, "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "name": "stdout", "output_type": "stream", "text": [ - "Hook: Upgrade your listening experience with the ultimate in wireless freedom! \n", + "Hook: Experience True Wireless Freedom with Superior Sound\n", "\n", - "Solution: Introducing our state-of-the-art wireless earbuds, the ultimate companion for audio enthusiasts on the go. Designed to deliver exceptional sound quality and all-day comfort, these earbuds are the perfect solution for hands-free, wire-free listening. \n", + "Solution: Introducing our cutting-edge wireless earbuds, designed to revolutionize your audio experience.\n", "\n", - "Features and Benefits: \n", - "- Superior Sound: Immerse yourself in crystal-clear, high-definition audio. Our earbuds use advanced drivers for deep bass and crystal-clear trebles, elevating your music, podcast, or call experience. \n", - "- Secure Fit: Ergonomically designed with multiple tip sizes to ensure a secure and comfortable fit, no matter your ear shape or size. \n", - "- Long-Lasting Battery: Enjoy up to 24 hours of non-stop listening with a portable charging case, keeping your earbuds powered throughout your day. Quick charge functionality also ensures a fast turnaround for those unexpected moments of low battery. \n", - "- Seamless Connectivity: Instantly connect to your favorite devices with the latest Bluetooth 5.2 technology, ensuring a stable and reliable connection for uninterrupted listening. \n", + "Features and Benefits:\n", + "- Immersive Audio: Enjoy superior sound quality with deep bass and crystal-clear highs, ensuring an immersive listening experience.\n", + "- True Wireless Technology: Free yourself from tangles and restrictions with a stable Bluetooth connection, providing seamless connectivity and true wireless freedom.\n", + "- Comfortable Design: The ergonomic design ensures a secure and comfortable fit, allowing you to enjoy your music without distraction.\n", + "- Extended Battery Life: With a long-lasting battery, you can listen for hours on end without worrying about recharging.\n", "\n", - "Call to Action: Experience the future of wireless audio. Buy now and unlock exceptional sound, anytime, anywhere!" + "Call to Action: Upgrade your audio experience with our wireless earbuds. Immerse yourself in superior sound, enjoy the freedom of true wireless technology, and benefit from the comfort and convenience they offer." ] } ], @@ -239,15 +315,33 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 13, "id": "1b5278a7", "metadata": {}, "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "name": "stdout", "output_type": "stream", "text": [ - "The email expresses sincere gratitude and appreciation to the team members for their hard work and dedication in organizing a successful community meetup." + "The email expresses gratitude and appreciation to the team members for their hard work, dedication, and contributions that led to the success of the recent community meetup event." ] } ], @@ -287,15 +381,33 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 14, "id": "7a671108", "metadata": {}, "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "name": "stdout", "output_type": "stream", "text": [ - "The movie title is \"Deadpool 2\"." + "Deadpool 2" ] } ], @@ -326,30 +438,50 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 15, "id": "83f9631e", "metadata": {}, "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "name": "stdout", "output_type": "stream", "text": [ - "Here are some potential FAQs with answers:\n", + "Here is a list of potential FAQs based on the provided text: \n", + "\n", + "**Q: What does the Cohere Platform offer to developers and organizations?**\n", + "**A:** The Cohere Platform provides an API that gives developers and organizations access to cutting-edge Large Language Models (LLMs) without requiring expertise in machine learning. \n", "\n", - "1. What does the Cohere Platform offer?\n", - " - The Cohere Platform provides a simple API that gives developers access to advanced LLMs without requiring expertise in machine learning. The platform also handles the complexities of text data curation, model development, training, and serving, so developers can focus on creating practical applications.\n", + "**Q: What are the key advantages of using the Cohere Platform?**\n", + "**A:** The platform handles all the complex tasks associated with LLMs, including data curation, model development, distributed training, and model serving. This allows users to focus on creating value in applied areas. \n", "\n", - "2. What are the key language processing capabilities the Cohere Platform provides?\n", - " - The Cohere Platform offers two primary language processing capabilities: text generation and text embedding.\n", + "**Q: What are the two main language processing capabilities provided by the Cohere Platform?**\n", + "**A:** The platform offers text generation and text embedding capabilities. Text generation involves providing a prompt and receiving a completion, such as asking for a haiku. Text embedding returns a list of numbers representing the semantic meaning of the input text, useful for sentiment analysis and other applications. \n", "\n", - "3. How does text generation work?\n", - " - Text generation takes a prompt, such as a few words or a sentence, and generates a stream of text as a response. An example could be receiving an original haiku poem as a completion to the prompt \"Write a haiku.\"\n", + "**Q: What is an example of text generation using the Cohere Platform?**\n", + "**A:** One example is prompting the model to write a haiku, and the model will generate an original haiku as a response. \n", "\n", - "4. What is text embedding, and what are its use cases?\n", - " - Text embedding takes a piece of text and returns a list of numbers that represent its semantic meaning. This can be applied to various situations, including sentiment analysis, to \"measure\" the text's meaning.\n", + "**Q: How does text embedding work, and what is its utility?**\n", + "**A:** Text embedding translates a piece of text into a list of numbers that captures its semantic meaning. This is valuable for tasks that require understanding the sentiment or underlying meaning of a text passage, enabling quantitative analysis. \n", "\n", - "5. Do I need machine learning expertise to use the Cohere Platform?\n", - " - No, the Cohere Platform is designed to remove the need for machine learning know-how. It simplifies the process, allowing developers to access advanced LLMs easily." + "These FAQs address some of the key points a user might inquire about regarding the Cohere Platform and its capabilities." ] } ], From 3f21269453b3414578410f564842e88f6afa9e12 Mon Sep 17 00:00:00 2001 From: Alexis Cook Date: Tue, 16 Apr 2024 12:09:20 -0600 Subject: [PATCH 2/3] building a chatbot changes --- notebooks/llmu/Building_a_Chatbot.ipynb | 114 ++++++++++++------------ 1 file changed, 58 insertions(+), 56 deletions(-) diff --git a/notebooks/llmu/Building_a_Chatbot.ipynb b/notebooks/llmu/Building_a_Chatbot.ipynb index 70a11ab21..f0396a431 100644 --- a/notebooks/llmu/Building_a_Chatbot.ipynb +++ b/notebooks/llmu/Building_a_Chatbot.ipynb @@ -88,7 +88,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 3, "metadata": { "id": "cDwP5nHwO0Ap" }, @@ -165,12 +165,14 @@ "\n", "The `message` parameter is the only required parameter for the Chat endpoint. \n", "\n", + "In our case, we also use the `model` parameter to specify the underlying chat model we want to use. For this, we pick Command R+, Cohere's newest large language model.\n", + "\n", "We call the endpoint with `co.chat()`, and get the main content of the response from the `text` value." ] }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 5, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -206,7 +208,7 @@ } ], "source": [ - "response = co.chat(message=\"Hello\")\n", + "response = co.chat(message=\"Hello\", model=\"command-r-plus\")\n", "print(response.text)" ] }, @@ -225,7 +227,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 12, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -256,12 +258,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "I'm here to help you improve your public speaking skills and build your confidence. What would you like to work on today?\n" + "How can I help you with your public speaking today?\n" ] } ], "source": [ "response = co.chat(message=\"Hello\",\n", + " model=\"command-r-plus\",\n", " preamble=\"You are an expert public speaking coach. Don't use any greetings.\")\n", "print(response.text)" ] @@ -283,7 +286,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 8, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -316,34 +319,33 @@ "text": [ "Sure! Here are some techniques for effective audience engagement:\n", "\n", - "- **Make Eye Contact:** Look at different individuals in the audience and try to maintain eye contact for a few seconds at a time. This helps create a sense of connection and makes your speech more intimate.\n", - "\n", - "- **Use Gestures:** Incorporate natural hand gestures to emphasize your points and add variety to your delivery. This helps to keep your audience focused and engaged.\n", + "- **Make eye contact:** Look at different individuals in the audience and try to maintain eye contact for a few seconds at a time. This helps create a sense of connection and makes your speech more intimate.\n", "\n", - "- **Vary Your Tone and Volume:** Avoid monotony by varying your tone and volume. Emphasize important words or phrases, and use pauses for effect to highlight key points.\n", + "- **Use gestures:** Incorporate hand gestures and body language to emphasize your points and add variety to your delivery. This helps keep your audience engaged and can also help you appear more confident and passionate about your topic.\n", "\n", - "- **Ask Questions:** Pose rhetorical questions to your audience to get them thinking about your topic. You can also directly ask for their opinions or input, which encourages active participation.\n", + "- **Vary your tone and volume:** Avoid monotone delivery by varying your pitch, pace, and volume. Emphasize important points by raising your volume or slowing down your pace. This helps to create emphasis and keeps your audience interested.\n", "\n", - "- **Tell Stories:** Incorporate relevant anecdotes or personal stories to illustrate your points. Stories are memorable and help your audience connect with you on a deeper level.\n", + "- **Ask questions:** Pose rhetorical questions to your audience to get them thinking about your topic. You can also directly ask for their opinions or input, either by a show of hands or by inviting them to share their thoughts. This creates a dialogue and makes your speech more interactive.\n", "\n", - "- **Use Humor:** Depending on the context, appropriate humor can lighten the mood, engage your audience, and make your speech more enjoyable.\n", + "- **Tell stories:** Use anecdotes and personal stories to illustrate your points and create a connection with your audience. Stories are memorable and help your audience relate to you and your message.\n", "\n", - "- **Incorporate Visual Aids:** Use slides, props, or demonstrations to enhance your presentation. Visual aids can help simplify complex concepts and keep your audience visually engaged.\n", + "- **Use humor:** Appropriate humor can help to lighten the mood, engage your audience, and make your speech more enjoyable. However, be careful to avoid offensive or inappropriate jokes, and ensure your humor is relevant to your topic.\n", "\n", - "- **Encourage Interaction:** If appropriate, involve your audience in activities or exercises related to your topic. This could be a simple show of hands, a group discussion, or a more involved activity.\n", + "- **Incorporate multimedia:** Use slides, videos, or props to enhance your presentation. Visual aids can help to break up your speech, provide additional information, and keep your audience focused.\n", "\n", - "- **Use Strategic Pauses:** Pauses give your audience a chance to absorb your message and emphasize important points. They also help you to take a breath and maintain a relaxed pace.\n", + "- **Encourage interaction:** If appropriate, include activities that involve your audience. This could be a group exercise, a poll, or a Q&A session. This helps to create a more engaging and interactive experience for your audience.\n", "\n", - "- **Tailor Your Content:** Know your audience and tailor your content to their interests and expectations. Use examples and references that are relevant to them to increase engagement.\n", + "- **Be passionate:** Show your enthusiasm for your topic. Audiences are more likely to engage if they sense your passion and authenticity. Let your personality shine through and speak from the heart.\n", "\n", - "- **Be Passionate and Energetic:** Your enthusiasm for your topic can be contagious. Let your passion show through your body language, tone of voice, and facial expressions.\n", + "- **Practice and adapt:** Rehearse your speech and pay attention to your delivery. Practice in front of a mirror, record yourself, or seek feedback from others. This will help you refine your technique and improve your audience engagement skills.\n", "\n", - "Remember, effective audience engagement is about creating a connection and making your speech memorable. By using these techniques, you can make your presentation dynamic and enjoyable for your audience." + "Remember, effective audience engagement is about creating a connection and making your speech memorable. By using these techniques and adapting them to your own style and personality, you can deliver a compelling presentation that resonates with your audience." ] } ], "source": [ "stream = co.chat_stream(message=\"Hello. I'd like to learn about techniques for effective audience engagement\",\n", + " model=\"command-r-plus\",\n", " preamble=\"You are an expert public speaking coach\")\n", "\n", "for event in stream:\n", @@ -386,7 +388,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 13, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -428,27 +430,27 @@ "\n", "- Make eye contact with your audience and use hand gestures to emphasize your points.\n", "- Use a clear and concise language that your audience can easily understand.\n", - "- Vary your tone and pace to keep your audience interested.\n", + "- Vary your tone and volume to keep your audience interested.\n", "- Use visual aids such as slides, props, or demonstrations to help illustrate your points.\n", "- Tell stories or anecdotes to help your audience connect with your message on a personal level.\n", "- Ask questions to involve your audience and encourage them to think about your topic.\n", - "- Use humor appropriately to lighten the mood and engage your audience.\n", - "- Be enthusiastic and passionate about your topic to show your audience that you care about what you're speaking about.\n", - "- Practice your speech or presentation beforehand to ensure that you are comfortable and confident when delivering it.\n", - "- Pay attention to your audience's body language and adjust your delivery accordingly.\n", + "- Use humor appropriately to keep your audience entertained and engaged.\n", + "- Be enthusiastic and passionate about your topic to show your audience that you care about what you're talking about.\n", + "- Connect with your audience by showing that you understand their interests and concerns.\n", + "- End your speech with a call to action that encourages your audience to take action on your topic.\n", "\n", - "Remember, effective audience engagement is about creating a connection with your audience and making your message memorable and meaningful for them.\n", + "Remember, effective audience engagement is about creating a connection with your audience and making your speech memorable and enjoyable for them.\n", "----------------------------------------------------------------------------------------------------\n", "\n", - "User: Could you elaborate on the third point.\n", - "Chatbot: Certainly! Varying your tone and pace is an important technique to keep your audience engaged. Here are some ways to do this:\n", + "User: Could you elaborate on the third point?\n", + "Chatbot: Sure! Varying your tone and volume is an important technique for keeping your audience engaged. Here are some tips:\n", "\n", - "- Change your tone of voice to emphasize important points or to reflect the emotion of what you're saying. For example, you might raise your voice to show excitement or lower it to show seriousness.\n", - "- Speed up your pace to create a sense of urgency or excitement, and slow down to emphasize important points or to allow your audience to absorb complex information.\n", - "- Use pauses to give your audience time to reflect on what you've just said and to create a sense of anticipation for what's coming next.\n", - "- Try to avoid monotony by varying your intonation and volume. This will help to keep your audience interested and engaged.\n", + "- Use a varied tone of voice to express different emotions and emphasize certain words or phrases. For example, you might use a serious tone to convey the importance of a particular issue, or an excited tone to show your enthusiasm for a new idea.\n", + "- Change your volume to highlight important points or to create a sense of drama. Speaking loudly can help to emphasize a particular word or phrase, while speaking softly can create a sense of intimacy or seriousness.\n", + "- Avoid monotony by varying your pitch and pace. A monotone delivery can be boring and make it difficult for your audience to stay focused. Try to vary your pitch and pace to keep your audience engaged.\n", + "- Practice your speech or presentation beforehand to get a feel for how your tone and volume can impact your delivery. Experiment with different tones and volumes to see what works best for your style and your message.\n", "\n", - "By varying your tone and pace, you can add interest and emphasis to your speech, and help your audience to stay focused and engaged.\n", + "By varying your tone and volume, you can add interest and emphasis to your speech, and keep your audience engaged and responsive.\n", "----------------------------------------------------------------------------------------------------\n", "\n", "User: quit\n", @@ -477,6 +479,7 @@ "\n", " # Chatbot response\n", " stream = co.chat_stream(message=message,\n", + " model=\"command-r-plus\",\n", " preamble=preamble,\n", " conversation_id=conversation_id)\n", "\n", @@ -500,7 +503,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -525,12 +528,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "role='USER' message='Hello' generation_id='ab9f458a-d4c9-4fb5-917d-a9ec4c2fdaad' response_id='c023b477-00dc-4444-b725-d1b02af356c0'\n", - "role='CHATBOT' message='Hello! How can I help you today?' generation_id='a87b88b0-596b-4c63-a297-5213cf0da507' response_id='c023b477-00dc-4444-b725-d1b02af356c0'\n", - "role='USER' message=\"I'd like to learn about techniques for effective audience engagement\" generation_id='437b1b3e-b558-4283-b35a-4525ef3a28d4' response_id='e75e7393-4b13-48fc-9611-bd33740ffa21'\n", - "role='CHATBOT' message=\"Sure! Here are some techniques for effective audience engagement:\\n\\n- Make eye contact with your audience and use hand gestures to emphasize your points.\\n- Use a clear and concise language that your audience can easily understand.\\n- Vary your tone and pace to keep your audience interested.\\n- Use visual aids such as slides, props, or demonstrations to help illustrate your points.\\n- Tell stories or anecdotes to help your audience connect with your message on a personal level.\\n- Ask questions to involve your audience and encourage them to think about your topic.\\n- Use humor appropriately to lighten the mood and engage your audience.\\n- Be enthusiastic and passionate about your topic to show your audience that you care about what you're speaking about.\\n- Practice your speech or presentation beforehand to ensure that you are comfortable and confident when delivering it.\\n- Pay attention to your audience's body language and adjust your delivery accordingly.\\n\\nRemember, effective audience engagement is about creating a connection with your audience and making your message memorable and meaningful for them.\" generation_id='cca053dd-cf75-4c64-9b75-05ece3e79897' response_id='e75e7393-4b13-48fc-9611-bd33740ffa21'\n", - "role='USER' message='Could you elaborate on the third point.'\n", - "role='CHATBOT' message=\"Certainly! Varying your tone and pace is an important technique to keep your audience engaged. Here are some ways to do this:\\n\\n- Change your tone of voice to emphasize important points or to reflect the emotion of what you're saying. For example, you might raise your voice to show excitement or lower it to show seriousness.\\n- Speed up your pace to create a sense of urgency or excitement, and slow down to emphasize important points or to allow your audience to absorb complex information.\\n- Use pauses to give your audience time to reflect on what you've just said and to create a sense of anticipation for what's coming next.\\n- Try to avoid monotony by varying your intonation and volume. This will help to keep your audience interested and engaged.\\n\\nBy varying your tone and pace, you can add interest and emphasis to your speech, and help your audience to stay focused and engaged.\"\n" + "role='USER' message='Hello' generation_id='b4146b59-0884-4aa3-a573-bb6bd4948511' response_id='b72e9f29-ac13-41e2-8892-b6529f9547f2'\n", + "role='CHATBOT' message='Hello! How can I help you today?' generation_id='3a002415-0213-49b9-8d4b-b7c24eba95f8' response_id='b72e9f29-ac13-41e2-8892-b6529f9547f2'\n", + "role='USER' message=\"I'd like to learn about techniques for effective audience engagement\" generation_id='fee7fbf4-fd93-4477-b987-bd2765694962' response_id='520e2329-979b-4e4b-9cdc-b2e4b49c3612'\n", + "role='CHATBOT' message=\"Sure! Here are some techniques for effective audience engagement:\\n\\n- Make eye contact with your audience and use hand gestures to emphasize your points.\\n- Use a clear and concise language that your audience can easily understand.\\n- Vary your tone and volume to keep your audience interested.\\n- Use visual aids such as slides, props, or demonstrations to help illustrate your points.\\n- Tell stories or anecdotes to help your audience connect with your message on a personal level.\\n- Ask questions to involve your audience and encourage them to think about your topic.\\n- Use humor appropriately to keep your audience entertained and engaged.\\n- Be enthusiastic and passionate about your topic to show your audience that you care about what you're talking about.\\n- Connect with your audience by showing that you understand their interests and concerns.\\n- End your speech with a call to action that encourages your audience to take action on your topic.\\n\\nRemember, effective audience engagement is about creating a connection with your audience and making your speech memorable and enjoyable for them.\" generation_id='2cc3d664-587f-4f1c-8c45-4ac658bb1668' response_id='520e2329-979b-4e4b-9cdc-b2e4b49c3612'\n", + "role='USER' message='Could you elaborate on the third point?'\n", + "role='CHATBOT' message='Sure! Varying your tone and volume is an important technique for keeping your audience engaged. Here are some tips:\\n\\n- Use a varied tone of voice to express different emotions and emphasize certain words or phrases. For example, you might use a serious tone to convey the importance of a particular issue, or an excited tone to show your enthusiasm for a new idea.\\n- Change your volume to highlight important points or to create a sense of drama. Speaking loudly can help to emphasize a particular word or phrase, while speaking softly can create a sense of intimacy or seriousness.\\n- Avoid monotony by varying your pitch and pace. A monotone delivery can be boring and make it difficult for your audience to stay focused. Try to vary your pitch and pace to keep your audience engaged.\\n- Practice your speech or presentation beforehand to get a feel for how your tone and volume can impact your delivery. Experiment with different tones and volumes to see what works best for your style and your message.\\n\\nBy varying your tone and volume, you can add interest and emphasis to your speech, and keep your audience engaged and responsive.'\n" ] } ], @@ -552,7 +555,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 15, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -604,20 +607,18 @@ "\n", "Remember, effective audience engagement is about connecting with your audience and making your message memorable. By using these techniques, you can deliver a speech that is both informative and engaging.\n", "\n", - "User: Could you elaborate on the fourth point.\n", - "Chatbot: Certainly! The fourth point is about using stories, examples, and analogies to illustrate your points and make your message more memorable.\n", + "User: Could you elaborate on the fourth point?\n", + "Chatbot: Certainly! \n", "\n", - "Stories, examples, and analogies are powerful tools for engaging your audience and helping them to understand and remember your message. Here's how you can use them effectively:\n", + "Using stories, examples, and analogies is a powerful technique to engage your audience and help them understand and remember your message. Here's how:\n", "\n", - "- Stories: A well-told story can capture your audience's imagination and make your message more relatable and memorable. Look for stories from your own life or from current events that illustrate the points you want to make. For example, if you're giving a speech about the importance of perseverance, you might tell a story about a time when you faced a challenge and how you overcame it.\n", + "- Stories: Sharing a relevant story or anecdote can make your speech more personal and engaging. Stories have the power to evoke emotions and create a deeper connection with your audience. For example, if you're speaking about the importance of perseverance, you could share a story about a time when you faced a challenge and how you overcame it. \n", + "- Examples: Providing concrete examples helps to illustrate your points and makes abstract concepts more tangible. For instance, if you're explaining a complex technical process, you could use an example to simplify and break down the information for your audience. \n", + "- Analogies: Using analogies is a way to explain something unfamiliar by comparing it to something familiar. Analogies can help your audience understand and remember your message by creating a mental link between two concepts. For example, if you're describing a new technology, you could compare it to something your audience is already familiar with. \n", "\n", - "- Examples: Examples can help to clarify your points and make them more concrete for your audience. Look for specific examples that illustrate the principles or concepts you're discussing. For example, if you're talking about the benefits of a particular product or service, provide specific examples of how it has helped your customers.\n", + "When using stories, examples, and analogies, make sure they are relevant to your topic and concise. You don't want to lose your audience's attention by rambling or veering off-topic. Also, try to use vivid details and sensory information to create a more engaging and memorable narrative. \n", "\n", - "- Analogies: Analogies can help your audience understand a complex or abstract concept by comparing it to something more familiar. For example, if you're explaining a technical process, you might compare it to a recipe or a sports game. Look for analogies that are relevant to your audience's interests and experiences.\n", - "\n", - "When using stories, examples, and analogies, it's important to keep them brief and to the point. You don't want to lose your audience's attention by rambling on. Also, make sure that your stories and examples are authentic and relevant to your topic.\n", - "\n", - "By incorporating stories, examples, and analogies into your speech, you can make your message more engaging and memorable for your audience.\n", + "By incorporating these techniques, you can make your speech more interesting, relatable, and easier for your audience to understand and retain.\n", "\n", "User: quit\n", "Ending chat.\n" @@ -645,8 +646,9 @@ "\n", " # Chatbot response\n", " stream = co.chat_stream(message=message,\n", - " preamble=preamble,\n", - " chat_history=chat_history)\n", + " model=\"command-r-plus\",\n", + " preamble=preamble,\n", + " chat_history=chat_history)\n", "\n", " chatbot_response = \"\"\n", " print(\"Chatbot: \", end='')\n", @@ -673,7 +675,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 16, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -708,8 +710,8 @@ "role='CHATBOT' message='Hello! How can I help you today?'\n", "role='USER' message=\"I'd like to learn about techniques for effective audience engagement\"\n", "role='CHATBOT' message='Sure! Here are some techniques for effective audience engagement:\\n\\n- Make eye contact with your audience and use hand gestures to emphasize your points.\\n- Use a clear and concise language that your audience can easily understand.\\n- Vary your tone and volume to keep your audience interested.\\n- Use stories, examples, and analogies to illustrate your points and make your message more memorable.\\n- Ask questions to involve your audience and encourage them to think about your topic.\\n- Use humor appropriately to lighten the mood and engage your audience.\\n- Use visuals, such as slides, photos, or props, to break up your speech and add interest.\\n- Move around the stage or room to change your position and keep your audience focused.\\n- Use pauses to emphasize important points and give your audience time to absorb your message.\\n- Finally, be passionate and enthusiastic about your topic. Your enthusiasm will be contagious and will help to engage your audience.\\n\\nRemember, effective audience engagement is about connecting with your audience and making your message memorable. By using these techniques, you can deliver a speech that is both informative and engaging.'\n", - "role='USER' message='Could you elaborate on the fourth point.'\n", - "role='CHATBOT' message=\"Certainly! The fourth point is about using stories, examples, and analogies to illustrate your points and make your message more memorable.\\n\\nStories, examples, and analogies are powerful tools for engaging your audience and helping them to understand and remember your message. Here's how you can use them effectively:\\n\\n- Stories: A well-told story can capture your audience's imagination and make your message more relatable and memorable. Look for stories from your own life or from current events that illustrate the points you want to make. For example, if you're giving a speech about the importance of perseverance, you might tell a story about a time when you faced a challenge and how you overcame it.\\n\\n- Examples: Examples can help to clarify your points and make them more concrete for your audience. Look for specific examples that illustrate the principles or concepts you're discussing. For example, if you're talking about the benefits of a particular product or service, provide specific examples of how it has helped your customers.\\n\\n- Analogies: Analogies can help your audience understand a complex or abstract concept by comparing it to something more familiar. For example, if you're explaining a technical process, you might compare it to a recipe or a sports game. Look for analogies that are relevant to your audience's interests and experiences.\\n\\nWhen using stories, examples, and analogies, it's important to keep them brief and to the point. You don't want to lose your audience's attention by rambling on. Also, make sure that your stories and examples are authentic and relevant to your topic.\\n\\nBy incorporating stories, examples, and analogies into your speech, you can make your message more engaging and memorable for your audience.\"\n" + "role='USER' message='Could you elaborate on the fourth point?'\n", + "role='CHATBOT' message=\"Certainly! \\n\\nUsing stories, examples, and analogies is a powerful technique to engage your audience and help them understand and remember your message. Here's how:\\n\\n- Stories: Sharing a relevant story or anecdote can make your speech more personal and engaging. Stories have the power to evoke emotions and create a deeper connection with your audience. For example, if you're speaking about the importance of perseverance, you could share a story about a time when you faced a challenge and how you overcame it. \\n- Examples: Providing concrete examples helps to illustrate your points and makes abstract concepts more tangible. For instance, if you're explaining a complex technical process, you could use an example to simplify and break down the information for your audience. \\n- Analogies: Using analogies is a way to explain something unfamiliar by comparing it to something familiar. Analogies can help your audience understand and remember your message by creating a mental link between two concepts. For example, if you're describing a new technology, you could compare it to something your audience is already familiar with. \\n\\nWhen using stories, examples, and analogies, make sure they are relevant to your topic and concise. You don't want to lose your audience's attention by rambling or veering off-topic. Also, try to use vivid details and sensory information to create a more engaging and memorable narrative. \\n\\nBy incorporating these techniques, you can make your speech more interesting, relatable, and easier for your audience to understand and retain.\"\n" ] } ], From 24a8254972474f2fee8d761b85d35f00812174bf Mon Sep 17 00:00:00 2001 From: Alexis Cook Date: Fri, 19 Apr 2024 13:06:03 -0600 Subject: [PATCH 3/3] edits to hyperparameters, prompt engineering --- .../Parameters_for_Controlling_Outputs.ipynb | 136 +----------------- .../llmu/Prompt_Engineering_Basics.ipynb | 64 +++++---- 2 files changed, 40 insertions(+), 160 deletions(-) diff --git a/notebooks/llmu/Parameters_for_Controlling_Outputs.ipynb b/notebooks/llmu/Parameters_for_Controlling_Outputs.ipynb index 9eb964ca6..553815be9 100644 --- a/notebooks/llmu/Parameters_for_Controlling_Outputs.ipynb +++ b/notebooks/llmu/Parameters_for_Controlling_Outputs.ipynb @@ -31,10 +31,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The notebook has 3 sections:\n", + "The notebook has 2 sections:\n", "- **Model Type** - Select a variation of the Command model.\n", - "- **Randomness** - Use the `temperature` parameter to control the level of randomness of the model.\n", - "- **Conciseness** - Set the `preamble` parameter to an empty string to make model responses more concise." + "- **Randomness** - Use the `temperature` parameter to control the level of randomness of the model." ] }, { @@ -131,9 +130,7 @@ "source": [ "## Model Type\n", "\n", - "When calling the Chat endpoint, use the `model` parameter to choose from several variations of the Command model. \n", - "\n", - "[See the documentation](https://docs.cohere.com/docs/models#command) for the most updated list of available Cohere models." + "When calling the Chat endpoint, use the `model` parameter to choose from several variations of the Command model. In the example, we select [Command R+](https://docs.cohere.com/docs/command-r-plus)." ] }, { @@ -179,6 +176,8 @@ "id": "Df4lLD-P3aj_" }, "source": [ + "[See the documentation](https://docs.cohere.com/docs/models#command) for the most updated list of available Cohere models.\n", + "\n", "## Randomness\n", "\n", "You can use the `temperature` parameter to control the level of randomness of the model. It is a value between 0 and 1. As you increase the temperature, the model gets more creative and random. Temperature can be tuned for different problems, and most people will find that the default temperature of 0.3 is a good starting point.\n", @@ -284,131 +283,6 @@ " model=\"command-r-plus\")\n", " print(response.text)" ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Conciseness\n", - "\n", - "Sometimes, the model provides more context than you need to address a query. For instance, consider what happens when we ask the model to generate code." - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " " - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Here is an example of how to load a CSV file as a Pandas DataFrame:\n", - "```python\n", - "import pandas as pd\n", - "\n", - "# Load the CSV file into a Pandas DataFrame\n", - "df = pd.read_csv('filename.csv')\n", - "\n", - "# Display the first few rows of the DataFrame\n", - "print(df.head())\n", - "```\n", - "\n", - "In this example, we use the `pd.read_csv()` function to load the CSV file into a Pandas DataFrame. The `read_csv()` function takes the file path or URL of the CSV file as an argument and returns a Pandas DataFrame object.\n", - "\n", - "We then use the `head()` function to display the first few rows of the DataFrame, which can be useful for quickly inspecting the data.\n", - "\n", - "Note that you need to replace `'filename.csv'` with the actual file path or URL of your CSV file.\n" - ] - } - ], - "source": [ - "response = co.chat(message=\"Generate code for loading a csv file as a pandas dataframe\", model=\"command-r-plus\")\n", - "print(response.text)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The model answers the question, and the response is relatively detailed.\n", - "\n", - "We can get the model to shorten its response by setting the `preamble` parameter to an empty string." - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " " - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Here is an example of how to load a CSV file as a Pandas DataFrame:\n", - "```python\n", - "import pandas as pd\n", - "\n", - "# Load the CSV file into a Pandas DataFrame\n", - "df = pd.read_csv('filename.csv')\n", - "\n", - "# Display the first few rows of the DataFrame\n", - "print(df.head())\n", - "```\n", - "\n", - "This code uses the `pd.read_csv()` function to load the CSV file into a Pandas DataFrame. The `print(df.head())` function then displays the first few rows of the DataFrame.\n" - ] - } - ], - "source": [ - "response = co.chat(message=\"Generate code for loading a csv file as a pandas dataframe\",\n", - " model=\"command-r-plus\",\n", - " preamble=\"\")\n", - "print(response.text)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "As you have explored in this notebook, the Chat endpoint is a versatile tool that empowers developers with a useful array of options and parameters." - ] } ], "metadata": { diff --git a/notebooks/llmu/Prompt_Engineering_Basics.ipynb b/notebooks/llmu/Prompt_Engineering_Basics.ipynb index 280ea2ac2..a28d32f35 100644 --- a/notebooks/llmu/Prompt_Engineering_Basics.ipynb +++ b/notebooks/llmu/Prompt_Engineering_Basics.ipynb @@ -145,7 +145,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 4, "id": "0d4130e9", "metadata": {}, "outputs": [ @@ -170,7 +170,7 @@ ], "source": [ "def generate_text(message):\n", - " stream = co.chat_stream(message=message, model=\"command-r-plus\", preamble=\"\")\n", + " stream = co.chat_stream(message=message, model=\"command-r-plus\")\n", " for event in stream:\n", " if event.event_type == \"text-generation\":\n", " print(event.text, end='')" @@ -196,7 +196,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 5, "id": "3802a5b5", "metadata": {}, "outputs": [ @@ -222,9 +222,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "Wireless Earbuds:\n", + "Sure! Here is a concise product description for wireless earbuds: \n", "\n", - "Experience true wireless freedom with our latest earbuds. Immerse yourself in your favorite tunes or take calls with crystal-clear clarity, all without the hassle of tangled cords. Our earbuds offer a secure and comfortable fit, ensuring they stay put during any activity. With a sleek and compact design, these earbuds are the perfect companion for your on-the-go lifestyle." + "\"Experience unparalleled sound with our wireless earbuds. Immerse yourself in rich, high-quality audio and enjoy the freedom of movement without tangles or hassles. Our earbuds offer a secure and comfortable fit, ensuring they stay put during any activity. With a sleek and portable design, these earbuds are the perfect companion for your active lifestyle.\"" ] } ], @@ -250,7 +250,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 6, "id": "a542f651", "metadata": {}, "outputs": [ @@ -276,17 +276,20 @@ "name": "stdout", "output_type": "stream", "text": [ - "Hook: Experience True Wireless Freedom with Superior Sound\n", + "Here is a concise product description for wireless earbuds: \n", "\n", - "Solution: Introducing our cutting-edge wireless earbuds, designed to revolutionize your audio experience.\n", + "**Hook:** Tired of tangled cords and restricted movement? \n", "\n", - "Features and Benefits:\n", - "- Immersive Audio: Enjoy superior sound quality with deep bass and crystal-clear highs, ensuring an immersive listening experience.\n", - "- True Wireless Technology: Free yourself from tangles and restrictions with a stable Bluetooth connection, providing seamless connectivity and true wireless freedom.\n", - "- Comfortable Design: The ergonomic design ensures a secure and comfortable fit, allowing you to enjoy your music without distraction.\n", - "- Extended Battery Life: With a long-lasting battery, you can listen for hours on end without worrying about recharging.\n", + "**Solution:** Go wireless with our latest earbuds! \n", "\n", - "Call to Action: Upgrade your audio experience with our wireless earbuds. Immerse yourself in superior sound, enjoy the freedom of true wireless technology, and benefit from the comfort and convenience they offer." + "**Features and Benefits:** \n", + "- Sleek and ergonomic design ensures a secure and comfortable fit. \n", + "- Advanced Bluetooth technology for seamless connectivity and uninterrupted audio. \n", + "- Immersive sound quality with powerful bass and crystal-clear highs. \n", + "- Built-in microphone for hands-free calls and voice assistant access. \n", + "- Convenient charging case provides on-the-go power. \n", + "\n", + "**Call to Action:** Experience true wireless freedom and elevate your audio experience with our cutting-edge earbuds. Order now and enjoy uninterrupted music, calls, and more!" ] } ], @@ -315,7 +318,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 7, "id": "1b5278a7", "metadata": {}, "outputs": [ @@ -341,7 +344,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "The email expresses gratitude and appreciation to the team members for their hard work, dedication, and contributions that led to the success of the recent community meetup event." + "The email expresses gratitude to the team members for their hard work, dedication, and guidance in organizing a successful community meetup, and looks forward to future collaborations." ] } ], @@ -381,7 +384,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 8, "id": "7a671108", "metadata": {}, "outputs": [ @@ -438,7 +441,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 9, "id": "83f9631e", "metadata": {}, "outputs": [ @@ -466,22 +469,25 @@ "text": [ "Here is a list of potential FAQs based on the provided text: \n", "\n", - "**Q: What does the Cohere Platform offer to developers and organizations?**\n", - "**A:** The Cohere Platform provides an API that gives developers and organizations access to cutting-edge Large Language Models (LLMs) without requiring expertise in machine learning. \n", + "- **Q: What does the Cohere Platform offer to developers and organizations?**\n", + " A: The Cohere Platform offers an API that provides access to advanced Large Language Models (LLMs) without requiring machine learning expertise. It simplifies the process by handling data curation, model development, training, and serving. \n", + "\n", + "- **Q: What are the key language processing capabilities of the Cohere Platform?**\n", + " A: The platform offers two main capabilities: text generation and text embedding. Text generation involves completing a prompt with a stream of generated text, like writing a haiku. Text embedding returns a numerical representation of the semantic meaning of a text input, useful for sentiment analysis and other measurements. \n", "\n", - "**Q: What are the key advantages of using the Cohere Platform?**\n", - "**A:** The platform handles all the complex tasks associated with LLMs, including data curation, model development, distributed training, and model serving. This allows users to focus on creating value in applied areas. \n", + "- **Q: How does the Cohere Platform benefit developers?**\n", + " A: Developers can focus on creating valuable applications without getting bogged down by the complexities of building language processing capabilities from scratch. The platform handles the heavy lifting, allowing developers to save time and effort. \n", "\n", - "**Q: What are the two main language processing capabilities provided by the Cohere Platform?**\n", - "**A:** The platform offers text generation and text embedding capabilities. Text generation involves providing a prompt and receiving a completion, such as asking for a haiku. Text embedding returns a list of numbers representing the semantic meaning of the input text, useful for sentiment analysis and other applications. \n", + "- **Q: What is the difference between text generation and text embedding?**\n", + " A: Text generation is about creating new text based on a prompt, like generating a haiku or continuing a story. Text embedding, on the other hand, translates text into a series of numbers that represent its semantic meaning, enabling quantitative analysis and understanding of the text's context. \n", "\n", - "**Q: What is an example of text generation using the Cohere Platform?**\n", - "**A:** One example is prompting the model to write a haiku, and the model will generate an original haiku as a response. \n", + "- **Q: Can I use the Cohere Platform for sentiment analysis?**\n", + " A: Yes, the text embedding capability of the Cohere Platform is particularly useful for sentiment analysis. By converting text into numerical representations, you can quantitatively analyze and understand the sentiment or emotional tone expressed in a given piece of text. \n", "\n", - "**Q: How does text embedding work, and what is its utility?**\n", - "**A:** Text embedding translates a piece of text into a list of numbers that captures its semantic meaning. This is valuable for tasks that require understanding the sentiment or underlying meaning of a text passage, enabling quantitative analysis. \n", + "- **Q: Does the Cohere Platform require machine learning expertise to use?**\n", + " A: No, the platform is designed to abstract away the complexities of machine learning. Developers can utilize the API without needing to understand the intricate details of machine learning or natural language processing. \n", "\n", - "These FAQs address some of the key points a user might inquire about regarding the Cohere Platform and its capabilities." + "These FAQs aim to address common inquiries that users might have about the Cohere Platform and its language processing capabilities." ] } ],