How Studying with Few Questions with Google’s Prompt Poet Can Improve Your Chances of Getting an LLM

How Studying with Few Questions with Google’s Prompt Poet Can Improve Your Chances of Getting an LLM

Join our day by day and weekly newsletters to receive the latest updates and exclusive content on industry-leading AI coverage. Learn more


Rapid engineering, the discipline of creating the right input to a large language model (LLM) to get the desired response, is a critical recent skill in the AI ​​era. It’s helpful even for casual users of conversational AI, but essential for creators of the next generation of AI applications.

Enter Poet of Hintsidea Character.aia startup offering conversational LLM studies, recently acquired by Google. Prompt Poet simplifies advanced prompt engineering by offering a user-friendly, low-code template system that efficiently manages context and seamlessly integrates external data. This allows LLM-generated responses to be grounded in the context of real-world data, opening up a recent horizon of AI interactions.

- Advertisement -

Prompt Poet stands out for its seamless integration of “few-shot learning,” a powerful LLM technique for rapid personalization without the need for complex and expensive model tuning. This article explores how Prompt Poet can leverage few-shot learning to deliver AI-driven personalized interactions with ease and efficiency.

Could Prompt Poet be a preview of Google’s future approach to prompt engineering in Gemini and other AI products? It’s price taking a closer look at this exciting potential.

