Prompt LLMs in the generative AI hub in SAP AI Core & Launchpad
- How to deploy an LLM model.
- How to use the models to execute different queries.
Prerequisites
- A BTP global account
If you are an SAP Developer or SAP employee, please refer to the following links ( for internal SAP stakeholders only ) -
How to create a BTP Account (internal)
SAP AI Core
If you are an external developer or a customer or a partner kindly refer to this tutorial - An Extended SAP AI Core service plan is required, as the Generative AI Hub is not available in the Free or Standard tiers. For more details, refer to SAP AI Core Service Plans
- You have completed the client authorization for your preferred user interface.
- Access to SAP AI Core instance with the Extended plan
- Python and programming IDE (e.g. VSCode)
For more information, see SAP AI Core documentation.
- Step 1
Provision SAP AI Core in your global account
Open the SAP BTP cockpit and access your global account.
Check the entitlements for your account by clicking
Entitlements
and searching for SAP AI Core.Click
Configure Entitlements
>Add Service Plans
.Select SAP AI Core and the
extended
service plan.Save your new entitlement.
Run the booster for SAP AI Core
Choose
Boosters
from the navigation pane. Find and choose the booster forSAP AI Core
from the selection.The booster tile contains information about SAP AI Core. Click
Start
when you are ready.When you start a booster, a wizard opens up which guides you through the required steps.
View your instances and create your keys
In the subaccount section of SAP BTP Cockpit, choose
Services
from the left navigation menu andInstances and subscriptions
from the page.To see the details of your new instance, click the chevron on the entry.
To create the keys that you need to access your instance, click the three dots >
Create Service Key
.Enter a
Key Name
of your choice and clickCreate
.Once your keys have been created, you can view or download them at any time by locating the key and clicking the three dots and choosing from the available options.
Provision SAP AI Launchpad in your global account
Note: SAP AI Launchpad is optional, but is the recommended interface for use with SAP AI Core.
Configure your entitlement as before, but select
SAP AI Launchpad
.Run the booster for SAP AI Launchpad
Choose
Boosters
from the navigation pane, and then choose the booster forSAP AI Launchpad
from the selection.Click
Start
when you are ready. - Step 2
- Step 3
- Step 4
What should be the value of top_k if you need to get repeatable output?
- Step 5
- Step 6
- Step 7
- Step 8
This example tasks the LLM with condensing and summarizing a given text. The text, clearly demarcated with triple backticks, is expected to be distilled into a concise summary of no more than 30 words. The focus is on extracting the most salient points and presenting them in a succinct manner, ensuring that the essence of the original content is retained without excessive verbosity. This format is designed to challenge the LLM’s capability to discern key details and convey them efficiently. For this demo we have taken 2 pages from SAP annual report 2 on Independent Assurance Practitioner’s Report by KPMG.
- Step 9
This example instructs the LLM to formulate a concise response to a specific question, with the context provided for reference. The LLM’s answer should be encapsulated within triple backticks, ensuring a clear distinction between the question and the response. If the LLM is uncertain about the correct answer based on the provided context, it is instructed to reply with “Unsure about answer”, offering a clear acknowledgment of uncertainty rather than providing potentially inaccurate information. Where we took a part of memo by Christian Klein from SAP Annual report.
- Step 10
This example directs an LLM to perform sentiment analysis on a provided product review. The LLM is instructed to assess the sentiment of the review text and respond with a single word, either “positive” or “negative”. The review text is clearly delineated using triple backticks, ensuring clarity about which portion of the text needs to be analyzed. This format aims to extract concise and direct sentiment evaluations without any ambiguity.
- Step 11
Here in this demo we are going to try out show text expansion qualities of AI core, where we wrote a few sentences about AI core and asked the LLM model to write a 500 word blog post or paragraph based on the context it understands.
- Step 12
Here in tone Adjustment we are trying to showcase use the LLM’s capabilities to change/modify the tone of a text written by a new employee at SAP to proper professional tone.
- Step 13
Here we picked a paragraph on SAP and made a few spelling and grammatical errors. Now we will be asking the LLM to fix those errors by proofreading the content.
- Step 14
We picked up a random review from trust pilot on SAP ERP and want the LLM to perform multiple tasks at once which include sentiment analysis, checking if the user is angry with the product, which product/item they are talking about and which brand does it belong to.
- Step 15
The following example demonstrates a few-shot learning approach in prompt engineering, where the model is provided with a couple of examples to understand the desired task and format. Instead of explicitly stating the task, the LLM is given a context in which it should operate.
- Contextual Setup: The “Child” and “Grandparent” dialog sets up a context. The model is implicitly being taught that it should generate responses in the style of a wise grandparent answering a child’s questions.
- Example Provided: The first complete interaction (about patience) serves as a shot or example, guiding the model on how it should structure its response.
- Task Indication: The second interaction (about unity) is incomplete, indicating the task the model needs to perform. The goal is to get the model to continue the pattern and provide a similarly styled, profound answer to the child’s new question.
The model’s generated completion is then printed, providing insight into its understanding and continuation of the provided examples.
In summary, by using a few-shot learning approach, the model is guided to understand and emulate the style of the conversation without explicitly being told the exact format or context. This method leverages the model’s ability to generalize from few examples and produce consistent and contextually relevant outputs.
- Step 16
The following example showcases an advanced application of prompt engineering that encapsulates a multi-step task for the LLM.
-
Role Emulation: The initial statement sets the stage by instructing the LLM to assume the role of a customer service AI assistant. This prepares the model to respond in a specific, customer-service oriented manner.
-
Multi-step Instruction: The prompt is divided into two distinct steps, each guiding the model to perform a specific action:
- Step 1: Sentiment Analysis - The model is directed to discern the sentiment of a provided customer review. This sentiment could be positive, negative, or neutral.
- Step 2: Contextual Reply - Based on the extracted sentiment, the model must generate an appropriate email reply. The instructions are clear:
- Positive or Neutral Sentiment: Express gratitude.
- Negative Sentiment: Offer an apology and provide an avenue for further assistance. The model is also guided to incorporate details from the review to ensure the response feels tailored and specific to the customer’s concerns.
-
Tone and Format: The instructions emphasize writing in a concise and professional tone. Moreover, the model is guided to sign off the email as “AI customer agent”, reinforcing the context and ensuring the generated response follows a proper email format.
-
Multi-step Continuation: This prompt is an excellent example of multi-step continuation. The LLM first determines the sentiment of the review and then uses that sentiment to guide its next action, which is generating a contextually appropriate email reply.
In summary, from a prompt engineering standpoint, this example effectively leverages a structured, multi-step instruction set to guide the LLM through a complex task. The clarity and specificity of the instructions, combined with the defined role and context, aim to elicit a precise and contextually relevant response from the model.
-
- Step 17
The next example allows us to evaluate visual prompting capabilities in AI Launchpad.
To begin, navigate to AI Launchpad > Generative AI Hub > Chat. CLick on
Configure
, and in model selection, select theImage
option to enable image input.In this example, we’ll be demonstrating the following image recognition capabilities:
-
Identifying Products
-
Categorizing by Characteristics
-
Analyzing Product Placement
-
Identifying Visual and Design Elements
Identifying Products
Use the upload button to upload relevant image for context. Add a corresponding query, then hit send.
ResponseCopyThe image features several different cereal brands with various packaging colors. Here is a list of the brands and their corresponding packaging colors: 1. Post Great Grains - Packaging Colours: Brown and beige with images of grains and nuts. 2. Post Grape-Nuts - Packaging Colours: White and purple. 3. Quaker Granola - Packaging Colours: Beige and brown with images of granola. 4. Kashi Organic Promise - Packaging Colours: Light green and beige. 5. Kashi Cinnamon Harvest - Packaging Colours: Light green and beige. 6. Carnation Breakfast Essentials - Packaging Colours: Yellow and blue. 7. Quaker Life - Packaging Colours: White with blue and green accents. 8. Quaker Oatmeal Squares - Packaging Colours: Light blue and beige. 9. Kashi GOLEAN Crunch! - Packaging Colours: White with red and green text. 10. Kashi GOLEAN Crisp! - Packaging Colours: White with green and red text. 11. Post Honey Bunches of Oats - Packaging Colours: Yellow and orange with images of oats and almonds. 12. Post Shredded Wheat - Packaging Colours: Yellow and red, as well as green and red. 13. Post Honeycomb - Packaging Colours: Yellow and blue. 14. Quaker Crunchy Corn Bran - Packaging Colours: Blue with yellow text and images of corn. 15. Nature's Path Crunchy Vanilla Sunrise - Packaging Colours: Orange with images of cereal and vanilla. 16. Crunch Berries (Cap’n Crunch) - Packaging Colours: Yellow with blue and red accents and cartoon characters. 17. Cap’n Crunch - Packaging Colours: Yellow with cartoon characters. 18. Oops! All Berries (Cap’n Crunch) - Packaging Colours: Blue with cartoon characters. 19. Golden Crisp - Packaging Colours: Yellow with blue and cartoon characters. 20. Frosted Flakes - Packaging Colours: Blue with orange and white accents, featuring cartoon characters. 21. Cocoa Pebbles - Packaging Colours: Brown with cartoon characters. 22. Fruity Pebbles - Packaging Colours: Red with cartoon characters. 23. Post Raisin Bran - Packaging
Questions can further be added, without having to reupload the image in same AI Launchpad Chat instance.
Categorizing by Characteristics
PromptCopyGroup the cereals by their primary ingredients, such as oats, wheat, or corn.
ResponseCopy
Certainly! Here is a grouping of the cereals by their primary ingredients as inferred from the image: - Oats: 1. Post Great Grains 2. Quaker Oatmeal Squares 3. Post Honey Bunches of Oats 4. Quaker Granola 5. Nature’s Path Cinnamon Harvest - Wheat: 1. Post Shredded Wheat 2. Kashi GOLEAN Crunch! 3. Kashi GOLEAN Crisp! - Corn: 1. Post Honeycomb 2. Cap’n Crunch 3. Cap’n Crunch Crunch Berries 4. Cap’n Crunch Oops! All Berries 5. Golden Crisp 6. Kellogg’s Frosted Flakes 7. Quaker Life 8. Quaker Crunchy Corn Bran - Rice: 1. Post Cocoa Pebbles 2. Post Fruity Pebbles - Grape Nuts (Mixed Ingredients including Barley): 1. Post Grape-Nuts These groupings are based on the typical primary ingredient associated with each cereal type.Analyzing Product Placement
PromptCopyDescribe the placement strategy for the cereals on the shelves. Are there any patterns in how products are organized?
ResponseCopyBased on the visible organization of cereals on the shelves in the image, the placement strategy seems to follow certain patterns and organizational principles: 1. Brand Clustering: - Cereals from the same brand are typically placed together in clusters. For instance, Post cereals like Great Grains, Grape-Nuts, and Honey Bunches of Oats are located near each other on the shelves. - Similarly, Quaker cereals such as Oatmeal Squares, Life, and Granola are placed in proximity to each other. 2. Product Lines and Variants: - Different variants of the same product line are placed next to each other. As seen with Quaker Life cereals, multiple flavors are grouped together. - For the Cap’n Crunch series, different versions (Crunch Berries, Oops! All Berries, and the original) are placed side by side. 3. Shelf Level and Product Type: - Healthier or whole grain options like Kashi Organic Promise and Grape-Nuts are placed at eye level on the top shelves, which may be aimed at health-conscious shoppers. - Popular, colorful, and marketed-to-children cereals such as Cap’n Crunch, Fruity Pebbles, and Cocoa Pebbles are placed on the middle to lower shelves where they are easily accessible and visible to children. 4. Breakfast Essentials and Granola Bars: - Non-cereal breakfast options like granola bars are placed towards the top, likely to encourage shoppers to consider these alternatives alongside their cereal choices. - Breakfast Essentials, aimed at providing quick meal options, are placed on the top shelf, potentially targeting adult shoppers looking for convenient breakfast solutions. 5. Vertical Space Utilization: - Vertical space is used to provide a variety of choices within the same category of cereals, allowing easy comparison. This is seen with multiple rows of products like Shredded Wheat and Honey Bunches of Oats. 6. Promotional Items: - Non-cereal items designed to attract attention, such as the hanging Fruit Loops Candy Rolls, are placed at eye-catching positions to entice impulse purchases. Overall, the placement strategy appears to be well-thought-out, aiming to make it easy for customers to find specific brands, compare similar products, and attract attention to special items or promotions.
Identifying Visual and Design Elements
PromptCopyAnalyze the design elements used on the cereal boxes, such as mascots, colors, and typography.
ResponseCopyThe design elements on cereal boxes play a crucial role in attracting shoppers. Here's a detailed analysis of the primary design elements used: - Mascots: - Cartoon Characters: Many cereal brands, especially those marketed towards children, use mascots or cartoon characters to create a friendly and engaging look. For example: - Cap’n Crunch features the iconic Cap’n Crunch character, which is instantly recognizable and appeals to kids. - Frosted Flakes showcases Tony the Tiger, a friendly and energetic character that makes the cereal memorable. - Cocoa Pebbles and Fruity Pebbles use characters from "The Flintstones," which adds a nostalgic and fun element. - Colors: - Bright and Vibrant Colors: These are used to grab attention and make products stand out on the shelves. - Cap’n Crunch and Crunch Berries use bold yellows and vibrant reds and blues to be eye-catching. - Fruity Pebbles and Cocoa Pebbles use bold reds and browns respectively, which stand out on the shelves. - Natural and Earth Tones: Used for more health-conscious products to suggest wholesomeness and natural ingredients. - Kashi cereals use greens and beiges to indicate health and organic qualities. - Post Great Grains and Quaker Granola use browns and beiges to suggest natural ingredients and healthiness. - Typography: - Bold and Large Fonts: The main product names are often in large, bold fonts to ensure high readability and easy recognition. - Life cereal has its name in large, bold letters. - Honeycomb uses large blocky letters to make the product name noticeable. - Playful Fonts: For child-friendly cereals, playful or whimsical fonts are used. - Oops! All Berries uses a fun and dynamic font to appeal to children. - Emphasis on Benefits: Key nutritional benefits or unique features are highlighted in contrasting colors or boxed texts. - Honey Bunches of Oats often directly states health benefits like "whole grain" on the box. - Imagery: - Images of Cereal and Ingredients: High-quality images of the product in a bowl, often with milk, are used to evoke taste and texture, making the cereal look appetizing.
NOTE: The image recognition capabilities are not limited to the above demonstrated characteristics, and can be extended and modified based on individual use-case and scenarios.
-
- Provisioning SAP AI Core
- Checking for foundation-models scenario
- Creating a configuration
- Creating a deployment
- Querying the LLMs
- Prompt Management
- Prompt Administration
- Text Summarization
- Question Answering
- Text Classification - Sentiment Analysis
- Expansion
- Tone adjustment
- Spell-check / Grammar-check
- Doing multiple tasks at once
- Few-Shot Prompting
- Zero-Shot prompting
- Visual Prompting