The Power of Learning from a Few Examples

    In small-shot learning, we give the AI ​​a handful of examples of the kinds of responses we expect to receive from different possible prompts, in addition to a few “shots” of the way it should behave in similar scenarios.

    The beauty of few-shot learning is its efficiency. Tuning a model involves retraining the model on a recent dataset, which might be computationally intensive, time-consuming, and expensive, especially when working with large models. On the other hand, few-shot learning provides a small set of examples with a hint to adapt the model’s behavior to a specific context. Even models that have been tuned can profit from few-shot learning to adapt their behavior to a more specific context.

    How Prompt Poet Makes Learning Accessible with Little Information

      Prompt Poet stands out for its ability to simplify the implementation of multi-shot learning. Prompt Poet enables you to create complex, dynamic prompts that include multi-shot examples directly in the prompt structure using YAML and Jinja2 templates.

      To explore an example, let’s say you would like to develop a customer support chatbot for a retail company. Using Prompt Poet, you may easily include customer information reminiscent of order history and status of current orders, in addition to information about current promotions and sales.

      But what about tone? Should it’s more friendly and fun or formal? More concise or informative? By including “few takes” of successful examples, you may fine-tune your chatbot’s responses to suit each brand’s distinct voice.

      Basic Instructions

        A basic instruction for a chatbot might seem like this:

        - name: system instructions 
          role: system 
          content: | 
            You are a customer support chatbot for a retail site. Your job is to help customers by answering their questions, providing helpful information, and resolving issues. Below you shall be provided some example user inputs paired with responses that are desirable in terms of tone, style, and voice. Emulate these examples in your responses to the user.
        In these examples, placeholders marked with double query marks like '??placeholder??' shall be used as an alternative of real user data. After the examples, you may be provided with real data about the user's current and past orders as a customer, which you have to use faithfully in dealing with the user. 

        We also can provide the model with our real customer data so that it could actually accurately answer questions about the user’s past and current orders. If appropriate, we also can include current sales and promotions.

        - name: customer data
          role: system
          content: |    
            current orders:
            {% for order in current_orders %}
            - {{ order.description }}
            {% endfor %}
            Past orders:
            {% for order in past_orders %}
            - {{ order.description }}
            {% endfor %}
        
        - name: promotions
          role: system
          content: |    
            promotions:
            {% for promotion in promotions %}
            - {{ promotion.description }}
            {% endfor %}

        But first we’d like to offer examples of the style, tone, and voice that we promised the model in the basic instructions.

        Establishing the tone: friendly or formal?

        Some brands have a more casual, friendly and playful tone, while others prefer a more refined elegance.

        For a brand with a friendly and casual tone, examples of educational materials in several shots might seem like this:

        - name: user prompt 
          role: user 
          content: | 
            Hi, I ordered ??product_name?? but have not received it yet. What’s going on? 
        
        - name: response 
          role: assistant 
          content: | 
            Hey ??user_name??! Sorry for the hassle—let’s get this sorted out ASAP. ? I’m pulling up your order for ??product_name?? placed on ??order_date??. Hang tight while I check where it’s at! 
        
        - name: user prompt 
          role: user 
          content: | 
            I would like to update my shipping address for an order I made today, it needs to be ??new_address?? 
        
        - name: response 
          role: assistant 
          content: | 
            Gotcha, ??user_name??! Let’s make sure your ??product_name?? gets to the right place. I’ll switch your shipping to ??new_address?? immediately. All set—the rest I can do for you? 
        
        - name: user prompt 
          role: user 
          content: | 
            What’s your return policy? Not sure I’m going to like ??product_name??. 
        
        - name: response 
          role: assistant 
          content: | 
            No worries, ??user_name??! If ??product_name?? doesn’t knock your socks off, we’ve got a super easy return process. Just let me know, and I’ll make it easier to get it sorted out. ?

        For a brand that emphasizes a more formal and skilled tone, the same questions might be answered otherwise, leading the model toward a different style:

        - name: user prompt 
          role: user 
          content: | 
            Hi, I ordered ??product_name?? but have not received it yet. Can you assist? 
        
        - name: response 
          role: assistant 
          content: | 
            Thank you for reaching out, ??user_name??. I apologize for any inconvenience this will likely have caused. I'll promptly review the status of your order for ??product_name?? placed on ??order_date?? and provide an update shortly. 
        
        - name: user prompt 
          role: user 
          content: | 
            I would like to update my shipping address for an order I made today, it needs to be ??new_address?? 
        
        - name: response 
          role: assistant 
          content: | 
            Certainly, ??user_name??. I'll update your shipping information to ??new_address?? for the order placed today. The changes have been successfully applied. Is there the rest I can assist you with? 
        
        - name: user prompt 
          role: user 
          content: | 
            Could you explain your return policy? I’m uncertain about keeping ??product_name??. 
        
        - name: response 
          role: assistant 
          content: | 
            Certainly, ??user_name??. If ??product_name?? does not meet your expectations, it's possible you'll initiate a return inside our specified timeframe. I'll guide you thru the process to make sure it is handled easily and efficiently.

        Putting all of it together

        The following code uses Prompt Poet’s `Prompt` class to create a single, coherent prompt from separate pieces of background instruction, low-touch learning examples, and real user data. This allows us to elicit AI responses that are rigorously informed and highly developed in purpose and style.

        # User data
        user_past_orders = get_past_orders(user)
        user_current_orders = get_current_orders(user)
        promotions = get_promotions(user)
        
        template_data = {
            "past_orders": user_past_orders,
            "current_orders": user_current_orders,
            "promotions": promotions
        }
        
        # Create the prompt using Prompt Poet
        
        combined_template = base_instructions + few_shot_examples + customer_data
        
        prompt = Prompt(
            raw_template=combined_template,
            template_data=template_data
        )
        
        # Get response from OpenAI
        model_response = openai.ChatCompletion.create(
          model="gpt-4",
          messages=prompt.messages
        )

        Leveling Up AI with Prompt Poet

          Prompt Poet is greater than just a tool for managing context in AI prompts—it’s a gateway to advanced prompt engineering techniques like low-shot learning. By making it easy to compose complex prompts with real data and the power to customize the voice of examples across a few shots, Prompt Poet lets you create advanced AI applications that are each informative and aligned with your brand.

          As AI evolves, mastering techniques like multi-shot learning shall be key to staying ahead of the pack. Prompt Poet can make it easier to leverage the full potential of LLM by creating solutions that are powerful and practical.

          Latest Posts

          Advertisement

          More from this stream

          Recomended