https://raw.githubusercontent.com/ajmaradiaga/feeds/main/scmt/topics/SAP-AI-Launchpad-blog-posts.xml SAP Community - SAP AI Launchpad 2024-05-20T11:11:36.748871+00:00 python-feedgen SAP AI Launchpad blog posts in SAP Community https://community.sap.com/t5/technology-blogs-by-sap/how-sap-s-generative-ai-architecture-redefines-business-applications/ba-p/13580679 How SAP's Generative AI Architecture Redefines Business Applications 2023-12-20T14:42:20+01:00 philipp_herzig https://community.sap.com/t5/user/viewprofilepage/user-id/195453 <P><IMG src="https://community.sap.com/legacyfs/online/storage/blog_attachments/2023/12/01-high-res.png" border="0" /></P><P><SPAN><BR /></SPAN><SPAN>At SAP, we view artificial intelligence (AI) not as a standalone technology, but as an integrated part of our business applications that infuses intelligence natively into business processes. The introduction of generative AI marks a disruptive shift that will transform how businesses operate, make decisions, and optimize processes. Contextualizing this technology in a business setting can unlock unprecedented value for our customers. </SPAN><SPAN>&nbsp;</SPAN><BR /><BR /><A href="https://www.youtube.com/live/6BsvzygS5Hg?si=dSHYyWBWuROpY0OY&amp;t=4358" target="_blank" rel="noopener nofollow noreferrer"><SPAN>At SAP TechEd on November 2-3</SPAN></A><SPAN>, 2023, we announced the introduction of <A href="https://community.sap.com/t5/technology-blogs-by-sap/how-sap-s-generative-ai-hub-facilitates-embedded-trustworthy-and-reliable/ba-p/13596153" target="_self">generative AI hub</A>, expected to be generally available by end of 2023, and <A href="https://news.sap.com/2024/04/sap-hana-cloud-vector-engine-ai-with-business-context/" target="_self" rel="noopener noreferrer">SAP HANA Cloud Vector Engine</A>, which will be available by March 2024. </SPAN><SPAN>&nbsp;</SPAN><BR /><SPAN>This blog post is the first of a series that dives deeper into various aspects of SAP’s approach to generative AI and its technical underpinnings.</SPAN><SPAN><BR /></SPAN><SPAN>&nbsp;</SPAN><BR /><STRONG><SPAN>SAP’s Generative AI Strategy&nbsp;</SPAN></STRONG><SPAN>&nbsp;</SPAN><BR /><BR /><SPAN>SAP believes that generative AI is one of the most consequential technologies of our time, and SAP is committed to helping our clients leverage generative AI to create tremendous business value. SAP specializes in business AI: generative AI that is relevant since it’s embedded in your business applications and processes from day one; that is reliable since we train, ground, and adapt generative AI on your business data and context; and that is responsible by design, following SAP’s rigorous AI ethics, privacy, and security practices.</SPAN><SPAN>&nbsp;</SPAN><BR /><BR /><SPAN>SAP is releasing generative AI-powered capabilities and features natively into our cloud business software, including Joule, our generative AI copilot that transforms how people interact with their processes and data. New capabilities on SAP Business Technology Platform, like a vector database engine in SAP HANA and generative AI hub, allow customers and partners to create generative AI-powered extensions and apps. We foster an ecosystem of strategic partnerships to leverage the best generative AI models available.</SPAN><SPAN>&nbsp;</SPAN><BR /><BR /><SPAN>We also believe that while AI is a useful tool, humans still play a key role in business decision-making and reasoning. Therefore, we deliberately design our AI solutions following our AI ethics policy and to keep humans in the loop to carefully review AI-generated information.</SPAN><SPAN>&nbsp;</SPAN><BR /><BR /><STRONG><SPAN>SAP’s Architecture for Generative AI</SPAN></STRONG><SPAN>&nbsp;</SPAN><BR /><BR /><SPAN>With more than 75% of the world's transaction revenue touching an SAP software system, SAP is uniquely positioned to integrate AI into business processes to create value. Already, over 24,000 SAP cloud customers actively use more than 130 AI scenarios in our applications and SAP BTP.&nbsp;</SPAN><SPAN>&nbsp;</SPAN><BR /><BR /><SPAN>The recent advancements in AI have opened vast opportunities that go far beyond what has been possible until today. At SAP, we are leveraging our deep business process knowledge to natively embed generative AI across our business application portfolio. Our teams are developing a wide range of </SPAN><STRONG><SPAN>use cases</SPAN></STRONG><SPAN> from question answering, text generation, classification, and summarization to code generation and are exploring the potential of emerging paradigms such as large language model agents.&nbsp;</SPAN><SPAN>&nbsp;</SPAN></P><P><IMG src="https://community.sap.com/legacyfs/online/storage/blog_attachments/2023/12/02-3.png" border="0" /></P><P><BR /><I><SPAN>Figure 1: Generative AI architecture enables fast and compliant productization of use cases with the most common generative AI models while ensuring compliance with enterprise standards.&nbsp; </SPAN></I><SPAN>&nbsp;</SPAN><BR /><BR /><SPAN>Each generative AI model yields unique qualities and strengths. To meet customers’ needs for their business, SAP has made a strategic move to provide enterprise-grade </SPAN><STRONG><SPAN>access</SPAN></STRONG><SPAN> to the most common models through its generative AI hub as part of SAP AI Core as illustrated in Figure 1. This includes leading cloud vendors as well as SAP-managed third-party models deployed on SAP’s own infrastructure for highest compliance standards. Moreover, the rapid evolution of open-source models has been impressive, and we're committed to keeping pace with this innovation by making selected open-source models available.</SPAN><SPAN>&nbsp;</SPAN><BR /><BR /><SPAN>However, even the most capable generative AI models risk 'hallucinations' or generate outputs that don't align with reality. At SAP, we are grounding our use cases in the vast amount of high-quality, real-world business and industry data that is at the core of our enterprise solutions. By leveraging techniques such as prompt engineering, in-context learning, and retrieval augmented generation (RAG), we are augmenting large language models (LLMs) with our customers’ data and generating results that are contextual and relevant to their specific business environment. The generative AI hub is </SPAN><STRONG><SPAN>orchestrating</SPAN></STRONG><SPAN> data flows towards our data platform, a key component to enable our development teams to scale development at low cost and provide a rich data model across business processes.</SPAN><SPAN>&nbsp;</SPAN><BR /><BR /><SPAN>For this, we are also working on bringing </SPAN><STRONG><SPAN>vector database</SPAN></STRONG><SPAN> capabilities to SAP HANA Cloud to store embeddings, a form of semantic data representation capable of translating high-dimensional data into a lower-dimensional space.</SPAN> <SPAN>This is particularly useful for making sense of complex and unstructured data, such as text, images, or user behavior, by capturing the essence of the data in a condensed form.&nbsp;</SPAN><SPAN>&nbsp;</SPAN><BR /><BR /><SPAN>We also provide developers with a playground system and libraries to explore and build on top of these technology components. At SAP, more than 35,000 employees are already using this playground system and have generated over one million prompts.</SPAN><SPAN>&nbsp;</SPAN><BR /><BR /><SPAN>Moreover, we recognize the importance of </SPAN><STRONG><SPAN>trust</SPAN></STRONG><SPAN> and transparency in the context of generative AI. Our technology enables us to implement strong authorization, audit and monitoring capabilities.&nbsp; We apply tenant segregation and zero data retention rules including no third-party training on our customers’ data as well as our strict data privacy policy. We understand that AI models have the potential to generate content that may not always align with ethical or quality standards. For this, we are building robust measures such as</SPAN> <SPAN>prompt templates and validation, and content management to filter these outputs so that they align with common standards.</SPAN><SPAN>&nbsp;</SPAN><BR /><BR /><SPAN>Our approach is not only ensuring enterprise standards, but it is also the technical backbone of SAP's commercial framework. Rather than imposing a one-size-fits-all solution, we provide our customers the flexibility to consume generative AI capabilities in SAP’s business applications that address their specific needs and objectives. </SPAN><SPAN>&nbsp;</SPAN><BR /><BR /><SPAN>Building on these technical underpinnings, we recently </SPAN><A href="https://news.sap.com/2023/09/joule-new-generative-ai-assistant/" target="_blank" rel="noopener noreferrer"><SPAN>announced </SPAN><STRONG><SPAN>Joule</SPAN></STRONG></A><SPAN> as SAP's gen-AI powered digital assistant that is embedded across our suite of business applications. The primary aim of Joule is to enhance productivity for our customers’ users by streamlining their daily tasks and decision-making processes. Recognizing the potential of generative AI, we are integrating technical components into Joule to augment conversational capabilities. These include analytics, text editing, document Q&amp;A, and generative capabilities through a federated architecture to enable contextual and relevant user interaction. </SPAN><SPAN>&nbsp;</SPAN><BR /><BR /><SPAN>We recognize the extensive impact of AI on decision-making, fairness, transparency, privacy, and dignity. It is this recognition that led us, in 2018, to establish a robust </SPAN><A href="https://www.sap.com/products/artificial-intelligence/ai-ethics.html?pdf-asset=a8431b91-117e-0010-bca6-c68f7e60039b&amp;page=1" target="_blank" rel="noopener noreferrer"><STRONG><SPAN>ethical framework</SPAN></STRONG></A><SPAN> guiding our AI development and operations. Our ethical principles are anchored in a commitment to human rights, designing for people, striving for bias-free business, transparency, upholding quality and safety, data protection, and engaging with broader societal challenges and regulators.</SPAN><SPAN>&nbsp;</SPAN><BR /><BR /><STRONG><SPAN>Conclusion</SPAN></STRONG><SPAN>&nbsp;</SPAN><BR /><BR /><SPAN>By integrating generative AI into our business processes, applications, and SAP BTP, we aim to unlock unprecedented value for our customers. Our strategy is centered on ensuring trust, control, and business readiness to harness the full potential of generative AI. </SPAN><SPAN>&nbsp;</SPAN><BR /><BR /><SPAN>Looking ahead, we are committed to keeping pace with the rapidly evolving landscape and will continue to explore and innovate in this exciting new field of AI. In the coming 6 months, we plan to further enhance our platform and embed Joule in many of our business applications.</SPAN> <SPAN>We are also working on many more generative AI innovations in our business applications from writing assistants generating job descriptions to intelligent process recommendations.</SPAN><SPAN>&nbsp;</SPAN><BR /><BR /><SPAN>We look forward to sharing more insights as part of this blog series and invite you to join us on this journey exploring the transformative potential of generative AI in business processes. Stay tuned for the next part of this series: we will deep dive into <A href="https://community.sap.com/t5/technology-blogs-by-sap/how-sap-s-generative-ai-hub-facilitates-embedded-trustworthy-and-reliable/ba-p/13596153" target="_self">SAP's generative AI hub</A>.</SPAN></P><P>Explore and learn more in our related publications:&nbsp;</P><UL><LI><A class="" title="https://community.sap.com/t5/technology-blogs-by-sap/how-sap-s-generative-ai-hub-facilitates-embedded-trustworthy-and-reliable/ba-p/13596153" href="https://community.sap.com/t5/technology-blogs-by-sap/how-sap-s-generative-ai-hub-facilitates-embedded-trustworthy-and-reliable/ba-p/13596153" target="_blank">How SAP’s Generative AI Hub facilitates embedded, trustworthy, and reliable AI</A>&nbsp;by <A href="https://community.sap.com/t5/user/viewprofilepage/user-id/217337" target="_self">Andreas Roth</A></LI><LI><A class="" title="https://community.sap.com/t5/technology-blogs-by-sap/boosting-benchmarking-for-reliable-business-ai/ba-p/13650962" href="https://community.sap.com/t5/technology-blogs-by-sap/boosting-benchmarking-for-reliable-business-ai/ba-p/13650962" target="_blank">Boosting Benchmarking for Reliable Business AI</A>&nbsp;by <A href="https://community.sap.com/t5/user/viewprofilepage/user-id/1396220" target="_self">Hao Zhi Leong</A></LI></UL><P>-------<BR /><EM>Co-authored by Dr. Philipp Herzig and Dr. J<SPAN class="">an Dumke</SPAN></EM></P> 2023-12-20T14:42:20+01:00 https://community.sap.com/t5/technology-blogs-by-sap/generative-ai-hub-out-now/ba-p/13580462 Generative AI Hub - OUT NOW! 2023-12-21T13:39:32+01:00 HadiHares https://community.sap.com/t5/user/viewprofilepage/user-id/8085 <P>At TechEd 2023, we previewed the generative AI hub in SAP AI Core and SAP AI Launchpad and the excitement went through the roof. <span class="lia-unicode-emoji" title=":rocket:">🚀</span><BR /><BR />&nbsp;</P><P><IMG src="https://community.sap.com/legacyfs/online/storage/blog_attachments/2023/12/Bildschirmfoto-2023-12-20-um-01.13.52.png" border="0" /></P><P>&nbsp;</P><P class="">Generative AI Hub Announcement at TechEd 2023</P><P><BR />&nbsp;</P><H3 id="toc-hId-1093843140">I am now thrilled to announce that the generative AI hub is released to customers.</H3><P><BR />&nbsp;<BR /><BR />We worked quite hard and successfully integrated generative AI capabilities into our SaaS solution offerings (i.e. SAP SuccessFactors) with the generative AI hub as its foundation. More and more embedded generative AI capabilities will be shipped across 2024, all leveraging the functionality of the generative AI hub. We now can also offer the same generative AI hub to developers and enable them to create generative AI extensions on SAP BTP for their SAP solutions like SAP S/4HANA, SAP SuccessFactors, etc.<BR /><BR />The generative AI hub gives you instant access to a broad range of large language models (LLMs) from different providers, such as GPT-4 by Azure OpenAI or OpenSource Falcon-40b. With this access, you’ll be able to orchestrate multiple models, whether programmatically via SAP AI Core or via the playground within SAP AI Launchpad.<BR /><BR />We truly believe that by providing a safe and secure playground to each employee will result in an enormous boost in productivity, creativity and efficiency to ultimately improve people's lives. This is our own learning within SAP and now we are making it also available to customers for their employees.</P><P><IMG src="https://community.sap.com/legacyfs/online/storage/blog_attachments/2023/12/GenAI_Hub_demo_short_720p_15fps-2.gif" border="0" /></P><P>&nbsp;</P><P class="">Generative AI Hub Playground Demo</P><P><BR />The generative AI hub provides tooling for prompt engineering, experimentation, and other capabilities to accelerate the development of BTP applications infused with generative AI, in a secure and trusted way. AI development teams can submit a prompt to multiple LLMs, compare the generated outcomes to identify the best-suited model for the task, and gain greater control and transparency with the built-in prompt history.</P><H3 id="toc-hId-897329635"><U>Availability</U></H3><P><BR />The generative AI hub is now generally available via SAP AI Core for productive use.<BR /><BR />A dedicated trial environment is planned in the upcoming weeks.<BR /><BR /><SPAN class=""><SPAN class=""><SPAN class="">In addition, all task-specific AI capabilities in SAP AI Core &amp; SAP AI Launchpad are getting further enhancements and plan to take advantage of the generative AI hub.</SPAN></SPAN></SPAN><SPAN class="">&nbsp;</SPAN></P><H3 id="toc-hId-700816130"><U>License</U></H3><P><BR />The generative AI hub is available as consumption-based pricing within <A href="https://help.sap.com/docs/btp/sap-business-technology-platform/what-is-consumption-based-commercial-model" target="_blank" rel="noopener noreferrer">CPEA</A>. Customers with existing cloud credits can directly consume LLMs upon entitling SAP AI Core in their BTP subaccount, without the need to manage different commercial frameworks from various LLM providers.<BR /><BR />For our partners, we are working on a Test, Demonstration and Development (TDD) license and targeting late Q1 ’24.</P><P>UPDATE:</P><P>TDD license is now available for our partners!</P><H3 id="toc-hId-504302625"><U>SAP's Generative AI Architecture</U></H3><P><BR />For a more deep dive how we shape our Generative AI Architecture, please refer to this <A href="https://blogs.sap.com/2023/12/20/how-saps-generative-ai-architecture-redefines-business-applications/" target="_blank" rel="noopener noreferrer">blogpost</A>.</P><H3 id="toc-hId-307789120"><U>Learn more</U></H3><P><BR /><A href="https://roadmaps.sap.com/board?range=FIRST-LAST&amp;FT=GEN_AI#Q4%202023" target="_blank" rel="noopener noreferrer">Roadmap for Generative AI overall</A><BR /><BR /><A href="https://roadmaps.sap.com/board?range=FIRST-LAST&amp;PRODUCT=73554900100800003641&amp;PRODUCT=73555000100800003283#Q4%202021" target="_blank" rel="noopener noreferrer">Roadmap for generative AI hub in SAP AI Core &amp; SAP AI Launchpad</A><BR /><BR /><A href="https://discovery-center.cloud.sap/serviceCatalog/sap-ai-core?region=all" target="_blank" rel="noopener nofollow noreferrer">SAP Discovery Center</A><BR /><BR /><A href="https://help.sap.com/docs/sap-ai-core?locale=en-US" target="_blank" rel="noopener noreferrer">Documentation</A><BR /><BR /><A href="https://developers.sap.com/tutorials/ai-core-generative-ai.html" target="_blank" rel="noopener noreferrer">Tutorial for generative AI Hub</A><BR /><BR /><A href="https://discovery-center.cloud.sap/refArchDetail/ref-arch-open-ai" target="_blank" rel="noopener nofollow noreferrer">Reference Architecture for Generative AI in SAP BTP</A><BR /><BR />Make sure to also follow our AI tags on SAP Community and start interacting with your peers.<BR /><BR /></P><UL><UL><LI><A href="https://community.sap.com/topics/machine-learning" target="_blank">Artificial Intelligence / Machine Learning</A></LI></UL></UL><P>&nbsp;</P><UL><UL><LI><A href="https://community.sap.com/topics/ai-core-artificial-intelligence" target="_blank">SAP AI Core</A></LI></UL></UL><P>&nbsp;</P><UL><UL><LI><A href="https://community.sap.com/topics/ai-launchpad" target="_blank">SAP AI Launchpad</A></LI></UL></UL><P>&nbsp;</P><UL><UL><LI><A href="https://community.sap.com/topics/artificial-intelligence" target="_blank">SAP AI Services</A></LI></UL></UL><P>&nbsp;</P> 2023-12-21T13:39:32+01:00 https://community.sap.com/t5/technology-blogs-by-members/understanding-generative-ai-core-concepts/ba-p/13574898 Understanding Generative AI: Core Concepts 2024-01-10T15:04:25+01:00 rishi_singh3 https://community.sap.com/t5/user/viewprofilepage/user-id/675993 Dear All,<BR /> <BR /> How are you?<BR /> <BR /> It is quite impossible nowadays to look at any technology news and not hear of Generative AI. Let us try to first understand the same from the very beginning and basics.<BR /> <BR /> We will first understand the basic concepts and then will drift toward how SAP has incorporated the same in its business model.<BR /> <BR /> But before we do that, let us have a good look at the capabilities of SAP in areas of AI, it's very important to understand that SAP has already incorporated the AI capabilities but it has now enabled GenAI scenarios.<BR /> <BR /> Just have a good look at the below and next we will move to start with BASIC's.<BR /> <P style="overflow: hidden;margin-bottom: 0px"><IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/blog_attachments/2024/01/Screenshot-2024-01-12-012655.jpg" /></P><BR /> <B>What is “intelligence”? </B>The ability to accomplish complex goals.<BR /> <BR /> <IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/blog_attachments/2024/01/Picture1-18.png" height="121" width="189" /><BR /> <BR /> <B>What is “</B><B>artificial intelligence</B><B>”? </B>Intelligence exhibited by non-biological systems.<BR /> <P style="overflow: hidden;margin-bottom: 0px"><IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/blog_attachments/2024/01/Picture2-9.png" height="115" width="190" />Now let us understand the <STRONG>Approaches to Artificial Intelligence</STRONG><IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/blog_attachments/2024/01/Screenshot-2024-01-10-184428.jpg" />Now as we have a basic understanding of AI concepts let us talk about <B>Generative AI.</B></P><BR /> Below are some of the quick facts:<IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/blog_attachments/2024/01/Screenshot-2024-01-10-184809.jpg" height="131" width="304" /><BR /> <BR /> Now let us look at the basic definitions:<BR /> <UL><BR /> <LI><B>Foundation models </B>are neural networks trained on large volumes of data using self-supervised learning that can be applied to many tasks.</LI><BR /> <LI><B>Large language models (LLMs) </B>are a subcategory of foundation models for text incl. computer code.</LI><BR /> <LI><B>Generative AI </B>can create novel output in text, images, sound, or video based on simple user input (called “prompts”).</LI><BR /> </UL><BR /> <P style="overflow: hidden;margin-bottom: 0px"><IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/blog_attachments/2024/01/Picture3-11.png" height="213" width="303" /></P><BR /> <P style="overflow: hidden;margin-bottom: 0px">Now let us look at <B>Generative AI at SAP</B></P><BR /> <P style="overflow: hidden;margin-bottom: 0px">Generative AI enables completely new capabilities in business software. With generative AI, we can create new content, summarize complex information, write computer code, and more. It is a new generation of AI that can reason through business problems and make suggestions that were previously unthinkable. Customers can expect generative AI use cases that bring tangible value across the SAP portfolio.</P><BR /> The below timeline shows the Evaluation of SAP products in terms of technology and innovation.<BR /> <P style="overflow: hidden;margin-bottom: 0px"><IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/blog_attachments/2024/01/Screenshot-2024-01-10-185403.jpg" /></P><BR /> Generative AI is not all good and rosy, it does have its fair amount of limitations and hiccups.<BR /> <BR /> <B>The </B><B>limitations of generative AI models</B><BR /> <UL><BR /> <LI><B>Hallucinat</B><B>io</B><B>n</B>. Large language models can generate plausible-sounding yet false answers.</LI><BR /> <LI><B>Up-to-date and specific knowledge</B>. The knowledge of a generative AI model is frozen in time from when it was trained. In contrast to world general knowledge, business information changes quickly.</LI><BR /> <LI><B>Inconsistent math abilities and limited notion of time</B>. Although improving, large language models are not calculators. Other kinds of foundation models could conceivably complete forecasts and math.</LI><BR /> </UL><BR /> But some methods will help to make it more reliable and efficient.<BR /> <UL><BR /> <LI><B>Prompt Engineering -</B> Provide more information to describe the task</LI><BR /> <LI><B>Retrieval </B><B>Augmented </B><B>Generation(</B><B>RAG) - </B>Extend to external domain knowledge by<BR /> retrieving and injecting information via embeddings (numeric vectors).</LI><BR /> <LI><B>Orchestration Tools - </B>Agents, functions, plug-ins, prompt and model chaining, memory.</LI><BR /> </UL><BR /> Now let us try to understand how SAP has incorporated Generative AI within its business models.<BR /> <BR /> <B>Extending SAP applications with generative AI</B><BR /> <BR /> SAP has provided the entry point to Generative AI, with a BTP application SAP AI Launchpad which can be found in the SAP Discovery Center.<BR /> <P style="overflow: hidden;margin-bottom: 0px"><IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/blog_attachments/2024/01/Picture5-5.png" height="140" width="213" /></P><BR /> SAP AI Launchpad is a multitenant software as a service (SaaS) application in the SAP Business Technology Platform. Customers and partners can use SAP AI Launchpad to manage AI use cases (scenarios) across multiple instances of AI runtimes (such as SAP AI Core). SAP AI Launchpad also provides generative AI capabilities via the Generative AI Hub.<BR /> <BR /> The below diagram is quite self-explanatory and helps to understand SAP capability in Generative AI.<BR /> <UL><BR /> <LI>At the very top layer, it has an SAP AI launchpad that provides various tools for Prompt engineering and management.</LI><BR /> <LI>The bottom layer showcases the Trust and control that SAP has incorporated with the foundation models so that it would be reliable for the business.</LI><BR /> <LI>SAP is introducing a vector engine within SAP HANA Cloud so that it understands, extracts or insert data in a natural language.</LI><BR /> </UL><BR /> <P style="overflow: hidden;margin-bottom: 0px"><IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/blog_attachments/2024/01/Picture4-7.png" /></P><BR /> Now let us talk about the <B>Generative AI business use cases</B><B><BR /> </B><BR /> <UL><BR /> <LI><B>Just Ask feature for SAP Analytics Cloud</B></LI><BR /> <LI><B>Document Information Extraction in SAP Transportation Management Application</B></LI><BR /> <LI><B>Joule </B><B>– </B><B>The copilot that truly understands your business</B></LI><BR /> </UL><BR /> The below diagram shows some more use cases.<BR /> <P style="overflow: hidden;margin-bottom: 0px"><IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/blog_attachments/2024/01/Picture6-6.png" /></P><BR /> I hope this will spark more interest in the areas of AI and GenAI, I would like to mention that technology is ever-evolving. GenAI seems to have a long road ahead.<BR /> <BR /> Thanks all for reading the article, please do leave feedback, if possible.<BR /> <BR /> Happy Learning !! 2024-01-10T15:04:25+01:00 https://community.sap.com/t5/technology-blogs-by-members/unleashing-the-power-of-sap-ai-launchpad-amp-sap-ai-core-create-your-first/ba-p/13583759 Unleashing the Power of SAP AI Launchpad & SAP AI Core: Create Your First AI Project 2024-01-28T17:45:07.242000+01:00 patrosrinivasa https://community.sap.com/t5/user/viewprofilepage/user-id/44687 <P><STRONG>Introduction:</STRONG></P><P>Hello All, Here I am ready with another blog on SAP AI Launchpad &amp; SAP AI Core. I will walk you through this blog and share my knowledge on how you can create your IST AI project with these trending AI technologies in SAP BTP platform.&nbsp;</P><P><SPAN>As many of you already know that SAP AI Core is a service in the SAP BTP that allows us to confidently deploy and manage artificial intelligence models that natively integrate with SAP applications. In this blog, I am going to show you how you can create an application with SAP AI Launchpad-SAP AI Core by connecting with GitHub repository.</SPAN></P><P><SPAN>Let's start..</SPAN></P><P><SPAN>Before going further, Please don't forget below pre-requisites to complete. Otherwise you can't able to see the desired output.<span class="lia-unicode-emoji" title=":winking_face:">😉</span></SPAN></P><P><STRONG>Prerequisites:</STRONG></P><OL><LI><SPAN>SAP BTP Global account access</SPAN></LI><LI><SPAN>Setup account for SAP AI Launchpad &amp; SAP AI Core.</SPAN></LI><LI><SPAN>GitHub account access.</SPAN></LI></OL><P><SPAN>&nbsp;</SPAN><SPAN>Note: &nbsp;If you are using a GitHub account hosted by your organization, it must be external facing (not behind a firewall).</SPAN></P><P><SPAN>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</SPAN><SPAN>To connect GitHub to SAP AI Core, we need to create a GitHub repository and a GitHub access token. A GitHub repository is where we store our AI workflows and other files. Each workflow can be used in various AI use cases. A GitHub access token is a code that allows SAP AI Core to access our GitHub repository. Below is screenshots for reference how you can generate access token and workflow pipeline.</SPAN><SPAN>&nbsp;</SPAN></P><P><SPAN><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="image1.PNG" style="width: 881px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/53890iC067B8DD33E6995A/image-size/large?v=v2&amp;px=999" role="button" title="image1.PNG" alt="image1.PNG" /></span></SPAN></P><P>&nbsp;</P><P><SPAN>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Once we have created a GitHub repository and a GitHub access token, we will establish bridge between SAP AI Core and our GitHub by clicking on ADD button and provide your repo url and credentials.</SPAN></P><P><STRONG>Before creating Repository:</STRONG></P><P><SPAN><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image2.PNG" style="width: 902px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/53891iCC58A4C3E53DC6B1/image-size/large?v=v2&amp;px=999" role="button" title="image2.PNG" alt="image2.PNG" /></span></SPAN></P><P>&nbsp;</P><P><STRONG>After creating Repository:</STRONG></P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image3.PNG" style="width: 910px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/53892i968CEFC67B69810E/image-size/large?v=v2&amp;px=999" role="button" title="image3.PNG" alt="image3.PNG" /></span></P><P>&nbsp;</P><P><SPAN>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; In case you didn't store your access key locally or forgot don't worry.. You can regenerate token as shown in below screen. All you have to do is click Regenerate Token button.</SPAN></P><P><SPAN><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image4.PNG" style="width: 883px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/53893i4E0829EA66F50C29/image-size/large?v=v2&amp;px=999" role="button" title="image4.PNG" alt="image4.PNG" /></span></SPAN></P><P><SPAN>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; After following all the steps that I have explained, you will see below screen. If you had reached below screen means you are doing great and have completed half of the process&nbsp;<span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:">😊</span></SPAN></P><P><SPAN><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image 5 and 6.png" style="width: 884px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/53894iF28662774A34326D/image-size/large?v=v2&amp;px=999" role="button" title="image 5 and 6.png" alt="image 5 and 6.png" /></span>&nbsp;</SPAN></P><P><SPAN>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; After creating workflow in GitHub we will jump into SAP AI Launchpad to create an application to sync workflows with SAP AI Core.</SPAN></P><P><SPAN><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image7.PNG" style="width: 718px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/53898i200EF4C865B42AF9/image-size/large?v=v2&amp;px=999" role="button" title="image7.PNG" alt="image7.PNG" /></span></SPAN></P><P><SPAN>once application is ready we can check our scenario(Name, Executable ID and Description etc details) under ML Operations node in SAP AI Launchpad.</SPAN></P><P><SPAN><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image8.PNG" style="width: 781px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/53899iBA77CF70AD8FF8BF/image-size/large?v=v2&amp;px=999" role="button" title="image8.PNG" alt="image8.PNG" /></span></SPAN></P><P><SPAN>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;To run executable, all we have to do is create a config file. The&nbsp;configuration name&nbsp;value should be a descriptive name of your choice. All other values must be set as shown in the image below, in line with your executable identifiers.</SPAN><SPAN>&nbsp;</SPAN></P><P><SPAN>Note: This step is one time only. Once a configuration is created, you can use it again and again.</SPAN></P><P>To execute your workflow, click&nbsp;<STRONG>Create Execution</STRONG>&nbsp;on the configuration details page.</P><P><SPAN><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image9.PNG" style="width: 781px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/53900iB462DA867BC3E4D6/image-size/large?v=v2&amp;px=999" role="button" title="image9.PNG" alt="image9.PNG" /></span></SPAN></P><P>&nbsp;</P><P><SPAN>after updating our workflow with another modification we can see the sync directly in SAP AI Launchpad logs section. All this because of configuration file was fetching info based on executableID&nbsp;that we defined in our workflow.</SPAN></P><P><SPAN><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image10.PNG" style="width: 768px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/54037i3605052104AC0A94/image-dimensions/768x602?v=v2" width="768" height="602" role="button" title="image10.PNG" alt="image10.PNG" /></span>&nbsp;</SPAN><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image11.PNG" style="width: 763px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/54038iA81B85679D915524/image-dimensions/763x360?v=v2" width="763" height="360" role="button" title="image11.PNG" alt="image11.PNG" /></span></P><P><SPAN>If you got above message under Execution Logs section, then your workflow is working perfectly fine. Job Well done!!</SPAN></P><P><SPAN>&nbsp;</SPAN><STRONG>Conclusion:</STRONG></P><P><SPAN>&nbsp;</SPAN><SPAN>So we have completed a project creation with help of SAP AI Launchpad, SAP AI Core and GitHub. SAP AI Launchpad is a multitenant SaaS application in SAP Business Technology Platform. Customers and partners can use SAP AI Launchpad to manage AI use cases aka scenarios across multiple instances of AI runtimes. I have shown you 1 of the runtime environment SAP AI Core here. We can explore more gen AI capabilities via the Generative AI Hub available via SAP AI Launchpad.</SPAN><SPAN>&nbsp;</SPAN></P><P><SPAN>Hope you liked it. Thanks for reading this blog. Happy learning!!</SPAN></P><P><STRONG>Reference Links:</STRONG></P><P><SPAN><A href="https://help.sap.com/docs/sap-ai-core " target="_self" rel="noopener noreferrer">https://help.sap.com/docs/sap-ai-core </A>&nbsp;</SPAN></P><P><SPAN><A href="https://community.sap.com/topics/ai-core-artificial-intelligence" target="_self">https://community.sap.com/topics/ai-core-artificial-intelligence</A>&nbsp;</SPAN></P><P><SPAN><A href="https://help.sap.com/docs/ai-launchpad/sap-ai-launchpad/what-is-sap-ai-launchpad?q=sap%20ai%20launchpad" target="_self" rel="noopener noreferrer">https://help.sap.com/docs/ai-launchpad/sap-ai-launchpad/what-is-sap-ai-launchpad?q=sap%20ai%20launchpad</A>&nbsp;</SPAN></P><P><SPAN><A href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/what-is-sap-ai-core" target="_self" rel="noopener noreferrer">https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/what-is-sap-ai-core</A>&nbsp;</SPAN></P><P>&nbsp;</P> 2024-01-28T17:45:07.242000+01:00 https://community.sap.com/t5/technology-blogs-by-sap/release-navigator-for-sap-btp-what-s-new-in-q4-2023-and-what-s-next-in-2024/ba-p/13593034 Release Navigator for SAP BTP What's New in Q4 2023 and What's Next in 2024 2024-02-05T15:50:27.237000+01:00 chriskollhed https://community.sap.com/t5/user/viewprofilepage/user-id/6181 <P><span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="1 Header.png" style="width: 906px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/61165i699F74F35AC303F5/image-size/large?v=v2&amp;px=999" role="button" title="1 Header.png" alt="1 Header.png" /></span></P><P><BR /><BR /><BR />The release navigator for SAP Business Technology Platform by SAP Enterprise Support consolidates release information across SAP BTP products and services. You can find blog posts, newsletters, videos, podcasts, webcasts, social media channels, webpages, and more helpful content created by SAP Product Management, SAP User Assistance, SAP Learning, SAP Enterprise Support, and other areas of the SAP ecosystem in this easy-to-use web interface. It’s available to all customers as part of the SAP Enterprise Support offering.<A title="Access the Release Navigator for SAP BTP Here" href="https://readiness-at-scale.enable-now.cloud.sap/pub/20230621_ras/index.html?show=book!BO_EC8330B09B97CDBE&amp;library=library.txt#slide!SL_120BDFE08096029D" target="_blank" rel="noopener nofollow noreferrer"><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Click here to Access the Release Navigator for SAP BTP.png" style="width: 271px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/59461i243BFA1566FD26F1/image-size/large?v=v2&amp;px=999" role="button" title="Click here to Access the Release Navigator for SAP BTP.png" alt="Click here to Access the Release Navigator for SAP BTP.png" /></span></A><BR /><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2 Entry.png" style="width: 906px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/59494iA35565B45DA169FB/image-size/large?v=v2&amp;px=999" role="button" title="2 Entry.png" alt="2 Entry.png" /></span><BR />You can now access the release navigator easier and with less clicks. Based on your feedback, we launched a <A href="https://support.sap.com/en/offerings-programs/enterprise-support/releaseready.html?anchorId=section_501520374" target="_blank" rel="noopener noreferrer">new page on the SAP Support Portal</A> that features a direct link to the release navigator for SAP BTP as well as to all other currently available release navigators.</P><P><A href="https://support.sap.com/en/offerings-programs/enterprise-support/releaseready.html?anchorId=section_501520374" target="_blank" rel="noopener noreferrer"><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="The new Release Ready web page on the SAP Support portal" style="width: 992px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/83296i07FFEBDA6AD461E9/image-size/large?v=v2&amp;px=999" role="button" title="20240319_ReleaseReadyPage.png" alt="The new Release Ready web page on the SAP Support portal" /><span class="lia-inline-image-caption" onclick="event.preventDefault();">The new Release Ready web page on the SAP Support portal</span></span></A></P><P>&nbsp;</P><P>&nbsp;</P><P><SPAN>How to navigate to the Release Ready page in the SAP Support Portal:</SPAN></P><P>In the <A href="https://support.sap.com/en/index.html" target="_blank" rel="noopener noreferrer">SAP Support Portal</A>, click on <STRONG>Offerings &amp; Programs</STRONG> and select <STRONG>Release Ready</STRONG>.<BR /><BR /><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="This is where you can find the Release Ready page within the SAP Support Portal" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/59501i9A02E5264BE10722/image-size/large?v=v2&amp;px=999" role="button" title="Offerings and Programs_plus indication.png" alt="This is where you can find the Release Ready page within the SAP Support Portal" /><span class="lia-inline-image-caption" onclick="event.preventDefault();">This is where you can find the Release Ready page within the SAP Support Portal</span></span></P><P>Access via the <A href="https://support.sap.com/en/offerings-programs/enterprise-support/value-maps.html#section_117923726" target="_blank" rel="noopener noreferrer">SAP Enterprise Support Value Maps</A> continues as previously. Additionally, you can now also find the release navigator within the <A href="https://support.sap.com/en/product/onboarding-resource-center/business-technology-platform.html" target="_blank" rel="noopener noreferrer">Onboarding Resource Center</A>.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3 Q4 Update.png" style="width: 906px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/59503i8681F68C2CB4A1B5/image-size/large?v=v2&amp;px=999" role="button" title="3 Q4 Update.png" alt="3 Q4 Update.png" /></span><BR />We have published a quarterly maintenance update with the Q4 release cycle. You can find updated dates and resources according to the latest releases for the products featured.</P><P>Additionally, you can get to product pages with less clicks now due to a simplified navigation on the Home page of the release navigator.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="20240306_Phase1_Homepage.png" style="width: 909px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/76668i4CF799A57E3BAEF4/image-size/large?v=v2&amp;px=999" role="button" title="20240306_Phase1_Homepage.png" alt="20240306_Phase1_Homepage.png" /></span></P><P>&nbsp;<span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="4 Translation.png" style="width: 906px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/59506iA2D3D850BFDDEF81/image-size/large?v=v2&amp;px=999" role="button" title="4 Translation.png" alt="4 Translation.png" /></span></P><P><SPAN>Did you know that the release navigator is created using SAP Enable Now, which offers a machine translation feature? You can translate all text on the navigator pages automatically to 40 languages.&nbsp;</SPAN></P><P>The translation feature is available in the authenticated version of the release navigator which<U> requires sign in with an S-user, Universal ID or internal ID.</U><BR /><BR />You can access the release navigator using a sign-in, by clicking on the tile "Translation Feature - Authenticated Version" in the section "About the Release Navigator".&nbsp;After you have signed in with one of the authorizations mentioned, you will be able to see the translation option at the top right corner of the screen.<BR /><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="20240306_Phase1_TranslationFeature_callout.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/76669i889A93B6542347FE/image-size/large?v=v2&amp;px=999" role="button" title="20240306_Phase1_TranslationFeature_callout.png" alt="20240306_Phase1_TranslationFeature_callout.png" /></span></P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="5 2024 plan.png" style="width: 906px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/60540i4AB9F836124B7C39/image-size/large?v=v2&amp;px=999" role="button" title="5 2024 plan.png" alt="5 2024 plan.png" /></span><BR />Upcoming updates for the release navigator are scheduled on a quarterly basis in alignment with the <SPAN><A href="https://me.sap.com/notes/2888562" target="_blank" rel="noopener noreferrer">Harmonized Release Calendar for SAP Cloud Products</A></SPAN>.<BR /><span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Content and UX updates to the BTP release navigator are planned for CW10, CW22, CW35 and CW48 of 2024. This schedule is subject to change without prior notice including, when necessary, delays or incorporating changes in subsequent update windows. It is not a commitment, promise, or legal obligation to deliver any material, code, or functionality." style="width: 904px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/60541iCB7102E785843F15/image-size/large?v=v2&amp;px=999" role="button" title="Innovation Plan.png" alt="Content and UX updates to the BTP release navigator are planned for CW10, CW22, CW35 and CW48 of 2024. This schedule is subject to change without prior notice including, when necessary, delays or incorporating changes in subsequent update windows. It is not a commitment, promise, or legal obligation to deliver any material, code, or functionality." /><span class="lia-inline-image-caption" onclick="event.preventDefault();">Content and UX updates to the BTP release navigator are planned for CW10, CW22, CW35 and CW48 of 2024. This schedule is subject to change without prior notice including, when necessary, delays or incorporating changes in subsequent update windows. It is not a commitment, promise, or legal obligation to deliver any material, code, or functionality.</span></span></P><P>Here’s a sneak peek at some of our Roadmap items for the release navigator:</P><P>Content Updates:</P><UL><LI>Updating resources relating to a specific quarterly release cycle</LI><LI>Integrating more products and services on dedicated product pages</LI></UL><P>UX Updates:</P><UL><LI>Continuous improvements of the UX elements for an easier navigation</LI><LI>Alignment of UX among the release navigators</LI></UL><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="6 feedback.png" style="width: 906px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/60561iF2BBDCE81E0B95F2/image-size/large?v=v2&amp;px=999" role="button" title="6 feedback.png" alt="6 feedback.png" /></span></P><P>Since launch of this tool in September 2023 we have received a great number of positive reactions and constructive feedback. Thank you and please <A title="Let us know how we can make the release navigator for SAP BTP better!" href="https://sapinsights.eu.qualtrics.com/jfe/form/SV_egtCPhgGOuO4Iwm?SolutionArea=SAPBTP" target="_blank" rel="noopener nofollow noreferrer">keep the input coming</A>, we appreciate all feedback!</P><P><A title="Let us know how we can make the release navigator for SAP BTP better" href="https://sapinsights.eu.qualtrics.com/jfe/form/SV_egtCPhgGOuO4Iwm?SolutionArea=SAPBTP" target="_blank" rel="noopener nofollow noreferrer"><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Click here to let us know how we can make the Release Navigator better.png" style="width: 271px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/60576i63952079BC42F05E/image-size/large?v=v2&amp;px=999" role="button" title="Click here to let us know how we can make the Release Navigator better.png" alt="Click here to let us know how we can make the Release Navigator better.png" /></span></A></P><P><SPAN><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="8 connect.png" style="width: 906px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/60565iE268B082DF9B86FD/image-size/large?v=v2&amp;px=999" role="button" title="8 connect.png" alt="8 connect.png" /></span></SPAN>Find all our teams blogs with the tag <A href="https://blogs.sap.com/tag/readinessscale/" target="_blank" rel="noopener noreferrer">Readiness@Scale</A> and feel free to connect here in the SAP Community or on&nbsp;<A href="https://www.linkedin.com/in/chris-kollhed-796682147/" target="_blank" rel="noopener nofollow noreferrer">LinkedIn</A>.</P><P data-unlink="true">Happy navigating!<BR /><SPAN><BR /></SPAN><EM>Readiness@Scale&nbsp;<BR /></EM><SPAN>SAP Enterprise Support</SPAN></P> 2024-02-05T15:50:27.237000+01:00 https://community.sap.com/t5/technology-blogs-by-sap/how-sap-s-generative-ai-hub-facilitates-embedded-trustworthy-and-reliable/ba-p/13596153 How SAP’s Generative AI Hub facilitates embedded, trustworthy, and reliable AI 2024-02-07T10:40:16.480000+01:00 andreas_roth https://community.sap.com/t5/user/viewprofilepage/user-id/217337 <P><SPAN>This blog&nbsp;post is part of a series that dives into various aspects of SAP’s approach to generative AI, and its technical underpinnings. Read the <A href="https://blogs.sap.com/2023/12/20/how-saps-generative-ai-architecture-redefines-business-applications/" target="_blank" rel="noopener noreferrer">first blog post of the series</A>. </SPAN></P><P><SPAN>&nbsp;<span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="andreas_roth_1-1707212909945.png" style="width: 755px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/61138i674927AB7824CA0A/image-dimensions/755x100?v=v2" width="755" height="100" role="button" title="andreas_roth_1-1707212909945.png" alt="andreas_roth_1-1707212909945.png" /></span></SPAN></P><H2 id="toc-hId-965859775"><SPAN>Introduction</SPAN></H2><P>In our <SPAN><A href="https://blogs.sap.com/2023/12/20/how-saps-generative-ai-architecture-redefines-business-applications/" target="_blank" rel="noopener noreferrer">previous blog post</A></SPAN>, we discussed how SAP's comprehensive architecture components underpin business AI. In this blog post, we delve deeper into the heart of this architecture – the generative AI hub.</P><H2 id="toc-hId-769346270"><SPAN>Why a generative AI hub</SPAN></H2><P><SPAN>The large language model (LLM) landscape has grown significantly for over a year, with the introduction of multiple models, each equipped with unique benefits and limitations. The suitability of a model often depends on the specific use case, with factors such as accuracy, latency, and operational environment playing pivotal roles. </SPAN></P><P><SPAN>At SAP, we are fortunate to have a plethora of use cases to leverage LLMs. For each, there needs to be a systematic and tool supported selection of an appropriate model from a wide range of offerings from SAP’s AI partners, such as Microsoft Azure, Google Cloud Platform (GCP), Amazon Web Services (AWS), Aleph Alpha, Anthropic, Cohere, and others, or from open source. Moreover, we must ensure versatility in application runtime, supporting a variety of models tailored to meet diverse needs. While we appreciate the innovation brought forward by LLM providers, our focus remains on avoiding over-reliance on a single provider. This approach allows us to pivot towards other LLMs that may better cater to our customers and use cases, and react to changes in the market over time.</SPAN></P><P><SPAN>Our emerging use cases share a common set of requirements. First, we prioritize establishing compliance and fostering trust in the application of LLMs. Following this, we diligently meet all commercial, metering, and billing necessities. However, our primary emphasis is on streamlining and harmonizing the incorporation of these models into our business applications. By addressing these concerns in a standardized way and following a common programming model, we are aiming to speed up the innovation process within our application development teams. </SPAN></P><P><SPAN>Grounding, which involves providing LLMs with specific and relevant information beyond their inherent knowledge, is crucial in ensuring the accuracy, quality, and relevance of the generated output. Within SAP, our extensive data assets are integral in enhancing LLM use cases with business context seamlessly and reliably, making them more effective.</SPAN></P><P><SPAN>The transformative potential of generative AI (GenAI) extends beyond just the capabilities of new models; it also lies in their accessibility to both developers and non-developers. When the excitement around ChatGPT started a year ago, we realized that SAP engineers required an uncomplicated while enterprise compliant instrument to unlock the potential of LLMs. This led to the creation of the internal SAP AI playground system, a simple service to explore different models. The result was an enthusiastic response and a flood of innovative ideas to incorporate LLMs into SAP applications. We believe that providing such central, easy access to LLMs is a key component of fostering innovation within any organization.</SPAN></P><P><SPAN>With these considerations in mind, <STRONG>SAP has decided to bring together trusted LLM access, business grounding for LLMs, and LLM exploration into a single generative AI hub</STRONG>. This hub is provided as integral part of <A href="https://discovery-center.cloud.sap/serviceCatalog/sap-ai-core?region=all" target="_blank" rel="noopener nofollow noreferrer">SAP AI Core</A> and <A href="https://discovery-center.cloud.sap/serviceCatalog/sap-ai-launchpad?region=all" target="_blank" rel="noopener nofollow noreferrer">SAP AI Launchpad</A>, central elements of our AI foundation on SAP Business Technology Platform (SAP BTP). This strategic move aims to streamline our approach to leveraging LLMs, making it more efficient and effective. While the generative AI hub addresses the requirements from SAP’s own business applications, we are aware that these requirements are shared in the wider SAP ecosystem, and thus took the decision to make the generative AI hub also available to our partners and customers.</SPAN></P><H2 id="toc-hId-572832765"><SPAN>How we realize the generative AI hub</SPAN></H2><P><SPAN>The architecture of the generative AI hub looks as follows:</SPAN></P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="andreas_roth_0-1707212798191.png" style="width: 760px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/61137iFE16B0936EF53E20/image-dimensions/760x323?v=v2" width="760" height="323" role="button" title="andreas_roth_0-1707212798191.png" alt="andreas_roth_0-1707212798191.png" /></span></P><P><EM>Figure 1: Architecture of generative AI hub</EM></P><P><SPAN>The primary purpose of the generative AI hub is to combine the best of LLMs with the best of SAP processes and data. To achieve this, first it needs to be easy to integrate LLMs of a wide range of provider types into SAP’s business applications. </SPAN></P><P><SPAN>Let us go step by step through the components of generative AI hub. </SPAN></P><H3 id="toc-hId-505401979"><SPAN>Access</SPAN></H3><P><SPAN>In generative AI Hub, we build on SAP AI Core, an SAP BTP service used by all SAP applications and services. SAP AI Core is not only providing capabilities to run AI workloads, but also efficient in proxying access to models that are operated as a service by providers. This is enabling us to maintain consistent access and lifecycle, and reuse much of SAP AI Core’s security and metering implementation. </SPAN></P><P><SPAN>For models that we operate independently, we depend on SAP AI Core’s features to cost-effectively run AI models on a large scale. To achieve this, we employ a Kubernetes-based structure with specific features suited to AI, such as GPU support. </SPAN></P><P><SPAN>What do applications need to do to integrate an LLM via Generative AI Hub into their application? Conceptually there are three major steps involved.</SPAN></P><P><SPAN>In the first step, users must acquire a service instance of SAP AI Core using the SAP BTP Cockpit. </SPAN></P><P><SPAN>In the second step, the goal is to create a <EM>deployment </EM>programmatically or via the SAP AI Launchpad, to instantiate a use case specific LLM configuration. It references a model provider specific executable, e.g., models provided via the Azure OpenAI service are bundled together in one. Further parameters like model name, model version, etc. can be configured as well. For each deployment, SAP AI Core provides a unique URL that can be used to access the LLM.</SPAN></P><P><SPAN>In the final step, the deployment URL can be embedded within an application. It is possible to use this URL as if interacting directly with the native LLM provider API, e.g. through an LLM provider specific SDK. We have intended for this to be the case for a good reason: we acknowledge that various LLMs may have unique features, which we want our use case providers to make use of. However, to ease the migration from one provider to the other, we are also planning to provide an abstract API that works uniformly across all providers, despite any provider-specific features that may be missing.</SPAN></P><P><SPAN>These steps are described in detail in <A href="https://developers.sap.com/tutorials/ai-core-generative-ai.html" target="_blank" rel="noopener noreferrer">this dedicated tutorial</A>.</SPAN></P><H3 id="toc-hId-308888474"><SPAN>Trust</SPAN></H3><P><SPAN>On the service-level, generative AI hub adheres to the highest industry standards by integrating SAP BTP's security functions, including Identity and Access Management, multi-tenancy, audit log service, TLS management, asset management, and CAM. Along with all other SAP products, it strictly adheres to a secure development and operations lifecycle, comprising among others threat modeling, static and dynamic code scans, open-source risk assessment, penetration testing, and periodic scans of cloud infrastructure. Operational security best practices are enforced, including access control, audit logging, multi-tenancy, and network layer security.&nbsp;<SPAN class="">These security procedures and their operations undergo reviews by internal governance procedures e.g. internal audits and the NIST CSF framework, as well as external audits in accordance with ISO27001, SOC1, SOC2 and C5 requirements.</SPAN></SPAN></P><P><SPAN>In addition, the generative AI hub also addresses the need for additional trust capabilities for GenAI use cases, primarily content moderation capabilities. The hub will check prompts and LLM responses for policy violations, and we aim to soon support optional de-identification and re-identification of personal data. </SPAN></P><P><SPAN>All our GenAI use cases need to support consumption-based pricing following our commercial model for AI. The generative AI hub plays a pivotal role in reliable usage metering, automatically reporting and aggregating consumed tokens based on tenants and the relevant business context.</SPAN></P><P><SPAN>Trust needs to extend beyond just the technical aspects. We have a legal and commercial framework in place, including a set of policies, procedures, and agreements that govern how we conduct business, interact with our selected AI partners, and comply with laws and regulations. Therefore, from input to outcome, trust is integral in all operations, not just in the technology we use but also in its management, customer engagement, and legal compliance.</SPAN></P><H3 id="toc-hId-112374969"><SPAN>Orchestration and Grounding</SPAN></H3><P><SPAN>LLMs very often incorporate contextual data using patterns such as Retrieval Augmented Generation (RAG) and other in-context learning methods, to achieve higher accuracy and include up-to-date information. This process is supported by common libraries to access data sources and orchestrate LLMs; one of the most notable examples is <A href="https://www.langchain.com/" target="_blank" rel="noopener nofollow noreferrer">LangChain</A>. The generative AI hub is designed to work seamlessly with LangChain and similar libraries. </SPAN></P><P><SPAN>Consider an application that would like to utilize a database of documents (e.g. emails) as contextual information (e.g. in order to utilize historic email responses). To realize this, we need to setup LLM deployments in generative AI hub (see above) for an embedding model as well as a completion model. Further we setup a vector database and store embeddings calculated by the embedding model of our documents. As outlined in the previous post, our SAP HANA database will soon provide such vector store capabilities, although in some use cases certain SAP BTP services, such as <A href="https://discovery-center.cloud.sap/serviceCatalog/postgresql-hyperscaler-option?region=all" target="_blank" rel="noopener nofollow noreferrer">PostgreSQL</A>, might already be a good enough option. With the help of LangChain we can now orchestrate a retrieval step by embedding a query through generative AI hub, using the vector database to retrieve the most similar matches, and finally generate a response to the query via generative AI hub.</SPAN></P><P><SPAN>While generative AI hub embraces LangChain, to optimize the development process, the service will support an orchestrated completion mechanism. It will enable users to define an orchestration configuration, which outlines the specific orchestration procedure (such as RAG), types of grounding data sources (such as a designated vector database), actual data source destination (detailing how to connect to a vector store), etc. In doing so, this mechanism provides a customizable and efficient solution for developers working with LLMs.</SPAN></P><P><SPAN>For an example around generating email insights with generative AI hub and LangChain have a look into this <A href="https://github.com/SAP-samples/btp-cap-genai-rag" target="_blank" rel="noopener nofollow noreferrer">sample project</A>.</SPAN></P><H3 id="toc-hId--84138536"><SPAN>Tooling</SPAN></H3><P><SPAN>As a further generative AI hub capability, there is a professional prompt engineering experience that we integrate into our SAP AI Launchpad. SAP AI Launchpad is designed from the outset to be a one-stop shop for all AI-related activities, providing a modular architecture that is extendable with further tools, sitting on top of the AI API offered by SAP AI Core. Thus SAP AI Launchpad is the natural place to add prompt engineering capabilities that simplify getting started with GenAI, such as storing and versioning prompts, comparing different variants with different LLMs. The screenshot below shows the prompt editor next to the other AI and GenAI related capabilities of SAP AI Launchpad.</SPAN></P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="andreas_roth_2-1707213027444.png" style="width: 745px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/61140i44BEA4FDA0DC6E36/image-dimensions/745x419?v=v2" width="745" height="419" role="button" title="andreas_roth_2-1707213027444.png" alt="andreas_roth_2-1707213027444.png" /></span></P><P><EM>Figure 2: Prompt Engineering with generative AI hub</EM></P><P><SPAN>We also see significant potential in making SAP AI Launchpad a place where the productization of LLM-centric applications begins, and continuous monitoring of prompt performance takes place. </SPAN></P><P><SPAN>UI based tooling is of course just one part of the story, we also provide more developer focused tooling. In this direction,</SPAN><SPAN>&nbsp;our <A href="https://pypi.org/project/generative-ai-hub-sdk/" target="_self" rel="nofollow noopener noreferrer">generative AI hub SDK</A>&nbsp;and our&nbsp;<A href="https://pypi.org/project/ai-core-sdk/" target="_blank" rel="noopener nofollow noreferrer">SAP AI Core SDK</A>&nbsp;are already available.&nbsp;</SPAN></P><H2 id="toc-hId--409734760"><SPAN>Conclusion</SPAN></H2><P><SPAN>Our technical architecture at SAP for GenAI revolves around the generative AI hub, which centrally addresses common concerns of our business applications and that we plan to gradually open up to the entire SAP ecosystem. This technical architecture is only one part of a successful GenAI narrative. Our next blog post will introduce how we perform benchmarking of LLMs, which is a crucial part of our journey towards relevant, reliable and responsible business AI powered by GenAI technology.</SPAN></P><P><SPAN><SPAN class=""><I>Co-authored by Dr. Andreas Roth and <A href="https://community.sap.com/t5/user/viewprofilepage/user-id/195453" target="_self">Dr. Philipp Herzig</A></I></SPAN></SPAN></P> 2024-02-07T10:40:16.480000+01:00 https://community.sap.com/t5/artificial-intelligence-and-machine-learning-blogs/navigating-the-ai-landscape-a-ux-designer-s-guide/ba-p/13582520 Navigating the AI Landscape: A UX Designer's Guide 2024-02-14T11:01:22.387000+01:00 ArshAshok https://community.sap.com/t5/user/viewprofilepage/user-id/176073 <P><STRONG>Introduction</STRONG></P><P>As we stand on the brink of a technological revolution, AI is reshaping the way we interact with the digital world. I'm here to&nbsp;share my insights&nbsp;regarding this evolving landscape, offering observations into how AI, machine learning, and other related technologies can enhance our work in UX design.</P><P><STRONG>Brief Overview of AI and ML</STRONG></P><P>Artificial Intelligence (AI) is the overarching concept of machines carrying out tasks in ways that we consider 'smart'. It's a broad discipline aimed at creating systems that can simulate various aspects of human intelligence. Machine Learning (ML) is a subset of AI, focused on algorithms that enable machines to improve at tasks with experience. Think of AI as the universe of intelligent computation, with ML being a planet within it.</P><P>Deep Learning, in turn, is a subset of ML. It involves neural networks with many layers (hence 'deep') that can learn and make intelligent decisions on their own. Deep Learning has been instrumental in achieving significant breakthroughs in areas like image and speech recognition.</P><P>Then come Foundation Models, a recent development in AI. These are large-scale models (like GPT-3) that are trained on vast amounts of data and can be adapted to a wide range of tasks without being specifically trained for them. They are called 'foundations' because they provide a base layer of understanding that can be built upon for various applications.</P><P>These technologies are interrelated, forming a hierarchy from broad to specific. AI encompasses everything intelligent that a machine might do. Under AI, ML is the method through which machines learn from data. Deep Learning is a further specialization of ML with a focus on complex, layered neural networks. And Foundation Models are the cutting-edge, versatile systems pushing the boundaries of what AI can achieve.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Arsh_0-1706283040223.png" style="width: 504px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/53132i7653F341B368869E/image-dimensions/504x254?v=v2" width="504" height="254" role="button" title="Arsh_0-1706283040223.png" alt="Arsh_0-1706283040223.png" /></span></P><P><STRONG>Generative Pretrained Transformer (GPT) and Transformer Architecture</STRONG></P><P>GPT, or Generative Pretrained Transformer, is a type of language processing AI. It's built on the Transformer architecture, which is revolutionary in the way it handles data. Traditional models processed data sequentially, one piece after another. The Transformer, however, allows for parallel processing, looking at entire sequences of data at once. This is done through mechanisms called 'attention' and 'self-attention,' letting the model weigh the importance of different parts of the input data and learn the context more effectively.</P><P>GPT takes this architecture and applies it to language, learning to predict the next word in a sentence. It's trained on a vast corpus of text and then fine-tuned for specific tasks. This pretraining is what makes it 'generative' - it can generate text, not just understand or classify it.</P><P><STRONG>Inception of Generative AI</STRONG></P><P>Generative AI came into existence as a natural progression from earlier AI models that were primarily discriminative. While discriminative models could classify and understand data, they couldn't create new data. The inception of Generative AI marked a shift from understanding to creation.</P><P>This shift was fueled by advancements in neural networks and an exponential increase in computational power and data availability. Researchers began exploring how neural networks could not only recognize patterns but also use those patterns to generate new, similar data. This exploration led to the development of models like Generative Adversarial Networks (GANs) and Variational Autoencoders (VAEs), and eventually to large-scale models like GPT.</P><P><STRONG>Integrating Reinforcement Learning with Human Feedback</STRONG></P><P>Adding to this is the concept of Reinforcement Learning with Human Feedback (RLHF). This approach trains AI systems not just on static datasets but on dynamic feedback loops. It’s akin to teaching a pet new tricks: the AI tries different strategies and, based on human feedback, learns which actions are desirable or undesirable. This human-in-the-loop methodology ensures that the AI’s learning trajectory aligns more closely with human values and preferences, making it particularly potent for personalization and adaptive learning scenarios.</P><P>Incorporating RLHF into the design of AI systems compels us to consider not just the initial user interaction but the ongoing relationship between the user and the AI as they adapt and learn from each other over time.</P><P><STRONG>Various Approaches to AI</STRONG></P><P>Understanding the various approaches to AI can be daunting, but it's crucial for harnessing its full potential:</P><UL><LI><STRONG>Symbolic AI</STRONG>: Based on the manipulation of symbols and rules, this approach tries to mimic human reasoning.</LI><LI><STRONG>Probabilistic AI</STRONG>: Focuses on using probabilities to make predictions and decisions.</LI><LI><STRONG>Statistical AI</STRONG>: Uses statistical methods to infer patterns and make predictions.</LI><LI><STRONG>Large Language Models (LLMs)</STRONG>: These are trained on vast datasets to understand and generate human-like text.</LI></UL><P>Each approach has its strengths, and knowing which to apply can significantly impact the success of a project.</P><P><STRONG>How Are Models Trained?</STRONG></P><P>AI models are trained using large datasets. They learn by recognising patterns and making associations. For instance, an image recognition model might learn to identify cats by being shown thousands of pictures of cats and not-cats. Over time, it improves its accuracy through a process called backpropagation, where it adjusts its internal parameters to minimize errors.</P><P><STRONG>AI and Design</STRONG></P><P>In the realm of AI, as designers, we're tasked with shaping a human-machine relationship that is continually evolving. Unlike traditional design, where interactions are fixed, AI-based design involves a fluid, ever-changing dynamic. Non-AI systems interact in a consistent, unchanging manner. However, AI systems learn and adapt over time, leading to a constantly developing relationship.</P><P>As both the machine and humans learn and adapt, they engage in a reciprocal learning process, forming a dynamic feedback loop. This loop is characterized by an ongoing exchange of information, with both parties growing and adjusting to the interaction. Our role as AI designers is to foster effective communication within this vibrant human-machine relationship.</P><P>In this context, data becomes the pivotal element. Previously, data interaction was straightforward — a user command followed by a machine response. With AI, data is the foundation of learned behaviours, informing the machine and shaping its growth. Here, data inputs are about educating the machine with information, not just instructing it. Conversely, machine outputs are no longer fixed; they have generated responses that necessitate explanations of how the data led to a particular conclusion.</P><P>As designers, we are charged with orchestrating these interactions throughout the entire data lifecycle. This includes the initial data capture, guiding the machine's learning process, designing clear and understandable data outputs, and ensuring a seamless flow of information back into the system for continued learning. Our responsibility extends beyond creating interfaces; it's about crafting experiences that support this rich, ongoing dialogue between humans and AI, ensuring clarity, transparency, and a mutual growth trajectory.</P><P>A comparison can be drawn from the days when selecting a movie at a DVD store involved browsing aisles for a favoured title or relying on a recommendation from a salesperson. In contrast, platforms like Netflix now curate suggestions tailored to our tastes, informed by our viewing history.</P><P><STRONG>Designers find themselves at the intersection of innovation, with three distinct yet interconnected realms to explore:</STRONG></P><P><STRONG>1. Designing with AI: Crafting Alongside AI</STRONG></P><P>Designers are now partnering with AI in a collaborative dance of creation, where the output is a fusion of human ingenuity and machine efficiency. Imagine the synergy of a designer working with AI to conjure up ground-breaking architectural structures, much like Autodesk's venture in utilizing generative design principles to conceive their Toronto office. Here, AI becomes an ally in the creative process, providing new perspectives and solutions that push the boundaries of traditional design.</P><P>Moreover, designers harness AI to streamline repetitive tasks, freeing up creative energy for more complex challenges. Tools like Airbnb's system for transforming sketches into digital wireframes or Netflix's algorithm for adapting graphics across different cultures exemplify this trend. These innovations signify a new era where AI does not replace the designer but rather amplifies their capabilities.</P><P><STRONG>2. Designing for AI: The Human-Centric Design Approach</STRONG></P><P>Designing for AI requires a human-centred lens, focusing on crafting systems that prioritize user needs and experiences. It's about spotting those unique opportunities where AI can not only function but flourish in addressing real-world problems. Here, the designer's role transcends aesthetics, venturing into the realm of functionality and utility, transforming user needs into data-driven AI solutions.</P><P>Human-centered design makes AI effective. These are some ways:</P><P style=" padding-left : 60px; "><STRONG>1. </STRONG><STRONG>Beyond Interfaces: Embracing Human-Centered Design in AI Algorithm Development</STRONG></P><P style=" padding-left : 60px; ">UX can aid in designing algorithms that mirror the decision-making processes humans employ, by considering their information, goals, and constraints. It can ensure that the decision environment, which encompasses both the algorithm and its human users should be thoughtfully constructed. Users should comprehend their AI tools well enough to use them effectively. Designers also aid in establishing guidelines and business protocols that translate algorithmic predictions into actionable insights, advising when human intervention is appropriate to supplement or override the AI.</P><P style=" padding-left : 60px; "><STRONG>2. To Translate User Needs into Data Requirements:</STRONG> &nbsp;A designer can aid in identifying the type of data necessary for training the model, considering various factors like predictive power (<EM>A percentage that refers to an ML model’s ability to predict outcomes given a certain input correctly</EM>), relevance, fairness, privacy, and security. Ensure the training dataset is comprehensive, reflecting the real-world scenarios the AI will encounter, and free from biases.</P><P style=" padding-left : 60px; "><STRONG>3. Knowing the source of the data &amp; Tuning the Model:</STRONG> Evaluating data sourcing and collection methods for their suitability of the project is critical. Once deployed, A designer will assess if the AI meets the target user’s needs as per predefined success metrics. Provide feedback on adjusting the model’s parameters as needed to enhance its performance, focusing on metrics that reflect user experience, such as customer satisfaction or the frequency of users following the AI’s recommendations.</P><P style=" padding-left : 60px; "><STRONG>4. Addressing Bias, Fairness, and Transparency</STRONG>: UX designers can help analyze data with an understanding of the domain, Goal definition, possible and required outcomes and the process that generated it. This leads to designers being a crucial part of designing algorithms that are mindful of the environment they will operate in, avoiding controversial predictors. They aid in conducting usability tests or audits to detect and eliminate unintended biases.</P><P style=" padding-left : 60px; "><STRONG>5. Managing the Handoff in AI Systems:</STRONG> Designing for smooth transitions between AI and human control in situations demanding common sense or contextual understanding is very important. The accountability for any action in the real world still lies with human users as over-reliance on technology can leave users unprepared for instances where AI fails, necessitating more skilled human intervention. A UX designer can analyse such situations and will aid in designing smooth handoff processes.</P><P style=" padding-left : 60px; "><STRONG>6. Designing Reward Functions</STRONG> <STRONG>and leveraging User Feedback for Model Improvement:</STRONG> Designing the AI’s reward function is critical as it influences the user experience significantly. User feedback is essential in refining AI models and enhancing user experience. Designers analyse and optimize the reward data to enhance the model for long-term user benefits and anticipate the downstream effects of your product. This also allows users to contribute to the personalization of their experiences, thereby increasing their trust in the system.</P><P style=" padding-left : 60px; "><STRONG>7. Anticipating Errors and Designing Response Pathways:</STRONG> A Human-centred design prepares your AI system to facilitate user responses to inevitable errors, turning them into opportunities for learning and improvement.</P><P style=" padding-left : 60px; "><STRONG>8. Educating Users and Setting Realistic Expectations</STRONG>: Designers help communicate the capabilities and limitations of your AI product to customers. Help users develop accurate mental models and understand how their interactions train the system. It’s essential to balance user trust, avoiding both undue scepticism and over-reliance on AI.</P><P style=" padding-left : 60px; "><STRONG>9. Guiding User Trust in AI Systems: Users need to adjust</STRONG> their trust in AI systems appropriately, rather than relying on them implicitly in every situation. The phenomenon of 'algorithm aversion' is well-documented, where users may be sceptical of software systems. Conversely, there are instances where users place excessive trust in AI capabilities, expecting more than what the system can deliver. Designers help users develop a balanced level of trust, aligning with the system's actual capabilities and limitations by taking a human-centred approach.</P><P>For instance, openly acknowledging the potential inaccuracies in AI predictions can temporarily reduce trust in those specific outcomes. However, this honesty can foster a more sustainable trust in the long term. Users become more judicious in their reliance on the system, reducing the likelihood of disappointment due to misplaced expectations."</P><P><STRONG>3. Designing of AI: The User Experience Frontier</STRONG></P><P>When it comes to the design of AI, it's about envisioning and sculpting the interactions between AI systems and their human users. It's a space where new forms of engagement, like voice-activated assistants or image recognition software, become gateways to enhanced user experiences. The key challenge here is transparency: designing interfaces that not only serve but also educate. Users should be able to grasp, with just the right level of detail, how AI systems make decisions and learn over time.</P><P>An example could be the intuitive dashboards in our cars that provide real-time insights into the vehicle's AI, or the smart home devices that learn our preferences and conversationally explain their actions. These are no longer scenarios from a sci-fi novel; they are today's design challenges that call for a blend of technical knowledge, user empathy, and creative foresight.</P><P>In essence, the designer's canvas has expanded, not just in size but in dimensionality. As AI continues to intertwine with our daily lives, it invites designers to step into roles that are as diverse as they are dynamic, shaping not only how AI looks but also how it behaves and interacts in the fabric of human experience.</P><P><STRONG>Understanding the Limitations of AI in UX Design</STRONG></P><P>Incorporating AI into UX design comes with distinct limitations that underscore the irreplaceable value of human insight and direction.</P><P><STRONG>1. Hallucinations and Reliability</STRONG></P><P>AI "hallucinations" refer to instances where a model confidently generates an incorrect response. These can be caused by inconsistencies within a large data set or errors in the model's training methodology. In fields where precision is critical, such as financial reporting or legal documentation, these inaccuracies can introduce significant risks. Combatting this requires robust document structuring and advanced prompt design techniques to direct AI towards more dependable outcomes.</P><P><STRONG>2. Prompt Sensitivity </STRONG></P><P><STRONG>&nbsp;</STRONG>Large Language Models (LLMs) are highly sensitive to user input. The nuances of how a prompt is phrased can lead to varied and unpredictable responses. This sensitivity necessitates a careful and strategic approach to prompt engineering, ensuring that the AI's responses align with user intentions. The evolving role of "Prompt Engineer" is a testament to the significance of crafting prompts that steer AI toward delivering consistent and accurate results.</P><P><STRONG>3. Context Window</STRONG></P><P>Limits The context window, the amount of information an AI can consider when generating a response, is a notable constraint. As the context window expands, so does the computational complexity. Despite improvements like GPT-4's extended context window, there remains a ceiling to the volume of data an AI can process at a time. This limitation is particularly challenging in tasks that require the review of extensive documents, where the AI must understand and analyze large quantities of text. Designing for AI in UX thus requires a thoughtful balance between the AI's capabilities and the complexity of the tasks it is expected to perform<STRONG>.</STRONG></P><P><STRONG>Things Designers Should Know Before Designing for AI</STRONG></P><P><STRONG>Technical Knowledge</STRONG></P><UL><LI>Grasping the basics of data science and AI techniques like NLP and deep learning.</LI><LI>Basic Understanding of the AI toolchain and DevOps processes for AI development.</LI><LI>Access to clean data set.</LI></UL><P><STRONG>Ethics in AI</STRONG></P><UL><LI>Integrate ethical standards into the design and development process, ensuring accountability, fairness, and transparency.</LI><LI>Navigate GDPR/compliance mandates and be mindful of the financial and human impacts of design decisions.</LI></UL><P><STRONG>Collaboration is Key: </STRONG></P><UL><LI>Work closely with data scientists and engineers to understand the technical aspects and constraints.</LI><LI>Foster a shared vision across multidisciplinary teams and participate actively in the AI development lifecycle.</LI><LI>Engage in design thinking activities tailored to AI and address the needs of diverse users.</LI></UL><P><STRONG>AI Strategy</STRONG></P><UL><LI>Develop and communicate a user-focused AI strategy, explaining barriers to adoption and the business and user benefits.</LI><LI>Articulate your company's AI strategy, differentiators, and the journey toward AI success.</LI></UL><P><STRONG>Designing AI Interactions</STRONG></P><UL><LI>Translate AI model outputs into understandable insights for users and design interactions that capture human input for machine learning.</LI><LI>Prototype and test AI solutions frequently, and design for various stages of the AI lifecycle, such as model maintenance and data collection methods.</LI></UL><P><STRONG>User Trust and Transparency</STRONG></P><UL><LI>Build trust by making your AI interactions transparent and understandable.</LI></UL><P>In conclusion, AI is not just a tool but a new frontier in design. By embracing it, we can create more personalized, efficient, and engaging user experiences. Let's embark on this journey together, continuously learning and adapting to ensure technology serves humanity in the most beneficial ways.</P><P>&nbsp;</P><P>Resources to Refer :</P><OL><LI>Generative AI at SAP: <A href="https://open.sap.com/courses/genai1" target="_blank" rel="noopener noreferrer">https://open.sap.com/courses/genai1</A></LI><LI>AI Ethics at SAP: <A href="https://open.sap.com/courses/aie1-1" target="_blank" rel="noopener noreferrer">https://open.sap.com/courses/aie1-1</A></LI><LI>Designing for Generative AI: <A href="https://experience.sap.com/internal/fiori-design-web/generative-ai-design/" target="_blank" rel="noopener noreferrer">https://experience.sap.com/internal/fiori-design-web/generative-ai-design/</A></LI><LI>Designing for Intelligent Systems: <A href="https://experience.sap.com/internal/fiori-design-web/designing-intelligent-systems/" target="_blank" rel="noopener noreferrer">https://experience.sap.com/internal/fiori-design-web/designing-intelligent-systems/</A></LI><LI>SAP AI community file: <A href="https://www.figma.com/file/SJh2Eb5KrBIbaK3Bo2wqtq/AI-UX-Pattern-Community-Explorations?type=design&amp;node-id=737-200772&amp;mode=design" target="_blank" rel="noopener nofollow noreferrer">https://www.figma.com/file/SJh2Eb5KrBIbaK3Bo2wqtq/AI-UX-Pattern-Community-Explorations?type=design&amp;node-id=737-200772&amp;mode=design</A></LI><LI><A href="https://teams.microsoft.com/l/channel/19%3a3beb9faf0d144622a649e4eddb97d152%40thread.tacv2/AI%2520Design%2520Guidelines%2520and%2520Patterns%2520Community?groupId=ead6a857-cde8-4c1c-abc4-cbd2751ae3a9&amp;tenantId=42f7676c-f455-423c-82f6-dc2d99791af7" target="_blank" rel="noopener nofollow noreferrer">AI Design Community Teams Channel</A></LI><LI><A href="https://www.figma.com/file/SJh2Eb5KrBIbaK3Bo2wqtq/AI-UX-Pattern-Community-Explorations?type=design&amp;node-id=737-200772&amp;mode=design" target="_blank" rel="noopener nofollow noreferrer">AI Design Community Exploration File</A>&nbsp;</LI><LI><A href="https://www.figma.com/file/Nf6HYsfOJGMH8jEl0QbuRh/AI-Prompting-Community-Feedback?type=whiteboard&amp;node-id=0%3A1&amp;t=NSDrZCXJS2kZf6iB-1" target="_blank" rel="noopener nofollow noreferrer">Prompt Pattern Presentation Figjam</A></LI></OL><P>&nbsp;</P> 2024-02-14T11:01:22.387000+01:00 https://community.sap.com/t5/technology-blogs-by-sap/sap-business-ai-infuse-ai-in-applications-using-sap-btp-with-some-use-cases/ba-p/13600062 SAP Business AI : Infuse AI in applications using SAP BTP (with some Use Cases) 2024-02-18T04:43:44.423000+01:00 VinayBhatt https://community.sap.com/t5/user/viewprofilepage/user-id/162013 <P><FONT size="6"><STRONG>Introduction</STRONG></FONT></P><P class="">The primary focus of this article is to lucidly present a broad classification of <STRONG>SAP Business AI</STRONG>, followed by an in-depth explanation on how to infuse AI into applications using <STRONG>SAP Business Technology Platform (BTP)</STRONG>. The spotlight will be on the AI/ML services within SAP BTP.</P><P class="">The article features some <STRONG>use cases drawn from my own projects</STRONG>. These examples are intended to illustrate the practical application of various technologies within SAP BTP, showing how they can be synergistically utilized to create end-to-end applications that are <STRONG>infused with AI</STRONG>.</P><P><STRONG>Agenda</STRONG></P><OL><LI><STRONG>Broad classification of SAP Business AI</STRONG> &amp; Introduction to various Services.</LI><LI><STRONG>SAP BTP AI :&nbsp;</STRONG><SPAN>AI services &amp; solutions in SAP BTP to build applications infused with AI.</SPAN></LI><LI><STRONG>Example Use Cases</STRONG><SPAN>&nbsp;</SPAN><UL><LI><STRONG>Semantic Search App &amp; RAG (Retrieval Augmented Generation example).&nbsp;</STRONG></LI><LI><STRONG>Zero shot classification with LLM's</STRONG></LI><LI><STRONG>AI Quiz App using LLM's</STRONG></LI></UL></LI></OL><P><FONT size="6"><STRONG>Broad classification of SAP Business AI&nbsp;</STRONG></FONT></P><P><SPAN><STRONG>SAP Business AI</STRONG>&nbsp;can be broadly classified into following categories :&nbsp;</SPAN></P><UL><LI><SPAN>&nbsp;<STRONG>Embedded AI&nbsp;</STRONG>: AI Integrated into <STRONG>business processes</STRONG> and solutions. SAP business AI includes AI solutions &amp; features infused in S4HANA (Finance , Sales &amp; Service), ARIBA( procurement), SAP Digital Assistant for Cx ( marketing &amp; commerce) , SAP Success Factors(HR), SAP Transport Management (Supply Chain), SAP Extended Warehouse Management (Supply Chain) and Cross Functional use cases with "Just Ask" at SAP Analytics cloud and many more.</SPAN></LI><LI><SPAN>&nbsp;<STRONG>SAP BTP AI :&nbsp;</STRONG>Build <STRONG>custom AI solutions</STRONG> and integrate them to your SAP landscape. BTP AI solutions&nbsp;Infuse artificial intelligence into your apps with scalability and responsibility in mind by&nbsp;enabling consumption of ready-to-use AI Models , training &amp; deployment of custom AI models, using Enterprise Process Automation, SAP's Foundation Models, AI through SAP Partnerships : IBM Watson, Google Cloud, Data Robot, Microsoft OpenAI etc.&nbsp;</SPAN>SAP combines the power of<SPAN>&nbsp;</SPAN><SPAN>generative AI with the context of business data and business processes</SPAN><SPAN>&nbsp;</SPAN><SPAN>and applies fine-tuning and prompt engineering at scale.&nbsp;</SPAN></LI><LI><STRONG><SPAN>SAP AI Services :&nbsp;</SPAN></STRONG><SPAN><STRONG>Models Pretrained</STRONG> on Business Data, access pretrained AI capabilities e.g. Document information extraction, Personalized recommendation and Data attribute recommendation.&nbsp; &nbsp;&nbsp;</SPAN><SPAN>&nbsp; &nbsp; &nbsp;</SPAN></LI><LI><STRONG><SPAN>Ecosystem AI :&nbsp;</SPAN></STRONG><SPAN>Procure <STRONG>best-of-breed</STRONG> AI solutions from SAP's ecosystem.&nbsp;</SPAN></LI></UL><P><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="VinayBhatt_0-1708062648875.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/66337i730DAA176FC58DA3/image-size/large?v=v2&amp;px=999" role="button" title="VinayBhatt_0-1708062648875.png" alt="VinayBhatt_0-1708062648875.png" /></span></P><P><STRONG><FONT size="5">SAP BTP AI</FONT></STRONG></P><P><FONT size="4">We will now focus on SAP BTP AI foundational platform &amp; services. Let's look at the foundational platform and services available to customers &amp; partners today to infuse AI into applications.</FONT></P><P><STRONG><FONT size="5">SAP AI Services</FONT></STRONG></P><P style=" text-align : justify; ">Access <STRONG>Pretrained models</STRONG> as APIs for Document Information Extraction (Dox), Personalized Recommendation services, Data Attribute recommendations &amp; Machine translation services etc. These pretrained models from SAP are trained on <STRONG>Business data</STRONG> and can be infused in BTP Applications to perform task like <STRONG>extracting Text from Images</STRONG> using OCR, <STRONG>retrieving master data from Invoices</STRONG> (e.g. pdf etc) or building custom recommendation services or machine translation services.</P><P style=" text-align : justify; "><STRONG>How can this help partners and customers to build AI applications ?</STRONG></P><P style=" text-align : justify; ">Partners and customers can consume SAP AI services API for DoX &amp; recommendation services etc in custom BTP apps ( No code/ Low code apps plus Pro code apps) &nbsp;, to create side by side AI applications or extentions to existing exterprise applications.</P><P style=" text-align : justify; ">Document Information Extraction <STRONG><A href="https://youtu.be/Ojg447dM66E" target="_blank" rel="noopener nofollow noreferrer">Video</A></STRONG></P><P style=" text-align : justify; "><A href="https://help.sap.com/docs/document-information-extraction" target="_blank" rel="noopener noreferrer">Documentation</A></P><P style=" text-align : justify; ">&nbsp;</P><P style=" text-align : justify; "><FONT size="5"><STRONG>SAP</STRONG> <STRONG>BTP</STRONG> <STRONG>Generative AI hub</STRONG>&nbsp;</FONT></P><P>&nbsp;SAP BTP Generative AI hub is available on <STRONG>SAP AI Launchpad/ SAP AI Core on BTP</STRONG> and provides a central place for accessing <STRONG>Large Language models</STRONG>&nbsp;from different providers <SPAN>such as GPT-4 by Azure OpenAI or OpenSource Falcon-40b</SPAN> .</P><P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<STRONG>How can this help partners and customers to build AI applications ? </STRONG></P><OL><OL><LI>The generative AI hub provides tooling for prompt engineering, experimentation, and other capabilities to accelerate the development of BTP applications infused with generative AI, in a secure and trusted way.</LI><LI>Partners and customers can <STRONG>build AI Applications</STRONG> on BTP using the Gen AI hub based access to LLM models as an API from SAP AI Core – <A href="https://discovery-center.cloud.sap/refArchDetail/ref-arch-open-ai" target="_blank" rel="noopener nofollow noreferrer">Reference Architecture</A></LI></OL></OL><P>&nbsp; &nbsp; &nbsp;&nbsp;<A href="https://community.sap.com/t5/technology-blogs-by-sap/generative-ai-hub-out-now/ba-p/13580462" target="_blank">Generative AI Hub – Out now!</A>&nbsp;: Includes a Demo of Gen AI Hub.</P><P>&nbsp;</P><P><FONT size="5"><STRONG>SAP HANA Cloud</STRONG> <STRONG>Vector Engine</STRONG></FONT>&nbsp;(GA)</P><P>The world of Gen AI / LLM’s has lot of mention on <STRONG>vector data </STRONG><SPAN>(embeddings) , which is simply put numerical representation of text, voice, Image data etc. With this vector representation of text, voice &amp; images, use cases like similarity search or contextual search or </SPAN><STRONG>Retrieval Augment Generation (RAG)</STRONG><SPAN>&nbsp;are prevalent, wherein similar documents matching a user query are pulled from a vector data store , before being fed to a LLM for a contextual response.</SPAN></P><P>Such application development can now happen in BTP for enterprise applications using the Reference architecture above which includes Gen AI Hub, HANA Vector Engine etc.</P><P><STRONG><A href="https://dam.sap.com/mac/app/p/video/asset/preview/Mfbuu9K?ltr=a&amp;rc=10" target="_blank" rel="noopener noreferrer">Video&nbsp; Vector Engine</A></STRONG></P><P>Below is a 2D representation of embeddings generated on simple text like dog, cat, kitten, man,woman and SAP BTP etc. Words similar in meaning are clustered together.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="VinayBhatt_0-1708173607147.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/66904iC56FF10DD11E61BD/image-size/large?v=v2&amp;px=999" role="button" title="VinayBhatt_0-1708173607147.png" alt="VinayBhatt_0-1708173607147.png" /></span></P><P>&nbsp;</P><P><A href="https://colab.research.google.com/drive/1pSD9exLbLaKOglUG-FrrVA_gfpJtL6R_?usp=sharing" target="_self" rel="nofollow noopener noreferrer"><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VinayBhatt_0-1708174348894.png" style="width: 200px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/66905i5EE65D949B2687FA/image-size/small?v=v2&amp;px=200" role="button" title="VinayBhatt_0-1708174348894.png" alt="VinayBhatt_0-1708174348894.png" /></span></A></P><P>I have created a&nbsp;<A href="https://colab.research.google.com/drive/1pSD9exLbLaKOglUG-FrrVA_gfpJtL6R_?usp=sharing" target="_self" rel="nofollow noopener noreferrer">Google colab</A> notebook for basic understanding of these NLP terms including :&nbsp;</P><UL><LI><STRONG>Transformers</STRONG> &amp; self Attention mechanism</LI><LI><STRONG>Word Embeddings</STRONG></LI><LI><STRONG>Similarity search</STRONG></LI><LI>Retrieval Augmented Generation (<STRONG>RAG</STRONG>)</LI><LI>Interaction with <STRONG>PDF</STRONG> documents</LI></UL><P>&nbsp;</P><P><FONT size="5"><STRONG>SAP BTP</STRONG> <STRONG>AI Core/ AI Launchpad</STRONG> </FONT></P><P>This is the foundational technology stack for orchestrating and deploying <STRONG>custom</STRONG> AI/ML applications on BTP. AI Core/Launchpad allows you to incorporate your GIT Code repository along with config.yaml file containing the templatized parameters for your ML/AI scenarios, Docker secret &amp; docker image, AI core resource to use (CPU/GPU config), any input parameters etc. AI core provides an SDK to interact with the foundation where as AI launchpad provides a UI5 Frontend to configure your ML/AI scenario. You can configure, deploy &amp; Monitor your scenarios on AI Core &amp; AI launchpad.</P><P><STRONG>Example Application :</STRONG> <A href="https://discovery-center.cloud.sap/missiondetail/4264/" target="_blank" rel="noopener nofollow noreferrer">Reduce your CO2 footprint using a smart Generative AI application on SAP BTP</A></P><P>&nbsp;</P><P><FONT size="5"><STRONG>SAP Analytics Cloud "Just Ask"&nbsp;</STRONG></FONT><FONT size="5"><STRONG>&amp;</STRONG> <STRONG>SAP Datasphere</STRONG></FONT></P><P>Just Ask(GA Q1 2024) will provide a <STRONG>Natural Language processing AI interface</STRONG><SPAN> within SAP Analytics cloud allowing the ability to interact with your data models &amp; dashboards using Natural language based queries.</SPAN></P><P><A href="https://www.sap.com/assetdetail/2023/09/7ed3bf68-897e-0010-bca6-c68f7e60039b.html" target="_self" rel="noopener noreferrer"><STRONG>Video Demo</STRONG></A></P><P><STRONG>&nbsp;SAP Datasphere (SAAS Datawarehouse)</STRONG>&nbsp;allows f<STRONG>ederated data access</STRONG> from many systems allowing Partners to use data from SAP Business applications ( S/4, Success Factors, Ariba etc) or Non SAP Business applications with other datasets on varied on premise/cloud environements to produce powerful Business reporting applications in SAP Analytics cloud, which now also provides inbuilt Gen AI capability with&nbsp;<STRONG>Just Ask.</STRONG></P><P>&nbsp;Below discovery mission includes details on how customers &amp; partners can use&nbsp;<SPAN>data from&nbsp;<STRONG>AWS, Azure, and Google Cloud</STRONG> with the federation capabilities of SAP Datasphere.</SPAN></P><P>&nbsp; <A href="https://discovery-center.cloud.sap/missiondetail/3656/3699/" target="_self" rel="nofollow noopener noreferrer">Discovery Mission : Explore your Hyperscaler data with SAP Datasphere&nbsp;</A></P><P>&nbsp; <A href="https://www.sap.com/sea/products/technology-platform/datasphere.html?video=c64e4807-637e-0010-bca6-c68f7e60039b" target="_self" rel="noopener noreferrer">Video : SAP Datasphere</A>&nbsp;</P><P>&nbsp; <A href="https://www.sap.com/sea/products/technology-platform/datasphere/guided-experience.html" target="_self" rel="noopener noreferrer">Try &amp; Experience SAP Datasphere</A></P><P>&nbsp;</P><P><FONT size="5"><STRONG>SAP Build Code</STRONG></FONT>&nbsp;</P><P>Build Code will provide “Joule” assistant for faster application development by generating code, data models &amp; by providing Guided experience for developers.</P><P>&nbsp;</P><P><div class="video-embed-center video-embed"><iframe class="embedly-embed" src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FLr4JWPVdI0k%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DLr4JWPVdI0k&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FLr4JWPVdI0k%2Fhqdefault.jpg&amp;key=b0d40caa4f094c68be7c29880b16f56e&amp;type=text%2Fhtml&amp;schema=youtube" width="530" height="298" scrolling="no" title="Build faster, build smoother, build easier with SAP Build Code - Product Demo" frameborder="0" allow="autoplay; fullscreen; encrypted-media; picture-in-picture;" allowfullscreen="true"></iframe></div></P><P>&nbsp;</P><P><FONT size="6"><STRONG>Example Use Cases</STRONG></FONT></P><P><FONT size="5"><STRONG>Semantic search app</STRONG></FONT></P><P>Following is a sample <STRONG>search</STRONG> application deployed on Cloud foundry using Python Build pack. A csv of all documents uploaded to sharepoint (or sap workzone) was extracted (typically using the "Reports" section which extracts the list of docs, url, num of clicks, Title, decription etc). This is then processed in python and the <STRONG>Text</STRONG>&nbsp;from Title &amp; description is merged and tokenized. The tokenized text for all docs is then converted into a <STRONG>TF-IDF Matrix</STRONG> (for Term based search which is the default option in below app screen) and also converted to <STRONG>Vector</STRONG>&nbsp;<STRONG>Embeddings</STRONG>&nbsp;using Google <STRONG>BERT&nbsp;</STRONG>model for&nbsp;<STRONG> contextual search.</STRONG></P><P>When a user puts in a query its processed to removed white spaces , special characters etc, tokenized and then compared with the existing Matrices for TF-IDF or Embeddings using <STRONG>Cosine Similarity</STRONG> to retrieve the <STRONG>top matching documents</STRONG>.&nbsp;</P><P>The missing piece in the architecture below is a <STRONG>Vector database to store the text embeddings as a persistent layer.&nbsp;</STRONG>I have used a FAISS in memory index which is loaded <STRONG>in</STRONG> <STRONG>memory</STRONG> when the app starts up. For full fledged guidance from SAP on such architectures refer the&nbsp;<A href="https://discovery-center.cloud.sap/refArchDetail/ref-arch-open-ai" target="_blank" rel="noopener nofollow noreferrer">Reference Architecture</A>.&nbsp;</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VinayBhatt_0-1708053712083.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/66288i8D58E45E6D8E5FAD/image-size/large?v=v2&amp;px=999" role="button" title="VinayBhatt_0-1708053712083.png" alt="VinayBhatt_0-1708053712083.png" /></span></P><P>&nbsp;</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VinayBhatt_1-1708053855634.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/66289iFF3AC019CA947327/image-size/large?v=v2&amp;px=999" role="button" title="VinayBhatt_1-1708053855634.png" alt="VinayBhatt_1-1708053855634.png" /></span></P><P>To understand what<STRONG> contextual search</STRONG>&nbsp;means here let's look at an example, Let's say a user searches for&nbsp; <STRONG>"Aviation Industry relared demo &amp; presentation content"</STRONG> , the results will include all documents which are close in the embedding space example Demos related to <STRONG>Airlines, Flights , Airport Management, Airport ground operation management etc.</STRONG></P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VinayBhatt_2-1708053913535.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/66290i9231ABE8F1520C97/image-size/large?v=v2&amp;px=999" role="button" title="VinayBhatt_2-1708053913535.png" alt="VinayBhatt_2-1708053913535.png" /></span></P><P><FONT size="4"><STRONG>BTP Solution Components</STRONG></FONT></P><P><STRONG>AI core / BTP CF</STRONG><SPAN>&nbsp;</SPAN>Runtime python buildpack(Python API), docker image</P><P><STRONG>AI Launchpad</STRONG><SPAN>&nbsp;</SPAN>: ML Ops , orchestration and monitoring of deployed API.</P><P><STRONG>SAP Build Apps : </STRONG>Frontend</P><P><STRONG>SAP BTP Object Store : </STRONG>CSV extracts store</P><P><STRONG>HANA Cloud Vector database : </STRONG>Text embeddings / similarity search</P><P><FONT size="6"><STRONG>Production Architecture with RAG</STRONG></FONT></P><P><SPAN>In this reference architecture pattern, learn how to seamlessly combine various Large Language Models (LLMs) using SAP AI Core. Maximize the potential of LangChain in&nbsp;</SPAN><A href="https://cap.cloud.sap/docs/" target="_blank" rel="noopener noreferrer nofollow">CAP</A><SPAN>&nbsp;model and implement advanced methods such as custom schema-based output parsing or Retrieval Augmented Generation (RAG) with embeddings and a vector database to further enhance the benefits for your specific needs. This reference architecture accommodates both Cloud Foundry and Kyma runtimes, providing adaptability in your endeavor to leverage GenAI on SAP BTP.</SPAN></P><P><A href="https://discovery-center.cloud.sap/refArchDetail/ref-arch-open-ai" target="_self" rel="nofollow noopener noreferrer"><SPAN>Retrieval Augmented Generation with GenAI on SAP BTP</SPAN></A></P><P><STRONG><FONT size="6">Zero Shot Classification using LLM</FONT></STRONG></P><P>Following is another example wherein I tried Zero Shot classification using a GPT model orchestrated using <STRONG>SAP Gen AI Hub ( SAP AI Core/Launchpad)</STRONG></P><P>Here users are using SAP Analytics cloud to visualize the<STRONG><SPAN>&nbsp;</SPAN>Average Co2<SPAN>&nbsp;</SPAN></STRONG>on a dashboard based on an analysis of their spend at various vendors/retails and across various transaction descriptions. As there are <STRONG>too many descriptions</STRONG> the dashboard is not very intuitive, we then call AI Core<SPAN>&nbsp;</SPAN><STRONG>GPT</STRONG><SPAN>&nbsp;</SPAN>proxy to<SPAN>&nbsp;</SPAN><STRONG>categorize</STRONG>&nbsp;<STRONG>transactions to fixed Categories like Retail,Accomodation, Food etc.&nbsp;</STRONG>using a prompt like below :&nbsp;</P><P><STRONG>PROMPT</STRONG></P><P>Here we are asking the GPT model to assign close to 66 transaction descriptions into 13 categories, the Index of the data will be preserved and will be later used to create the mapping in the data model.</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-abap"><code>Categorize the numerized descriptions below into the 13 categories ['Agricultural Services' 'Contracted Services' 'Airlines' 'Car Rental' 'Lodging' 'Transportation Services' 'Utility Services' 'Retail Outlet Services' 'Clothing Stores' 'Miscellaneous Stores' 'Business Services' 'Professional Services and Membership Organizations' 'Government Services']. Display the result in a table with the format "| INDEX OF DESCRIPTION | CATEGORY |". Descriptions: | 0 | Meat Provisioners – Freezer and Locker | | 1 | Grocery Stores, Supermarkets | | 2 | Cable and other pay television (previously Cable Services) | | 3 | Digital Goods: Media, Books, Movies, Music | | 4 | Financial Institutions – Manual Cash Disbursements | | 5 | Sporting Goods Stores | | 6 | Service Stations ( with or without ancillary services) | | 7 | Financial Institutions – Merchandise and Services | | 8 | Eating places and Restaurants | | 9 | Household Appliance Stores | | 10 | Drugs, Drug Proprietors, and Druggist’s Sundries | | 11 | Glass, Paint, and Wallpaper Stores | | 12 | Petroleum and Petroleum Products | | 13 | Taxicabs and Limousines | | 14 | Book Stores | | 15 | Drug Stores and Pharmacies | | 16 | Candy, Nut, and Confectionery Stores | | 17 | Veterinary Services | | 18 | Miscellaneous and Specialty Retail Stores | | 19 | Money Orders – Wire Transfer | | 20 | Shoe Stores | | 21 | Lodging – Hotels, Motels, Resorts, Central Reservation Services (not elsewhere classified) | | 22 | Family Clothing Stores | | 23 | Miscellaneous Home Furnishing Specialty Stores | | 24 | Fast Food Restaurants | | 25 | Caterers | | 26 | Local/Suburban Commuter Passenger Transportation – Railroads, Feries, Local Water Transportation. | | 27 | Misc. Food Stores – Convenience Stores and Specialty Markets | | 28 | Legal Services and Attorneys | | 29 | Men’s Women’s and Children’s Uniforms and Commercial Clothing | | 30 | Civic, Fraternal, and Social Associations | | 31 | Department Stores | | 32 | Orthopedic Goods Prosthetic Devices | | 33 | Telecommunications Equipment including telephone sales | | 34 | Nurseries – Lawn and Garden Supply Store | | 35 | Package Stores – Beer, Wine, and Liquor | | 36 | Men’s and Women’s Clothing Stores | | 37 | Computers, Computer Peripheral Equipment, Software | | 38 | Dairy Products Stores | | 39 | Membership Organizations ( Not Elsewhere Classified) | | 40 | Equipment Rental and Leasing Services, Tool Rental, Furniture Rental, and Appliance Rental | | 41 | Watch, Clock, Jewelry, and Silverware Stores | | 42 | Travel Agencies and Tour Operations | | 43 | Laundry, Cleaning, and Garment Services | | 44 | Commercial Footwear | | 45 | Card Shops, Gift, Novelty, and Souvenir Shops | | 46 | Digital Goods: Games | | 47 | Hardware Stores | | 48 | Cigar Stores and Stands | | 49 | Bakeries | | 50 | Membership Clubs (Sports, Recreation, Athletic), Country Clubs, and Private Golf Courses | | 51 | Recreation Services (Not Elsewhere Classified) | | 52 | Women’s Ready-to-Wear Stores | | 53 | Women’s Accessory and Specialty Shops | | 54 | Tax Payments | | 55 | Management, Consulting, and Public Relations Services | | 56 | Drinking Places (Alcoholic Beverages), Bars, Taverns, Cocktail lounges, Nightclubs and Discotheques | | 57 | News Dealers and Newsstands | | 58 | Ambulance Services | | 59 | Industrial Supplies, Not Elsewhere Classified | | 60 | Computer Software Stores | | 61 | Motion Picture Theaters | | 62 | Cosmetic Stores | | 63 | Electronic Sales | | 64 | Hospitals | | 65 | Miscellaneous Publishing and Printing | | 66 | Wholesale Clubs |</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P><STRONG>RESULTS:&nbsp;</STRONG></P><P>As you see in the results 66 Indexes are now assigned to 13 Categories or transaction descriptions:&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-abap"><code>This classification is based on the provided categories and the details of the descriptions: | INDEX OF DESCRIPTION | CATEGORY | |----------------------|-------------------------------------| | 0 | Retail Outlet Services | | 1 | Retail Outlet Services | | 2 | Utility Services | | 3 | Retail Outlet Services | | 4 | Financial Institutions | | 5 | Retail Outlet Services | | 6 | Retail Outlet Services | | 7 | Business Services | | 8 | Retail Outlet Services | | 9 | Retail Outlet Services | | 10 | Retail Outlet Services | | 11 | Retail Outlet Services | | 12 | Retail Outlet Services | | 13 | Transportation Services | | 14 | Retail Outlet Services | | 15 | Retail Outlet Services | | 16 | Retail Outlet Services | | 17 | Professional Services and Membership Organizations | | 18 | Miscellaneous Stores | | 19 | Financial Institutions | | 20 | Clothing Stores | | 21 | Lodging | | 22 | Clothing Stores | | 23 | Retail Outlet Services | | 24 | Retail Outlet Services | | 25 | Retail Outlet Services | | 26 | Transportation Services | | 27 | Retail Outlet Services | | 28 | Professional Services and Membership Organizations | | 29 | Clothing Stores | | 30 | Professional Services and Membership Organizations | | 31 | Retail Outlet Services | | 32 | Retail Outlet Services | | 33 | Retail Outlet Services | | 34 | Agricultural Services | | 35 | Retail Outlet Services | | 36 | Clothing Stores | | 37 | Retail Outlet Services | | 38 | Retail Outlet Services | | 39 | Professional Services and Membership Organizations | | 40 | Contracted Services | | 41 | Retail Outlet Services | | 42 | Professional Services and Membership Organizations | | 43 | Professional Services and Membership Organizations | | 44 | Clothing Stores | | 45 | Retail Outlet Services | | 46 | Retail Outlet Services | | 47 | Retail Outlet Services | | 48 | Retail Outlet Services | | 49 | Retail Outlet Services | | 50 | Professional Services and Membership Organizations | | 51 | Recreation Services | | 52 | Clothing Stores | | 53 | Clothing Stores | | 54 | Government Services | | 55 | Professional Services and Membership Organizations | | 56 | Retail Outlet Services | | 57 | Retail Outlet Services | | 58 | Professional Services and Membership Organizations | | 59 | Retail Outlet Services | | 60 | Retail Outlet Services | | 61 | Recreation Services | | 62 | Retail Outlet Services | | 63 | Retail Outlet Services | | 64 | Professional Services and Membership Organizations | | 65 | Retail Outlet Services | | 66 | Retail Outlet Services | Note: There were some descriptions that didn't fit perfectly into any of the provided categories. For these, the closest match was chosen based on the context. For example, "Financial Institutions – Manual Cash Disbursements" and "Financial Institutions – Merchandise and Services" were assigned to "Financial Institutions", which is not present in the provided categories but seems the most appropriate based on the description.</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>The AI Core code calls GPT to map the transaction descriptions to the outcome categories &amp; the results are then processed and saved back in the HANA cloud database. The SAC live connection then pulls the updated records&nbsp; in a new <STRONG>simplified</STRONG> dashboard.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VinayBhatt_0-1708056237744.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/66295i407DC8195A18FB8B/image-size/large?v=v2&amp;px=999" role="button" title="VinayBhatt_0-1708056237744.png" alt="VinayBhatt_0-1708056237744.png" /></span></P><P>Below is a <STRONG>simpler dashboard</STRONG> with lesser categories after update from GPT :&nbsp;</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VinayBhatt_1-1708056525314.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/66297iC6725B73936713B5/image-size/large?v=v2&amp;px=999" role="button" title="VinayBhatt_1-1708056525314.png" alt="VinayBhatt_1-1708056525314.png" /></span></P><P><FONT size="4"><STRONG>BTP Solution Components</STRONG></FONT></P><P><STRONG>AI core &amp; Gen AI Hub :&nbsp;</STRONG>App logic in Python in a docker image(GPT call / prompt management)&nbsp;</P><P><STRONG>AI Launchpad</STRONG><SPAN>&nbsp;</SPAN>: ML Ops , operations monitoring of deployed API.</P><P><STRONG>SAP Analytics Cloud : </STRONG>Frontend</P><P>&nbsp;</P><P><FONT size="6"><STRONG>AI QUIZ APP</STRONG></FONT></P><P><FONT size="4">Following is a sample quiz application which uses <STRONG>Gen AI to create Multiple Choice Question &amp; Answers</STRONG> , using product specific or organization specific scenarios. Quizes can be generated in JSON format using a LLM and then served using a Frontend application.&nbsp;</FONT></P><P><FONT size="5"><STRONG>PROMPT</STRONG></FONT></P><P>In the prompt we have provided a JSON template for the response, GPT model will return question/answer pair in this template , making it easier to directly use this in the frontend application.</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-abap"><code>using the below text as context : " What Is Edge Integration Cell Edge Integration Cell is an optional hybrid integration runtime offered as part of SAP Integration Suite, which enables you to manage APIs and run integration scenarios within your private landscape. The hybrid deployment model of Edge Integration Cell enables you to: * Design and monitor your integration content in the cloud. * Deploy and run your integration content in your private landscape. To learn more about how hybrid deployment works using Edge Integration Cell, see Hybrid Deployment Using Edge Integration Cell. To compare hybrid deployment with the standard deployment model of SAP Integration Suite, see Standard Deployment in the Cloud. Edge Integration Cell supports the following use cases: * Security or compliance use cases
In many enterprises, sensitive data must be managed and controlled inside the enterprise's firewall. In addition, there could be strict architectural restrictions and you want to keep your data within your private landscape. * Getting a migration path for SAP Process Integration customers
SAP Process Integration is used by many customers for ground-to-ground integration scenarios. Edge Integration Cell allows these customers to benefit from the newest innovations that come with SAP Integration Suite, with the option to design and monitor integration content in the cloud, and deploy and run their scenarios exclusively in their private landscapes.
Note
If you want to use integration flows to integrate your on-premise applications, you can use SAP Process Orchestration in addition to SAP Integration Suite. SAP Integration Suite comes with a set of runtime profiles that make sure that the integration flow editor allows you to design only those features that are supported by the runtime components of a specific SAP Process Orchestration release.
For more information, see Runtime Profiles.
However, this option requires you to install a separate product, SAP Process Orchestration, for processing and monitoring messages.
Using Edge Integration Cell, you can manage all tasks – from integration design up to processing and monitoring the scenario – within one service: SAP Integration Suite.
 In both cases, we recommend using a hybrid integration approach for enterprise-wide connectivity. For more information about the supported features and limitations of Edge Integration Cell, see Edge Integration Cell Runtime Scope. " Generate five multiple choice question answer set output as a single JSON code, using below template , the link property of the JSON should default to the url: “link":"https://help.sap.com/docs/integration-suite/sap-integration-suite/what-is-sap-integration-suite-edge-integration-cell” { "type": "multiple", "difficulty": "easy", "category": “SAP BTP - Edge”, "question": “What is fundamental technology behind ChatGPT”, "correct_answer": “Generative AI”, "incorrect_answers": [ "Its cool", "Ethanol", "Formaldehyde" ], "link":""</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>Test the Response using different LLM models on Gen AI Hub , here we have the opportunity to maintain our prompts.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VinayBhatt_1-1708060250367.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/66320iC2737A752A50BCA5/image-size/large?v=v2&amp;px=999" role="button" title="VinayBhatt_1-1708060250367.png" alt="VinayBhatt_1-1708060250367.png" /></span></P><P>The generated questions JSON can be saved in a GIT repo and exposed as an API using Python Flask/Fast API on cloud foundry buildpack. Frontend Application here is built on&nbsp;<STRONG>React.&nbsp;</STRONG>Here is a reference Quiz Open source App which can be customized to read from a Private API instead of Open Trivia Database : <A href="https://github.com/SafdarJamal/quiz-app" target="_self" rel="nofollow noopener noreferrer">GIT</A></P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VinayBhatt_0-1708170480571.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/66890iD95D2616CB7AA38E/image-size/large?v=v2&amp;px=999" role="button" title="VinayBhatt_0-1708170480571.png" alt="VinayBhatt_0-1708170480571.png" /></span></P><P>&nbsp;</P><P><FONT size="4"><STRONG>BTP Solution Components</STRONG></FONT></P><P><STRONG>AI core &amp; Gen AI Hub :&nbsp;</STRONG>App logic in Python in a docker image(GPT call / prompt management)&nbsp;</P><P><STRONG>AI Launchpad</STRONG><SPAN>&nbsp;</SPAN>: ML Ops , operations and monitoring of deployed API.</P><P><STRONG>React App: </STRONG>FrontendDeployed on Cloud foundry Node buildpack.&nbsp;</P><P><STRONG><FONT size="6">Conclusion</FONT></STRONG></P><P>SAP BTP has a powerful platform to quickly build highly scalable applications and further infuse Gen AI using the technologies &amp; products that we explored in this article. I'm happy to collaborate and provide more inputs on any of the applications I have presented in the use cases section.&lt;Please note that these were self initiated projects for personal learning and development &gt;.</P> 2024-02-18T04:43:44.423000+01:00 https://community.sap.com/t5/artificial-intelligence-and-machine-learning-blogs/unlocking-the-power-of-sap-ai-core-building-a-rag-pipeline-with-llamaindex/ba-p/13619841 Unlocking the Power of SAP AI Core: Building a RAG Pipeline with LlamaIndex 2024-02-26T19:03:06.124000+01:00 PuranK https://community.sap.com/t5/user/viewprofilepage/user-id/181122 <P class="" data-unlink="true"><STRONG><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Image generated by Author" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/71479i9CA3C451CA7D274E/image-size/large?v=v2&amp;px=999" role="button" title="_165cba82-9a97-4a7f-aaf0-1aa8abefa17f.jfif" alt="Image generated by Author" /><span class="lia-inline-image-caption" onclick="event.preventDefault();">Image generated by Author</span></span></STRONG></P><P>&nbsp;</P><P class="" data-unlink="true"><STRONG>Introduction:</STRONG><SPAN>&nbsp;</SPAN>In the ever-evolving landscape of AI and language models, the year 2023 marked a significant focus on the capabilities of Large Language Models (LLMs) and Retrieval-Augmented Generation (RAG) architectures. As the year came to a close, I seized the opportunity during the holidays to delve into this cutting-edge field. This blog recounts my journey of building a sophisticated RAG pipeline, leveraging technologies like LlamaIndex, ChromaDB, HuggingFace’s Zephyr-7b (a fine-tuned version of<SPAN>&nbsp;</SPAN><A href="https://huggingface.co/mistralai/Mistral-7B-v0.1" target="_blank" rel="noopener nofollow noreferrer">mistralai/Mistral-7B-v0.1</A>&nbsp;), and deploying the entire system on SAP Business Technology Platform (BTP).</P><P class=""><STRONG>How it All Began:</STRONG></P><P class="">My exploration began with the learnings I had in the realms of LLM and Generative AI. LlamaIndex, a potent data framework connecting domain data to LLMs, caught my attention. Learning the intricacies of executing data ingestion pipelines, generating embeddings, and storing them in a vector database, I decided to extend this knowledge by building and deploying it on SAP AI Core.</P><P class=""><STRONG>Challenges and Solutions:</STRONG></P><P class="">While embarking on this endeavor, I encountered a hurdle: the anticipation of the vectorized SAP HANA DB release in Q1 2024. Undeterred, I scoured for an open-source vector database and discovered ChromaDB — an influential, user-friendly solution with an active online community. The next puzzle piece was finding a free-to-use LLM, and I stumbled upon HuggingFace platform.</P><P class="">In a corporate use case where an SFTP site contains diverse data types, such as text-based PDFs, image-based PDFs, images, and plain text files. The goal is to ingest this data into the RAG pipeline, create vector embeddings, store them in a vector database, and build an index for efficient search and retrieval. The process flow is visualized in the diagram below:</P><P><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Image credit : https://blog.griddynamics.com/retrieval-augmented-generation-llm/" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/71462i74EC0B79B74989D4/image-size/large?v=v2&amp;px=999" role="button" title="PuranK_21-1708965882146.png" alt="Image credit : https://blog.griddynamics.com/retrieval-augmented-generation-llm/" /><span class="lia-inline-image-caption" onclick="event.preventDefault();">Image credit : https://blog.griddynamics.com/retrieval-augmented-generation-llm/</span></span></P><P>&nbsp;</P><P class="" data-unlink="true"><STRONG>Basic RAG implementation involves 4 steps:</STRONG><BR /><EM>If you are already familiar with RAG techniques, you can jump to<SPAN>&nbsp;</SPAN></EM><STRONG><EM>Build &amp; deployment steps for SAP BTP and AI Core</EM></STRONG>&nbsp;&nbsp;</P><P class=""><STRONG>Step 1 : Loading documents</STRONG><SPAN>&nbsp;</SPAN>— In our case we will be loading the documents from SFTP site</P><P class=""><STRONG>Step 2 : Parsing Documents into Text Chunks (Nodes)<SPAN>&nbsp;</SPAN></STRONG>— Split the document into text chunks, which are called “Nodes” in LlamaIndex, where we define the chuck size as 512 in the embedding model.</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-python"><code> sentence_node_parser = SentenceWindowNodeParser.from_defaults( window_size=3, window_metadata_key="window", original_text_metadata_key="original_text" ) nodes = sentence_node_parser.get_nodes_from_documents(documents)</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P class=""><STRONG>Step 3 : Selection of embedding model and LLM</STRONG></P><UL class=""><LI>The embedding model is used to create vector embeddings for each of the nodes. Here we are calling the<SPAN>&nbsp;</SPAN><A class="" href="https://huggingface.co/sentence-transformers/all-mpnet-base-v2" target="_blank" rel="noopener ugc nofollow noreferrer"><EM>microsoft/mpnet</EM></A><SPAN>&nbsp;</SPAN>model from Hugging Face. This model tops the<SPAN>&nbsp;</SPAN><A class="" href="https://www.sbert.net/docs/pretrained_models.html" target="_blank" rel="noopener ugc nofollow noreferrer">leader board</A><SPAN>&nbsp;</SPAN>in terms of overall performance for embeddings.</LI><LI>LLM: User query and the relevant text chunks are fed into the LLM so that it can generate answers with relevant context.</LI></UL><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-python"><code>embed_model = HuggingFaceEmbedding(model_name=”sentence-transformers/all-mpnet-base-v2", max_length=512)</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P class=""><STRONG>Step 4. Create Index, retriever, and query engine</STRONG></P><P class="">Index, retriever, and query engine are three basic components for asking questions about your data or documents:</P><UL class=""><LI>Index is a data structure that allows us to retrieve relevant information quickly for a user query from external documents. The Vector Store Index takes the text chunks/Nodes and then creates vector embeddings of the text of every node, ready to be queried by an LLM.</LI></UL><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-python"><code>ctx_sentence = ServiceContext.from_defaults(llm=llm, embed_model=embed_model, node_parser=sentence_node_parser) storage_context = StorageContext.from_defaults(vector_store=vector_store) sentence_index = VectorStoreIndex(nodes, service_context=ctx_sentence, storage_context=storage_context)</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><UL class=""><LI>For retrieval we will be using an advanced method<SPAN>&nbsp;</SPAN><STRONG>sentence window retrieval :<SPAN>&nbsp;</SPAN></STRONG>To achieve an even more fine-grained retrieval, instead of using smaller child chunks, we can parse the documents into a single sentence per chunk.</LI><LI>In this case, single sentences will be similar to the “child” chunk concept. The sentence “window” (5 sentences on either side of the original sentence) will be similar to the “parent” chunk concept. In other words, we use the single sentences during retrieval and pass the retrieved sentence with the sentence window to the LLM. Details of this technique can be visualized better with this<SPAN>&nbsp;</SPAN><A class="" href="https://link.excalidraw.com/readonly/m6DK7oyEFpyQnuw55DVP?darkMode=true" target="_blank" rel="noopener ugc nofollow noreferrer">diagram</A>.</LI></UL><P><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="PuranK_22-1708966131954.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/71464iC0A1D59B7D89187D/image-size/large?v=v2&amp;px=999" role="button" title="PuranK_22-1708966131954.png" alt="PuranK_22-1708966131954.png" /></span></P><UL class=""><LI>Create the sentence window node parser</LI></UL><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-python"><code># create the sentence window node parser w/ default settings node_parser = SentenceWindowNodeParser.from_defaults( window_size=3, window_metadata_key="window", original_text_metadata_key="original_text", ) sentence_nodes = node_parser.get_nodes_from_documents(docs) sentence_index = VectorStoreIndex(sentence_nodes, service_context=service_context)</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><UL class=""><LI>Create a query engine</LI></UL><P class="">When we create the query engine, we can replace the sentence with the sentence window using the<SPAN>&nbsp;</SPAN><EM>MetadataReplacementPostProcessor</EM>, so that the window of the sentences get sent to the LLM.</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-python"><code>query_engine = sentence_index.as_query_engine( similarity_top_k=2, # the target key defaults to `window` to match the node_parser's default node_postprocessors=[ MetadataReplacementPostProcessor(target_metadata_key="window") ], ) window_response = query_engine.query( "Can you tell me about the key concepts for supervised finetuning" ) print(window_response)</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><BLOCKQUOTE><P class=""><STRONG>Build &amp; deployment steps for SAP BTP and AI Core</STRONG></P></BLOCKQUOTE><P class="">Now with this understanding lets build the<SPAN>&nbsp;</SPAN><A class="" href="https://docs.llamaindex.ai/en/stable/examples/low_level/oss_ingestion_retrieval.html" target="_blank" rel="noopener ugc nofollow noreferrer">RAG pipeline using LlamaIndex</A><SPAN>&nbsp;</SPAN>and run this pipeline on SAP AI core.<BR />Pre requisites and setup:</P><OL class=""><LI>I have<SPAN>&nbsp;</SPAN><A class="" href="https://blogs.sap.com/2023/04/04/running-an-sftp-server-on-sap-kyma/" target="_blank" rel="noopener ugc noreferrer">set up a SFTP server on BTP Kyma runtime</A>, you can use any other SFTP server as well.</LI><LI>Set up a ChromaDB using Docker image and deploy the docker image on Kyma runtime using below YAML file.<SPAN>&nbsp;</SPAN><A class="" href="https://docs.trychroma.com/deployment" target="_blank" rel="noopener ugc nofollow noreferrer">Other deployment options</A></LI></OL><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-python"><code>docker pull chromadb/chroma docker tag chroma &lt;your_username&gt;/chroma:latest docker push &lt;your_username&gt;/chroma:latest</code></pre><pre class="lia-code-sample language-yaml"><code>apiVersion: apps/v1 kind: Deployment metadata: name: my-chroma-app spec: replicas: 1 selector: matchLabels: app: my-chroma-app template: metadata: labels: app: my-chroma-app spec: containers: - name: my-chroma-app image: your-docker-username/my-chroma-image:latest ports: - containerPort: 80</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P><SPAN>Create a Load balancer service for this deployment</SPAN></P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-yaml"><code>apiVersion: v1 kind: Service metadata: name: your-service spec: type: LoadBalancer ports: - port: 80 targetPort: 8080 selector: app: your-app</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P class="">and lastly create a DNS entry on top of the service to access the ChromaDB using host and port details over internet.</P><P class="">3. I have subscribed to the SAP AI Core standard edition for advanced memory usage in running LLM.</P><P class="">4. Now, let’s explore the code for building the RAG pipeline, including data ingestion from SFTP and loading the<SPAN>&nbsp;</SPAN><A class="" href="https://huggingface.co/HuggingFaceH4/zephyr-7b-beta" target="_blank" rel="noopener ugc nofollow noreferrer">HuggingFace model zephyr-7b-beta</A><SPAN>&nbsp;</SPAN>model into SAP AI core</P><UL class=""><LI>In the VS code make a directory</LI></UL><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-bash"><code>mkdir zephyr-on-ai-core</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><UL class=""><LI>Code to build a Docker Image for custom GPU which will be required to load the transformer model, I have the docker file named as<SPAN>&nbsp;</SPAN><EM>Dockerfile.customgpu</EM></LI></UL><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-python"><code>FROM python:3.11.6 AS base WORKDIR /serving COPY requirements.txt requirements.txt RUN apt update RUN git clone https://github.com/huggingface/transformers RUN pip3 install -r requirements.txt RUN apt-get update \ &amp;&amp; apt-get -y install tesseract-ocr RUN apt-get install -y poppler-utils FROM base as final ENV LC_ALL=C.UTF-8 ENV LANG=C.UTF-8 RUN export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/cuda/lib64:/usr/local/cuda-10.0/targets/x86_64-linux/lib:/usr/local/cuda-10.2/targets/x86_64-linux/lib:/usr/local/cuda-11/targets/x86_64-linux/lib:/usr/local/cuda-11.6/targets/x86_64-linux/lib/stubs:/usr/local/cuda-11.6/compat:/usr/local/cuda-11.6/targets/x86_64-linux/lib RUN export PATH=$PATH:/usr/local/cuda-11/bin # Required for huggingface RUN mkdir -p /nonexistent/ RUN mkdir -p /transformerscache/ RUN chown -R 1000:1000 /nonexistent RUN chmod -R 777 /nonexistent RUN chmod -R 777 /transformerscache # Create the directory and set permissions RUN mkdir -p /serving/data RUN chown -R 1000:1000 /serving/data RUN chmod -R 777 /serving/data # Create the directory and set permissions RUN mkdir -p /serving/data/temp RUN chown -R 1000:1000 /serving/data/temp RUN chmod -R 777 /serving/data/temp # Create the directory and set permissions RUN mkdir -p /usr/local/lib/python3.11/site-packages/llama_index/download/llamahub_modules RUN chown -R 1000:1000 /usr/local/lib/python3.11/site-packages/llama_index/download/llamahub_modules RUN chmod -R 777 /usr/local/lib/python3.11/site-packages/llama_index/download/llamahub_modules ENV TRANSFORMERS_CACHE=/transformerscache COPY /serving /serving CMD ["uvicorn", "app:api", "--host", "0.0.0.0", "--port", "8080"] </code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><UL class=""><LI>Create a<SPAN>&nbsp;</SPAN><EM>requirements.txt</EM><SPAN>&nbsp;</SPAN>to manage all the dependencies as below</LI></UL><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-abap"><code>transformers==4.36.2 tokenizers&gt;=0.13.3 --find-links https://download.pytorch.org/whl/torch_stable.html torch fastapi uvicorn accelerate huggingface_hub onnxruntime requests chromadb==0.4.9 llama-index sentence-transformers==2.1.0 PyPDF2==1.26.0 pysftp # pytesseract and its dependencies pillow pytesseract PyMuPDF # pdf2image and its dependencies pdf2image</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><UL class=""><LI>Now let’s create a subfolder template and in this folder create a<SPAN>&nbsp;</SPAN><EM>transformers.yaml</EM><SPAN>&nbsp;</SPAN>with below code</LI></UL><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-yaml"><code>apiVersion: ai.sap.com/v1alpha1 kind: ServingTemplate metadata: name: transformers annotations: scenarios.ai.sap.com/description: "zephyr" scenarios.ai.sap.com/name: "zephyr" executables.ai.sap.com/description: "zephyr" executables.ai.sap.com/name: "zephyr" labels: scenarios.ai.sap.com/id: "zephyr" ai.sap.com/version: "1.0" spec: template: apiVersion: "serving.kserve.io/v1beta1" metadata: annotations: | autoscaling.knative.dev/metric: concurrency autoscaling.knative.dev/target: 1 autoscaling.knative.dev/targetBurstCapacity: 0 labels: | ai.sap.com/resourcePlan: infer.l spec: | predictor: imagePullSecrets: - name: dockerpk minReplicas: 1 maxReplicas: 5 containers: - name: kserve-container image: docker.io/purankhoeval/zephyr:01 ports: - containerPort: 8080 protocol: TCP</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><UL class=""><LI>Create a another folder called serving and inside this we are going to create two files<SPAN>&nbsp;</SPAN><EM>app.py</EM><SPAN>&nbsp;</SPAN>and<SPAN>&nbsp;</SPAN><EM>worker_model.py</EM></LI><LI>In the app.py we are creating API definition using FastAPI and this API has entry points defined for each operation such as Data Ingestion and Query search</LI><LI>In the<SPAN>&nbsp;</SPAN><EM>worker_model.py</EM><SPAN>&nbsp;</SPAN>we are implementing the handling functions of data ingestion, query search and results retrieval</LI><LI>Data ingestion for RAG is a multistep process. It starts with reading the content from SFTP server directory, I have kept 3 files for this scenario, a remittance image, a text based pdf of 20 pages which is a subset of this<SPAN>&nbsp;</SPAN><A class="" href="https://arxiv.org/pdf/2307.09288.pdf" target="_blank" rel="noopener ugc nofollow noreferrer">document</A><SPAN>&nbsp;</SPAN>and one more 46 pages image based pdf which has remittance details. These documents will be loaded using LlamaIndex library functions and split into smaller chunks i.e. nodes in our case.</LI></UL><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-python"><code># Code for worker_model.py import torch import transformers import traceback # Add this import import sys, os import pysftp import huggingface_hub from pprint import pprint from llama_index.node_parser import SentenceWindowNodeParser from llama_index.embeddings import HuggingFaceEmbedding from llama_index.schema import MetadataMode from llama_index.postprocessor import MetadataReplacementPostProcessor from llama_index.vector_stores import ChromaVectorStore,VectorStoreQuery from llama_index import ( VectorStoreIndex, SimpleDirectoryReader, StorageContext, ServiceContext, Document ) from llama_index.llms import HuggingFaceInferenceAPI from llama_index.embeddings import HuggingFaceEmbedding import chromadb from chromadb.utils import embedding_functions from llama_index import download_loader from pathlib import Path import pytesseract import pdf2image from pdf2image import convert_from_path import fitz transformers.utils.logging.set_verbosity_error() transformers.utils.logging.disable_progress_bar() os.environ["TRANSFORMERS_CACHE"] = "shared/IMR/llm2023/cache" def download_pdf_from_sftp(sftp_host, sftp_username, sftp_password, sftp_port, remote_path, local_path): cnopts = pysftp.CnOpts() cnopts.hostkeys = None # Disable host key checking (not recommended for production) with pysftp.Connection(sftp_host, username=sftp_username, password=sftp_password, port=sftp_port, cnopts=cnopts) as sftp: # Create the local directory if it doesn't exist os.makedirs(os.path.dirname(local_path), exist_ok=True) # sftp.get(remote_path, local_path) remote_files = sftp.listdir(remote_path) # Download each file individually for remote_file in remote_files: remote_file_path = os.path.join(remote_path, remote_file) local_file_path = os.path.join(local_path, remote_file) sftp.get(remote_file_path, local_file_path) # SFTP details sftp_host = '&lt;sftp_host&gt;' sftp_port = '&lt;port&gt;' sftp_username = '&lt;user&gt;' sftp_password = '&lt;password&gt;' remote_pdf_path = '/upload/' local_pdf_path = './data/' # Download PDF from SFTP download_pdf_from_sftp(sftp_host, sftp_username, sftp_password, sftp_port, remote_pdf_path, local_pdf_path) ImageReader = download_loader("ImageReader") # Use the model_kwargs to pass options to the parser function loader = ImageReader(text_type="plain_text") image_paths = [] documents = [] def is_text_based_pdf(pdf_path): try: # Open the PDF file pdf_document = fitz.open(pdf_path) # Iterate through each page and check for text for page_number in range(pdf_document.page_count): page = pdf_document[page_number] text = page.get_text() # If text is found on any page, it's likely a text-based PDF if text.strip(): return True # No text found on any page, it might be an image-based PDF return False except Exception as e: # Handle exceptions (e.g., if the PDF is encrypted or malformed) print(f"Error checking PDF: {e}") return False def process_pdf_file(pdf_path): is_text_based = is_text_based_pdf(pdf_path) # Check if the PDF is text-based or image-based if is_text_based: directory_reader = SimpleDirectoryReader(input_files=[pdf_path]) # Load data from the specified file path documentspdf = directory_reader.load_data() # Create a llamaindex Document from ImageDocument doc1 = documentspdf[0] doc1 = Document(doc_id=doc1.id_, text=doc1.text, metadata=doc1.metadata) documents.append(doc1) doc1 = [] else: print("The PDF is image-based.") # Convert the PDF to images images = convert_from_path(pdf_path) # Save each image to a file and load as ImageDocuments for i, image in enumerate(images): image_path = Path(f"./data/temp/page_{i}.png") image.save(image_path) image_paths.append(image_path) doc = loader.load_data(file=image_path) documents.extend(doc) # Process files in the directory def process_files_in_directory(directory_path): # Iterate through files in the directory for filename in os.listdir(directory_path): file_path = os.path.join(directory_path, filename) # Check file extension _, file_extension = os.path.splitext(filename) # Call the appropriate function based on the file type if file_extension.lower() in ['.jpg', '.jpeg', '.png']: local_image_path = "./data/remit.png" ImageReader = download_loader("ImageReader") # Use the model_kwargs to pass options to the parser function loader = ImageReader(text_type="plain_text") documentsimg = loader.load_data(file_path) documents.extend(documentsimg) elif file_extension.lower() == '.pdf': process_pdf_file(file_path) class Model: generator = None @staticmethod def setup(): """model setup""" print("START LOADING SETUP ZEPHYR 7B", file=sys.stderr) device = torch.device("cuda" if torch.cuda.is_available() else "cpu") model_name = "HuggingFaceH4/zephyr-7b-beta" HUB_TOKEN = "&lt;hub_token&gt;" huggingface_hub.login(token=HUB_TOKEN) llm = HuggingFaceInferenceAPI( model_name="HuggingFaceH4/zephyr-7b-beta", token=HUB_TOKEN ) print("SETUP DONE", file=sys.stderr) @staticmethod def predict(prompt, args): """model setup""" return Model.generator(prompt, args) @staticmethod def query(question): print("Question:", question) # sentence_transformer_ef = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="all-mpnet-base-v2") # Set up ChromaDB client and collection chroma_host = "&lt;chroma host on kyma&gt;" chroma_port = 8000 chroma_client = chromadb.HttpClient(host=chroma_host, port=chroma_port) # chroma_client = chromadb.PersistentClient(path='./sentence_index') print('HEARTBEAT:', chroma_client.heartbeat()) chroma_collection_name = "multidoc" chroma_collection = chroma_client.get_collection(name=chroma_collection_name) # , embedding_function=sentence_transformer_ef) HUB_TOKEN = "&lt;your token&gt;" huggingface_hub.login(token=HUB_TOKEN) llm = HuggingFaceInferenceAPI( model_name="HuggingFaceH4/zephyr-7b-beta", token=HUB_TOKEN ) embed_model = HuggingFaceEmbedding(model_name="sentence-transformers/all-mpnet-base-v2", max_length=512) # set up ChromaVectorStore and load in data vector_store = ChromaVectorStore(chroma_collection=chroma_collection) ctx_sentence = ServiceContext.from_defaults(llm=llm, embed_model=embed_model) retrieved_sentence_index = VectorStoreIndex.from_vector_store(vector_store=vector_store, service_context=ctx_sentence) sentence_query_engine = retrieved_sentence_index.as_query_engine( similarity_top_k=5, verbose=True, # the target key defaults to `window` to match the node_parser's default node_postprocessors=[ MetadataReplacementPostProcessor(target_metadata_key="window") ], ) import json try: sentence_response = sentence_query_engine.query(question) # Check if the result is empty if not sentence_response: result_message = {"success": False, "message": "No results found."} else: # Extract relevant information from sentence_response extracted_info = {"response": sentence_response.response} result_message = {"success": True, "results": extracted_info} # Print the JSON representation print(json.dumps(result_message)) # Return the result_message return result_message except Exception as e: error_message = {"success": False, "message": f"Error during query execution: {str(e)}"} print(json.dumps(error_message)) traceback.print_exc() sys.exit(1) @staticmethod def DataIngestion(): print("Data Ingestion Started") directory_path = "./data/" process_files_in_directory(directory_path) sentence_node_parser = SentenceWindowNodeParser.from_defaults( window_size=3, window_metadata_key="window", original_text_metadata_key="original_text" ) nodes = sentence_node_parser.get_nodes_from_documents(documents) HUB_TOKEN = "&lt;your token&gt;" huggingface_hub.login(token=HUB_TOKEN) llm = HuggingFaceInferenceAPI( model_name="HuggingFaceH4/zephyr-7b-beta", token=HUB_TOKEN ) # sentence_transformer_ef = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="all-mpnet-base-v2") chroma_host = "&lt;chroma host on kyma&gt;" chroma_port = 8000 chroma_client = chromadb.HttpClient(host=chroma_host, port=chroma_port) chroma_collection_name = "multidocai" # chroma_client.delete_collection(name=chroma_collection_name) chroma_collection = chroma_client.get_or_create_collection(name=chroma_collection_name) # embedding_function=sentence_transformer_ef) embed_model = HuggingFaceEmbedding(model_name="sentence-transformers/all-mpnet-base-v2", max_length=512) vector_store = ChromaVectorStore(chroma_collection=chroma_collection) ctx_sentence = ServiceContext.from_defaults(llm=llm, embed_model=embed_model, node_parser=sentence_node_parser) storage_context = StorageContext.from_defaults(vector_store=vector_store) sentence_index = VectorStoreIndex(nodes, service_context=ctx_sentence, storage_context=storage_context) # sentence_index.storage_context.persist() if __name__ == "__main__": # for local testing Model.setup() print(Model.predict("Hello, who are you?", {}))</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><UL class=""><LI>We are ready to create a docker image. In the below code replace &lt;your_username&gt; with the actual docker hub username</LI></UL><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-bash"><code>docker build -t &lt;your_username&gt;/zephyr:01 -f Dockerfile.customgpu . docker push &lt;your_username&gt;/zephyr:01</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><UL class=""><LI>Now push the entire project to github, we would be creating an AI application from the serving template in SAP AI Core using the github repository, and docker registry secret, detailed steps to set up the repository and how to create an AI application can be found in this<SPAN>&nbsp;</SPAN><A class="" href="https://developers.sap.com/tutorials/ai-core-helloworld.html" target="_blank" rel="noopener ugc noreferrer">article</A><SPAN>&nbsp;</SPAN>and<SPAN>&nbsp;</SPAN><A class="" href="https://developers.sap.com/tutorials/ai-core-deploy.html" target="_blank" rel="noopener ugc noreferrer">deployment related tutorial</A></LI><LI>Once you have deployed successfully, SAP AI Core will generate an inference API URL to run the LLM predictions ( URL generation takes a bit)</LI></UL><P><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="PuranK_23-1708966584481.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/71466i766559E7DA3C22ED/image-size/large?v=v2&amp;px=999" role="button" title="PuranK_23-1708966584481.png" alt="PuranK_23-1708966584481.png" /></span></P><UL class=""><LI>You can test this inference endpoint using postman, just remember to set the bearer token for oAuth authentication using client id and client secret for the AI Core service.</LI></UL><P class="">5. Let’s move on to the last phase of this post to create a Next JS UI project which can call this AI inference endpoint to generate results for us. While client side is handled through Next JS, the server side requests are going to be handled by Node JS</P><UL class=""><LI>Back to the VS code project zephyr-on-ai-core, inside this parent folder let’s create a Next JS app using the terminal command</LI></UL><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-bash"><code>npx create-next-app ragui cd ragui npm run dev</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><UL class=""><LI>This will launch your Next.js app, and you can view it in your browser at<SPAN>&nbsp;</SPAN><A class="" href="http://localhost:3000/" target="_blank" rel="noopener ugc nofollow noreferrer">http://localhost:3000</A>.</LI><LI>Inside ragui there should be a folder app and inside that page.tsx, modify this file with the following code. We are trying to create a basic chat app container where user can input the query and trigger the response retrieval by clicking on the send message button. There is an additional button start data ingestion to trigger the data ingestion process. This will trigger the logic to read the files located on SFTP server and for each of these files we are going to create nodes using LlamaIndex library function sentence node parser.</LI></UL><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-javascript"><code>"use client"; // This is a client component import React, { useState, useRef, useEffect } from 'react'; interface Message { text: string; user: string; } interface RenderMessageTextProps { text: string; } const ChatApp = () =&gt; { const [messages, setMessages] = useState&lt;Message[]&gt;([]); const [newMessage, setNewMessage] = useState&lt;string&gt;(''); const [dataIngestionStatus, setDataIngestionStatus] = useState(''); const messagesContainerRef = useRef&lt;HTMLDivElement&gt;(null); const renderMessageText = ({ text }: RenderMessageTextProps) =&gt; { const formattedText = text.replace(/\n/g, '&lt;br&gt;'); return &lt;span dangerouslySetInnerHTML={{ __html: formattedText }} /&gt;; }; const handleStartDataIngestion = async () =&gt; { try { const messageData = {}; const response = await fetch('/api/startDataIngestion', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(messageData), }); if (response.ok) { setDataIngestionStatus('Data ingestion successful'); } else { setDataIngestionStatus('Data ingestion failed'); } } catch (error) { console.error('Error starting data ingestion:', error); setDataIngestionStatus('Internal server error'); } }; const handlesendMessage = async () =&gt; { try { const userMessage = { text: newMessage, user: 'You', }; setMessages((prevMessages) =&gt; [...prevMessages, userMessage]); const messageData = { message: newMessage, }; console.log('Sending message:', newMessage); const response = await fetch('/api/runQuery', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(messageData), }); if (response.ok) { const responseData = await response.json(); const responseText = responseData.response?.response || ''; setMessages((prevMessages) =&gt; [ ...prevMessages, { text: responseText, user: 'AriMa' }, ]); } else { setDataIngestionStatus('Failed to send message'); } } catch (error) { console.error('Error sending message:', error); setDataIngestionStatus('Internal server error'); } }; // Function to scroll to the bottom of the messages container const scrollToBottom = () =&gt; { if (messagesContainerRef.current) { messagesContainerRef.current.scrollTop = messagesContainerRef.current.scrollHeight; } }; // Scroll to the bottom on initial render and whenever messages change useEffect(() =&gt; { scrollToBottom(); }, [messages]); return ( &lt;div className="flex flex-col items-center justify-between h-screen p-8 bg-gray-800 text-white"&gt; &lt;div className="flex items-center justify-between w-full mb-8"&gt; &lt;button onClick={handleStartDataIngestion} className="px-4 py-2 text-white bg-green-500 rounded-md focus:outline-none" &gt; Start Data Ingestion &lt;/button&gt; &lt;/div&gt; &lt;div className="flex flex-col items-center justify-end flex-1 w-full mb-8 overflow-y-auto p-4"&gt; &lt;div ref={messagesContainerRef} className="flex flex-col"&gt; {messages.map((message, index) =&gt; ( &lt;div key={index} className="mb-2"&gt; &lt;span className="text-gray-400"&gt;{message.user}:&lt;/span&gt; {message.text} &lt;/div&gt; ))} &lt;/div&gt; &lt;/div&gt; &lt;div className="flex items-center justify-between w-full"&gt; &lt;input type="text" value={newMessage} onChange={(e) =&gt; setNewMessage(e.target.value)} placeholder="Type a message..." className="flex-1 px-4 py-2 mr-2 text-black bg-white rounded-md focus:outline-none" /&gt; &lt;button onClick={handlesendMessage} className="px-4 py-2 text-white bg-black rounded-md focus:outline-none" &gt; Send Message &lt;/button&gt; &lt;/div&gt; &lt;/div&gt; ); }; export default ChatApp;</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P><SPAN>Inside the app folder create another folder api and here create a folder as startDataIngestion and inside this create a file route.ts. The below code for this page api route will handle the data ingestion process</SPAN></P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-javascript"><code> // pages/api/data-ingestion.ts import type { NextApiRequest, NextApiResponse } from 'next'; import axios from 'axios'; import { NextResponse } from 'next/server'; interface Message { role: string; text: string; } export const POST = async (request: Request, res: NextResponse) =&gt; { try { const apiUrl = '&lt; url &gt;/api/DataIngestion'; const axiosRes = await axios.post(apiUrl); // You need to handle conversation storage or update here (use a database, state management, etc.) return NextResponse.json({ success: true, message: 'Data Ingestion Completed' }); } catch (error) { console.error('Error with API request:', error); return NextResponse.json({ success: false, message: 'Internal server error' }); } }</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P><SPAN>Create another folder under api as runQuery and route.ts file inside this with the below code. This code will call the Node JS API to run the SAP AI Core inference API we deployed earlier with the query we are submitting it from the UI</SPAN></P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-javascript"><code>// pages/api/runQuery.ts import type { NextApiRequest, NextApiResponse } from 'next'; import axios from 'axios'; import { NextResponse } from 'next/server'; interface Message { role: string; text: string; } export const POST = async (request: Request, res: NextResponse) =&gt; { try { const userInput = await request.json(); const systemPrompt = "Answer with high precision"; const fullPrompt = `&lt;|system|&gt;\n${systemPrompt}&lt;/s&gt;\n&lt;|user|&gt;\n${userInput.message}&lt;/s&gt;\n&lt;|assistant|&gt;`; // const fullPrompt = userInput.message; console.log(fullPrompt); const requestBody = { prompt: fullPrompt, args: {} }; const apiUrl = '&lt;url&gt;/api/getResponse'; const axiosRes = await axios.post(apiUrl, requestBody); const data = axiosRes.data; const generatedText = data; console.log('generated text:',generatedText); const newMessage: Message = { role: 'user', text: userInput, }; const newResponse: Message = { role: 'arima', text: generatedText, }; // You need to handle conversation storage or update here (use a database, state management, etc.) return NextResponse.json({ success: true, response: generatedText }); } catch (error) { console.error('Error with API request:', error); return NextResponse.json({ success: false, message: 'Internal server error' }); } } </code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P><SPAN>Kudos to if you made it this far, now onto the last part, implementation of server side API handling.</SPAN><BR /><SPAN>Create a folder&nbsp;</SPAN><EM>serverapi</EM><SPAN>&nbsp;under the parent folder zephyr-on-ai-core and inside this a file server.js with below code</SPAN></P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-javascript"><code>const express = require('express'); const axios = require('axios'); const cors = require('cors'); const request = require('request-promise'); const app = express(); const port = process.env.PORT || 3006; app.use(cors()); // Parse JSON in the request body app.use(express.json()); app.post('/api/getResponse', async (req, res) =&gt; { try { // Get OAuth token (replace with your actual credentials) const fs = require('fs'); // Specify the path to your service key file const serviceKeyPath = './config.json'; // Read the content of the file const serviceKeyContent = fs.readFileSync(serviceKeyPath, 'utf8'); const serviceKey = JSON.parse(serviceKeyContent); // Extract client ID and client secret const clientId = serviceKey.clientid; const clientSecret = serviceKey.clientsecret; const token = await getOAuthToken(clientId, clientSecret); // Make AI API call const response = await axios.post( 'https://&lt;url&gt;/v2/inference/deployments/d87531155571d6e8/v2/query', req.body, { headers: { Authorization: `Bearer ${token}`, 'ai-resource-group': 'default', 'Content-Type': 'application/json', }, } ); // res.json(response.data); // res.json(response.results); const responseBody = response.data.results.response; res.status(200).json({ success: true, response: responseBody }); } catch (error) { console.error('Error with API request:', error); res.status(500).json({ error: 'Internal Server Error' }); } }); app.post('/api/DataIngestion', async (req, res) =&gt; { try { // Get OAuth token (replace with your actual credentials) const fs = require('fs'); // Specify the path to your service key file const serviceKeyPath = './config.json'; // Read the content of the file const serviceKeyContent = fs.readFileSync(serviceKeyPath, 'utf8'); const serviceKey = JSON.parse(serviceKeyContent); // Extract client ID and client secret const clientId = serviceKey.clientid; const clientSecret = serviceKey.clientsecret; const token = await getOAuthToken(clientId, clientSecret); // Make AI API call const response = await axios.post( 'https://&lt;url&gt;/v2/inference/deployments/d87531155571d6e8/v2/DataIngestion', req.body, { headers: { Authorization: `Bearer ${token}`, 'ai-resource-group': 'default', 'Content-Type': 'application/json', }, } ); res.status(200).json({ success: 'Data Ingestion completed' }); } catch (error) { console.error('Error with API request:', error); res.status(500).json({ error: 'Internal Server Error' }); } }); app.listen(port, () =&gt; { console.log(`Server is running on port ${port}`); }); async function getOAuthToken(clientId, clientSecret) { const tokenUrl = '&lt;token_url&gt;/oauth/token'; try { const credentials = Buffer.from(`${clientId}:${clientSecret}`).toString('base64'); // Make a POST request to the token endpoint using request-promise const response = await request.post({ uri: tokenUrl, form: { grant_type: 'client_credentials', }, headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': `Basic ${credentials}`, }, json: true, // Automatically parses the response body as JSON }); // Check if the request was successful (status code 200) if (response) { // Access token is available in the response data const accessToken = response.access_token; return accessToken; } else { // Print the error details if the request was not successful console.error(`Error: ${response.status} - ${response.error_description}`); return null; } } catch (error) { // Handle exceptions, e.g., network errors console.error(`Error: ${error.message}`); return null; } }</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P class="">Package.json file for this node js with below code</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-json"><code>{ "name": "server", "version": "1.0.0", "description": "", "main": "server.js", "scripts": { "test": "echo \"Error: no test specified\" &amp;&amp; exit 1" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "axios": "^1.6.2", "cors": "^2.8.5", "express": "^4.18.2", "request-promise": "^4.2.6" } }</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P class="">and finally manifest.json file as below</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-json"><code>--- applications: - name: aicoreapirag path: . memory: 128M disk_quota: 250M</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P><SPAN>Let’s push this node js api to SAP BTP cloud foundry runtime with below command</SPAN></P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-bash"><code>cd serverapi cf login cf push</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P class="">Once the node js server side api is deployed successfully, we need to take the API URL from the BTP cockpit and use that URL in our frontend app code to call the server side api.</P><P class="">Now we are all set to push the Next JS app to cloud foundry with the below commands</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-bash"><code>cd ragui npm run build cf push</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P><SPAN>Let’s launch the chat app and ask it a query from the llama text pdf</SPAN><BR /><STRONG>Query 1: Can you tell me about the key concepts of supervised finetuning ?</STRONG></P><P><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="PuranK_25-1708966938590.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/71469iC99EA21FF5A9B012/image-size/large?v=v2&amp;px=999" role="button" title="PuranK_25-1708966938590.png" alt="PuranK_25-1708966938590.png" /></span></P><P><SPAN>Next query is from image based pdf which contained itemized remittance summary for patients</SPAN><BR /><STRONG>Query 2 : How much is the total Remittance Summary amount for the patient &lt;patient name&gt;?</STRONG></P><P><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="PuranK_26-1708967044353.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/71470iB9CC0A949CF658A1/image-size/large?v=v2&amp;px=999" role="button" title="PuranK_26-1708967044353.png" alt="PuranK_26-1708967044353.png" /></span></P><P class="">It’s a very basic UI chat app which works and serves the purpose of relaying the queries to LLM running on SAP AI Core and ingesting the data into vector database. You can also test the “Start Data Ingestion”, it works..</P><BLOCKQUOTE><P class=""><EM>Thank you for reading this article, Try the code yourself and let me know for any feedback, and if you enjoyed reading this article:</EM></P></BLOCKQUOTE><BLOCKQUOTE><P class="">A<EM>dvanced RAG references :</EM></P></BLOCKQUOTE><OL class=""><LI><A class="" href="https://towardsdatascience.com/advanced-rag-01-small-to-big-retrieval-172181b396d4" target="_blank" rel="noopener nofollow noreferrer">https://towardsdatascience.com/advanced-rag-01-small-to-big-retrieval-172181b396d4</A></LI><LI><A class="" href="https://pub.towardsai.net/advanced-rag-techniques-an-illustrated-overview-04d193d8fec6" target="_blank" rel="noopener ugc nofollow noreferrer">https://pub.towardsai.net/advanced-rag-techniques-an-illustrated-overview-04d193d8fec6</A></LI></OL><P>I published this article originally on Medium during the transition of SAP Community blogs</P><P><A href="https://medium.com/@purankhoeval/unlocking-the-power-of-sap-ai-core-building-a-rag-pipeline-with-llamaindex-036c3613b8c3" target="_blank" rel="noopener nofollow noreferrer">https://medium.com/@purankhoeval/unlocking-the-power-of-sap-ai-core-building-a-rag-pipeline-with-llamaindex-036c3613b8c3</A></P><P>&nbsp;</P> 2024-02-26T19:03:06.124000+01:00 https://community.sap.com/t5/technology-blogs-by-sap/set-up-sap-generative-ai-hub-in-an-sap-btp-enterprise-account-and-consume/ba-p/13624287 Set up SAP Generative AI Hub in an SAP BTP Enterprise Account and Consume Generative AI Model 2024-03-01T21:07:06.919000+01:00 MirelaB https://community.sap.com/t5/user/viewprofilepage/user-id/7971 <P>SAP Generative AI Hub is now available with the SAP AI Core extended service plan. By leveraging Generative AI Hub, SAP partners and customers can build AI-powered extensions and apps on SAP BTP.<BR />&nbsp;<BR />As part of the SAP AI Core, Generative AI Hub provides access to the most common large language models (LLMs) from different providers. To integrate an LLM via Generative AI Hub into an application, there are a few important steps to follow, that will be covered in this blog:</P><UL><LI>Create an SAP AI Core service instance.</LI><LI>Create an LLM configuration to reference a model provider specific executable.</LI><LI>Use the configuration to create a deployment.<BR />The configuration and deployment can be created either via the SAP AI Launchpad UI or using the SAP AI Core APIs.</LI><LI>For the created deployment, SAP AI Core provides a unique URL that can be used to access the LLM. Use this URL to infuse generative AI features into your application. Embedding the use of the URL into an application is not covered in this blog. Instead, the use of the deployment URL is demonstrated with Postman.</LI></UL><H1 id="toc-hId-858883036">Prerequisites</H1><UL><LI>You have an SAP BTP Enterprise Account.</LI><LI>You have an entitlement for SAP AI Core, Service Plan "Extended".</LI><LI>You have an entitlement for SAP AI Launchpad, Service Plan "Standard".</LI><LI>You have an entitlement and free quota for SAP BTP, Cloud Foundry Runtime.</LI></UL><H1 id="toc-hId-662369531">SAP AI Core Setup</H1><P>First, make sure with your global account administrator that all services listed in the Prerequisites section have service plan quota assigned to your global account.</P><P>As subaccount administrator, go to the account level, Entitlements -&gt; Entity Assignments screen and select your subaccount. Click Edit, then Add Service Plans to configure entitlement.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="I821210_0-1709231673726.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/73619iB04C2EEB537F5CCA/image-size/large?v=v2&amp;px=999" role="button" title="I821210_0-1709231673726.png" alt="I821210_0-1709231673726.png" /></span></P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="I821210_1-1709231673733.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/73618i0CF139411E25D618/image-size/large?v=v2&amp;px=999" role="button" title="I821210_1-1709231673733.png" alt="I821210_1-1709231673733.png" /></span></P><P>Add 1 unit quota for the extended service plan then save entitlements update.</P><H2 id="toc-hId-594938745"><FONT size="4">Create SAP AI Core Service Instance</FONT></H2><P>Navigate to your subaccount and select Services -&gt; Instances and Subscriptions. Click on Create. Fill out the fields as shown below and click Create.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="I821210_2-1709231673738.png" style="width: 400px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/73617i4C8AAD79613D575E/image-size/medium?v=v2&amp;px=400" role="button" title="I821210_2-1709231673738.png" alt="I821210_2-1709231673738.png" /></span></P><P>In case you have an existing standard plan service instance, the creation will fail as shown below.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="I821210_3-1709231673749.png" style="width: 400px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/73621i3181B7007D198045/image-size/medium?v=v2&amp;px=400" role="button" title="I821210_3-1709231673749.png" alt="I821210_3-1709231673749.png" /></span></P><P>Update existing SAP AI Core service instance instead. For that, go back to Services -&gt; Instances and Subscriptions and search for the SAP AI Core standard service plan service instance. Click on Update button illustrated below:</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="I821210_4-1709231673755.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/73620i3B7BC16E6D7B60BA/image-size/large?v=v2&amp;px=999" role="button" title="I821210_4-1709231673755.png" alt="I821210_4-1709231673755.png" /></span></P><P>In the next screen, select extended plan instead of the standard plan and Update Instance.</P><H2 id="toc-hId-398425240"><FONT size="4">Create Service Key</FONT></H2><P>On the Instances and Subscriptions screen, find your SAP AI Core service instance and choose Create Service Key from the three dots dropdown.</P><P>Enter the name and click Create.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="I821210_5-1709231673760.png" style="width: 400px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/73622iB707FDBC153F546D/image-size/medium?v=v2&amp;px=400" role="button" title="I821210_5-1709231673760.png" alt="I821210_5-1709231673760.png" /></span></P><P>Download and store your service key json file locally. You will use it in the next steps.</P><H1 id="toc-hId-72829016">&nbsp;</H1><H1 id="toc-hId--123684489"><FONT size="6">SAP AI Launchpad Setup</FONT></H1><P>As subaccount administrator, go to the account level, Entitlements -&gt; Entity Assignments screen and select your subaccount. Click Edit, then Add Service Plans to configure entitlement.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="I821210_6-1709231673769.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/73625i040F515067C65017/image-size/large?v=v2&amp;px=999" role="button" title="I821210_6-1709231673769.png" alt="I821210_6-1709231673769.png" /></span></P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="I821210_7-1709231673775.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/73623i59234BAB1AA7B02E/image-size/large?v=v2&amp;px=999" role="button" title="I821210_7-1709231673775.png" alt="I821210_7-1709231673775.png" /></span></P><P>Add 1 unit quota for the standard service plan then save entitlements update.</P><H2 id="toc-hId--191115275"><FONT size="4">Subscribe to SAP AI Launchpad</FONT></H2><P>SAP AI Launchpad is a SaaS application, and you need to subscribe to it. Follow these SAP Help steps to create a subscription: <A href="https://help.sap.com/docs/ai-launchpad/sap-ai-launchpad/subscribe-to-sap-ai-launchpad" target="_blank" rel="noopener noreferrer">https://help.sap.com/docs/ai-launchpad/sap-ai-launchpad/subscribe-to-sap-ai-launchpad</A></P><H2 id="toc-hId--387628780"><FONT size="4">Set up User Access to SAP AI Launchpad</FONT></H2><P>In your subaccount go to Security -&gt; Users and select your user. Assign role collections as required. Follow these SAP Help steps: <A href="https://help.sap.com/docs/ai-launchpad/sap-ai-launchpad/allow-access-to-sap-ai-launchpad" target="_blank" rel="noopener noreferrer">https://help.sap.com/docs/ai-launchpad/sap-ai-launchpad/allow-access-to-sap-ai-launchpad</A></P><P>If you want access to Generative AI Hub features, don’t assign role collections containing “without_genai”. If you want to be editor for specific features, assign only the editor role collections, and not both, viewer and editor role collections for that feature.</P><H1 id="toc-hId--713225004">&nbsp;</H1><H1 id="toc-hId--909738509">Create Connection between SAP AI Launchpad and SAP AI Core</H1><P>Following subscription, you’ll be able to launch SAP AI Launchpad application. Go to Instances and Subscriptions screen in your subaccount. You’ll see your SAP AI Launchpad application under the Subscriptions. Click on it to open it.</P><P>Workspaces app is used to manage connections between SAP AI Launchpad and AI runtimes such as SAP AI Core. AI runtimes provide resources to process AI activities such as training and inference.</P><P>In the Workspaces, you need to add a new AI API connection. Click on Add and fill out the fields as shown below. Under the Service Key field, click the upload symbol to upload the SAP AI Core service key json file that you stored locally as per Create Service Key section.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MirelaB_0-1709234819035.png" style="width: 400px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/73650iB7085171E9C09D97/image-size/medium?v=v2&amp;px=400" role="button" title="MirelaB_0-1709234819035.png" alt="MirelaB_0-1709234819035.png" /></span></P><P>Click on Create and the connection will be established as shown below.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="I821210_9-1709231673789.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/73628i7D395611B4D599F5/image-size/large?v=v2&amp;px=999" role="button" title="I821210_9-1709231673789.png" alt="I821210_9-1709231673789.png" /></span></P><P>You also need to select a resource group so that you can perform ML Operations tasks. Resource groups represent a virtual collection of related resources within the scope of your AI runtime. Runtime entities such as executions, deployments, configurations, and artifacts belong to a specific resource group and are not shared across resource groups.</P><P>During subscription to SAP AI Launchpad, when your tenant is onboarded, a default resource group is automatically created. For your connection, you can select the default resource group as shown in the picture above.</P><H1 id="toc-hId--336511931">&nbsp;</H1><H1 id="toc-hId--533025436">Create a Configuration</H1><P>To be able to deploy and consume LLMs you first need to create a configuration that will reference a model provider specific executable.</P><P>An executable is used to define training or serving pipelines for an AI use case. An executable that is used to serve (deploy) an AI model is called a serving executable.</P><P>Access to the LLMs is provided under the global AI scenario foundation-models, which is managed by SAP AI Core. Individual models are provided as executables in the form of serving templates and accessed by choosing the corresponding template for the desired model.</P><P>See models that are currently supported here:</P><P><A href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/models-and-scenarios-in-generative-ai-hub" target="_blank" rel="noopener noreferrer">https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/models-and-scenarios-in-generative-ai-hub</A></P><P>In SAP AI Launchpad, go to ML Operations -&gt; Configurations and click Create.</P><P>Give your configuration a name, select the foundation-models scenario and the version, and select the serving executable.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="I821210_24-1709232222205.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/73637i63A66C19FC7B4E6D/image-size/large?v=v2&amp;px=999" role="button" title="I821210_24-1709232222205.png" alt="I821210_24-1709232222205.png" /></span></P><P>Click Next to enter Input Parameters.</P><P>Select model name you want to deploy. See model version in the link provided above. Note that the model version can be given as latest. If the model version is not specified, it will be set to latest by default.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="I821210_25-1709232251899.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/73638i997C1DF26C3D2678/image-size/large?v=v2&amp;px=999" role="button" title="I821210_25-1709232251899.png" alt="I821210_25-1709232251899.png" /></span></P><P>Click on&nbsp;Next&nbsp;-&gt;&nbsp;Review&nbsp;-&gt;&nbsp;Create&nbsp;to create the configuration.</P><P>When you now click on ML Operations -&gt; Configurations on the left-hand side menu, you’ll see the created configuration.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="I821210_12-1709231673804.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/73629iAAA32B9973909A78/image-size/large?v=v2&amp;px=999" role="button" title="I821210_12-1709231673804.png" alt="I821210_12-1709231673804.png" /></span></P><H1 id="toc-hId--729538941">&nbsp;</H1><H1 id="toc-hId--926052446">Create a Deployment</H1><P>A deployment runs a model for serving (inferencing) purposes.</P><P>A serving executable is an AI pipeline that serves or deploys a model for online predictions. As we saw in the previous section, you use a configuration to specify values for the serving executable, such as the model as an input artifact. The configuration is then used to create a deployment.</P><P>A running deployment can only reference one configuration. Multiple deployments can be created using the same configuration, resulting in separate endpoints for online predictions.</P><P>You use SAP AI Launchpad to create deployments for your runtime connection. Deployments that are implemented on an SAP AI Core runtime produce HTTPS endpoints. These endpoints can be used to access the LLM.</P><P>Following the previous step, click on the created configuration, then on Create Deployment.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="I821210_26-1709232485025.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/73639iAC73A4706C0FC13A/image-size/large?v=v2&amp;px=999" role="button" title="I821210_26-1709232485025.png" alt="I821210_26-1709232485025.png" /></span></P><P>Keep Duration as Standard and click on Review then Create to create the deployment.</P><P>Once the deployment created, wait for the current status to be set to RUNNING.</P><P>It could take a few minutes for the deployment to go from UNKNOWN status to RUNNING status.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="I821210_27-1709232538461.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/73640iE39423F085394BF6/image-size/large?v=v2&amp;px=999" role="button" title="I821210_27-1709232538461.png" alt="I821210_27-1709232538461.png" /></span></P><P>Take note of the deployment URL as you will use it in the next section.</P><P>Please note that both, the configuration and the deployment can also be created by using SAP AI Core APIs. See the API Reference on the SAP Business Accelerator Hub <A href="https://api.sap.com/api/AI_CORE_API/resource/Configuration" target="_blank" rel="noopener noreferrer">https://api.sap.com/api/AI_CORE_API/resource/Configuration</A><SPAN>, </SPAN></P><P><SPAN>and <A href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/create-deployment-for-generative-ai-model-in-sap-ai-core#using-the-api" target="_blank" rel="noopener noreferrer">https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/create-deployment-for-generative-ai-model-in-sap-ai-core#using-the-api</A> for details. </SPAN>Use the AI_API_URL from your SAP AI Core service key as the "apiurl".</P><H2 id="toc-hId--1415968958"><FONT size="4">Consume Generative AI Models</FONT></H2><P>Now that you have a deployment running, you can run inference requests against it, and it will return the results from the LLM. LLMs have broad applicability for a range of natural language processing tasks, including text prediction and generation, content summary, translation, content classification and categorization, conversational AI and chatbots, etc.</P><P>Models from Azure OpenAI are accessed through a private instance of the chat-completion API.<BR />The endpoint to use is <STRONG>{{deploymentUrl}}/chat/completions?api-version={{api-version}}</STRONG>.<BR />For more info on this API and version to use, see <A href="https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#chat-completions" target="_blank" rel="noopener nofollow noreferrer">https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#chat-completions</A></P><P>With each inference request, you need to pass SAP AI Core access token and AI-Resource-Group key value in the header. To get a new token, use OAuth 2.0 client credentials grant type and find client ID, client secret and access token URL values in your SAP AI Core service key. See pictures below:</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MirelaB_1-1709235605736.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/73654i6AD6F1837302F631/image-size/large?v=v2&amp;px=999" role="button" title="MirelaB_1-1709235605736.png" alt="MirelaB_1-1709235605736.png" /></span></P><P>&nbsp;</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MirelaB_2-1709235623315.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/73655iFF15E22320148577/image-size/large?v=v2&amp;px=999" role="button" title="MirelaB_2-1709235623315.png" alt="MirelaB_2-1709235623315.png" /></span></P><P>The query is sent in the body of the request, under “messages”. There are other optional parameters that you can include, and for their definitions, see <A href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/consume-generative-ai-models-using-sap-ai-core" target="_blank" rel="noopener noreferrer">https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/consume-generative-ai-models-using-sap-ai-core</A></P><P>The picture below shows the body and response for a text summarizing request. For more examples and details, see the same link above.</P><DIV class=""><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MirelaB_3-1709235646828.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/73656i9A5F80C3B729BBD2/image-size/large?v=v2&amp;px=999" role="button" title="MirelaB_3-1709235646828.png" alt="MirelaB_3-1709235646828.png" /></span><P>&nbsp;</P><P>&nbsp;</P><SPAN>In conclusion, all the steps covered in this blog are prerequisites to integrating an LLM via SAP Generative AI Hub into extensions and applications built on SAP BTP, with the purpose of adding generative AI features and functionalities to your application. Embedding the use of deployment URL programmatically into your application can be at the basis of building such functionalities.</SPAN><BR /><P>&nbsp;</P></DIV><P>&nbsp;</P><P>If you are a partner that needs structured support in building your solutions on SAP BTP, check out our Co-Innovated with SAP service: <A href="https://partnerbenefitscatalog.sap.com/Partner-Benefits-Catalog/Innovation/Co-Innovated-with-SAP-Service/p/1000260?siteUid=PartnerMarketplace&amp;siteName=Partner+Marketplace&amp;isProductReferences=true" target="_blank" rel="noopener noreferrer">Co-Innovated with SAP Service | Innovation | Partner Benefits Catalog | Partner Marketplace</A></P><P>If you need additional details, reach out to us at <A href="mailto:coinnovate@sap.com" target="_blank" rel="noopener nofollow noreferrer">coinnovate@sap.com</A>.</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P> 2024-03-01T21:07:06.919000+01:00 https://community.sap.com/t5/artificial-intelligence-and-machine-learning-blogs/fantastic-sap-ai-sdks-and-where-to-find-them/ba-p/13610510 Fantastic SAP AI SDKs and where to find them 2024-03-19T14:42:07.467000+01:00 MarioDeFelipe https://community.sap.com/t5/user/viewprofilepage/user-id/13491 <P><SPAN>In today's fast-paced digital landscape, businesses are increasingly turning to artificial intelligence (AI) to gain a competitive edge. SAP has recognized this trend and has developed a suite of powerful SDKs (Software Development Kits) to help organizations seamlessly integrate AI capabilities into their applications and workflows. In this blog post, we will explore the different SAP AI SDKs, their functionalities, and the value they bring to customers and if I miss any of them, let me know!</SPAN></P><P>&nbsp;</P><H1 id="toc-hId-857843010"><SPAN>SAP AI Core SDK</SPAN></H1><P>&nbsp;</P><P><SPAN>The [SAP AI Core SDK](<A href="https://pypi.org/project/ai-core-sdk/" target="_blank" rel="noopener nofollow noreferrer">https://pypi.org/project/ai-core-sdk/</A>) is a Python-based SDK that allows developers to access and interact with the SAP AI Core service using Python methods and data structures. This SDK provides a comprehensive set of tools to manage AI scenarios and workflows within SAP AI Core.</SPAN></P><P>&nbsp;</P><TABLE><TBODY><TR><TD width="790.391px" height="30px"><STRONG>AI Core Key Features</STRONG></TD></TR><TR><TD width="157.139px" height="57px"><SPAN>Scenario Management</SPAN></TD><TD width="633.252px" height="57px"><SPAN>Create, update, and manage AI scenarios and executables.</SPAN></TD></TR><TR><TD width="157.139px" height="57px"><SPAN>Workflow Execution</SPAN></TD><TD width="633.252px" height="57px"><SPAN>Execute pipelines as batch jobs for tasks such as preprocessing, training models, or performing batch inference.</SPAN></TD></TR><TR><TD width="157.139px" height="57px"><SPAN>Model Deployment</SPAN></TD><TD width="633.252px" height="57px"><SPAN>Deploy trained machine learning models as web services to serve high-performance inference requests.</SPAN></TD></TR><TR><TD width="157.139px" height="57px"><SPAN>Infrastructure Integration</SPAN></TD><TD width="633.252px" height="57px"><SPAN>Register Docker registries, synchronize AI content from Git repositories, and register object stores for training data and models.</SPAN></TD></TR><TR><TD width="157.139px" height="30px"><SPAN>Metrics Tracking</SPAN></TD><TD width="633.252px" height="30px"><SPAN>Log and track metrics within workflow executions for monitoring and analysis.</SPAN></TD></TR></TBODY></TABLE><P>&nbsp;</P><P><SPAN>The SAP AI Core SDK simplifies the development process by providing a unified interface to interact with SAP AI Core. This enables developers to focus on building and deploying AI solutions without worrying about the underlying infrastructure complexities.</SPAN></P><P><SPAN><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Captura de pantalla 2024-03-18 a las 16.11.57.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/82489i645FD19EB02A40E2/image-size/large?v=v2&amp;px=999" role="button" title="Captura de pantalla 2024-03-18 a las 16.11.57.png" alt="Captura de pantalla 2024-03-18 a las 16.11.57.png" /></span></SPAN></P><P>&nbsp;K<SPAN>ey GitHub repositories that leverage the SAP AI SDKs:</SPAN></P><P><SPAN>[SAP-samples/ai-core-samples](<A href="https://github.com/SAP-samples/ai-core-samples" target="_blank" rel="noopener nofollow noreferrer">https://github.com/SAP-samples/ai-core-samples</A>)</SPAN></P><P>&nbsp;</P><P><SPAN>This repository contains sample code and examples of the SAP AI Core SDK that can be used to interact with SAP AI Core. It demonstrates how to create clients, manage resource groups, track metrics during training, and deploy inference services.</SPAN></P><P><SPAN>[SAP-samples/azure-openai-aicore-cap-api](<A href="https://github.com/SAP-samples/azure-openai-aicore-cap-api" target="_blank" rel="noopener nofollow noreferrer">https://github.com/SAP-samples/azure-openai-aicore-cap-api</A>)</SPAN></P><P><SPAN>This repository shows how to deploy an inference service on SAP AI Core that acts as a proxy for Azure OpenAI Services. It leverages the SAP AI Core SDK to create and manage the necessary resources.</SPAN></P><P><SPAN>[SAP-samples/aicore-multioutput-regression-restaurant-inspections](<A href="https://github.com/SAP-samples/aicore-multioutput-regression-restaurant-inspections" target="_blank" rel="noopener nofollow noreferrer">https://github.com/SAP-samples/aicore-multioutput-regression-restaurant-inspections</A>)</SPAN></P><P><SPAN>This repository demonstrates a machine learning service that leverages the capabilities of SAP BTP (SAP AI Core and SAP AI Launchpad) for criticality assessments, likely using the SAP AI Core SDK.</SPAN></P><P><SPAN>[SAP-samples/teched2023-AI269](<A href="https://github.com/SAP-samples/teched2023-AI269" target="_blank" rel="noopener nofollow noreferrer">https://github.com/SAP-samples/teched2023-AI269</A>)</SPAN></P><P><SPAN>This repository contains materials for a TechEd session on prompt engineering with the SAP Generative AI Hub, suggesting the use of the SAP Generative AI Hub SDK.</SPAN></P><P>[SAP-samples/teched2023-AI266](<A href="https://github.com/SAP-samples/teched2023-AI266" target="_blank" rel="noopener nofollow noreferrer">https://github.com/SAP-samples/teched2023-AI266</A>)</P><P><SPAN>This repository provides a hands-on lab for working with SAP AI Core and SAP AI Launchpad, likely leveraging the SAP AI Core SDK and AI API Client SDK.</SPAN></P><P><SPAN>These repositories cover various use cases, such as interacting with SAP AI Core, deploying inference services, leveraging generative AI models, and integrating with other services like Azure OpenAI. They serve as valuable resources for developers looking to leverage the capabilities of SAP's AI SDKs in their projects.</SPAN></P><H1 id="toc-hId-661329505"><SPAN>AI API Client SDK</SPAN></H1><P><SPAN>The [AI API Client SDK](<A href="https://pypi.org/project/ai-api-client-sdk/" target="_blank" rel="noopener nofollow noreferrer">https://pypi.org/project/ai-api-client-sdk/</A>) is a Python library that allows developers to interact with the AI API, a standardized interface for managing the AI scenario lifecycle across different runtimes, including SAP AI Core and other partner technologies.</SPAN></P><P>&nbsp;</P><TABLE><TBODY><TR><TD width="790.391px" height="30px"><STRONG>AI API Client Key Features</STRONG></TD></TR><TR><TD width="157.139px" height="57px"><SPAN>Scenario Lifecycle Management</SPAN></TD><TD width="633.252px" height="57px"><SPAN>Create, update, and manage AI scenarios, executables, and configurations.</SPAN></TD></TR><TR><TD width="157.139px" height="57px"><SPAN>Execution Management</SPAN></TD><TD width="633.252px" height="57px"><SPAN>Trigger and monitor AI workflow executions</SPAN></TD></TR><TR><TD width="157.139px" height="57px"><SPAN>Model Management</SPAN></TD><TD width="633.252px" height="57px"><SPAN>Deploy, update, and undeploy machine learning models for serving inference requests.</SPAN></TD></TR><TR><TD width="157.139px" height="57px"><SPAN>Runtime Agnostic</SPAN></TD><TD width="633.252px" height="57px"><P><SPAN>Interact with AI scenarios across multiple runtimes, including SAP AI Core and partner technologies.</SPAN></P></TD></TR></TBODY></TABLE><P><SPAN>The AI API Client SDK provides a consistent and unified way to manage AI assets, regardless of the underlying runtime environment. This abstraction layer simplifies the development process and promotes portability, allowing organizations to leverage AI capabilities across different platforms and technologies.</SPAN></P><P>&nbsp;</P><H1 id="toc-hId-464816000"><SPAN>SAP Generative AI Hub SDK</SPAN></H1><P>&nbsp;</P><P><SPAN>The [SAP Generative AI Hub SDK](<A href="https://pypi.org/project/generative-ai-hub-sdk/" target="_blank" rel="noopener nofollow noreferrer">https://pypi.org/project/generative-ai-hub-sdk/</A>) is a Python library that enables developers to interact with the SAP Generative AI Hub, a platform that provides access to a broad range of large language models (LLMs) from various providers, such as GPT-4 by Azure OpenAI or open-source models like Falcon-40b.</SPAN></P><P>&nbsp;</P><TABLE><TBODY><TR><TD width="790.391px" height="30px"><STRONG>Generative AI Hub Key Features</STRONG></TD></TR><TR><TD width="157.139px" height="57px"><SPAN>LLM Access</SPAN></TD><TD width="633.252px" height="57px">&nbsp;Submit prompts to multiple LLMs and compare the generated outcomes to identify the best-suited model for a given task.</TD></TR><TR><TD width="157.139px" height="57px"><SPAN>Prompt Engineering</SPAN></TD><TD width="633.252px" height="57px">&nbsp;Leverage tooling for prompt engineering, experimentation, and other capabilities to accelerate the development of applications infused with generative AI.</TD></TR><TR><TD width="157.139px" height="57px"><SPAN>Prompt History</SPAN></TD><TD width="633.252px" height="57px">&nbsp;Gain greater control and transparency with built-in prompt history tracking.</TD></TR><TR><TD width="157.139px" height="57px"><SPAN>Secure and Trusted</SPAN></TD><TD width="633.252px" height="57px">&nbsp;Access LLMs in a secure and trusted environment, ensuring compliance and data privacy.</TD></TR></TBODY></TABLE><P>&nbsp;</P><P><SPAN>The SAP Generative AI Hub SDK empowers developers to harness the power of generative AI, enabling them to create innovative applications that leverage the capabilities of state-of-the-art language models while maintaining control, transparency, and compliance.</SPAN></P><P><SPAN><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Captura de pantalla 2024-03-18 a las 16.13.38.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/82490i9CC67420BD25BEF7/image-size/large?v=v2&amp;px=999" role="button" title="Captura de pantalla 2024-03-18 a las 16.13.38.png" alt="Captura de pantalla 2024-03-18 a las 16.13.38.png" /></span></SPAN></P><P>&nbsp;</P><P><STRONG>[SAP-samples/btp-generative-ai-hub-use-cases](<A href="https://github.com/SAP-samples/btp-generative-ai-hub-use-cases" target="_blank" rel="noopener nofollow noreferrer">https://github.com/SAP-samples/btp-generative-ai-hub-use-cases</A></STRONG><STRONG>)</STRONG></P><P><SPAN>This repository contains samples on how to build industry solutions leveraging generative AI capabilities on top of SAP BTP, integrated with SAP S/4HANA Cloud. It likely utilizes the SAP Generative AI Hub SDK.</SPAN></P><P>&nbsp;</P><H1 id="toc-hId-268302495"><SPAN>AI Core LLM</SPAN></H1><P><SPAN>The [AI Core LLM](<A href="https://pypi.org/project/sap-ai-core-llm/" target="_blank" rel="noopener nofollow noreferrer">https://pypi.org/project/sap-ai-core-llm/</A>) is a Python library that provides a unified interface for interacting with large language models (LLMs) deployed on SAP AI Core. This SDK abstracts away the complexities of working with different LLM providers and models, allowing developers to focus on building applications that leverage the power of language models.</SPAN></P><P>&nbsp;</P><TABLE><TBODY><TR><TD width="790.391px" height="30px"><STRONG>AI Core LLM Key Features</STRONG></TD></TR><TR><TD width="157.139px" height="57px"><SPAN>LLM Integration</SPAN></TD><TD width="633.252px" height="57px">&nbsp;Seamlessly integrate LLMs from various providers, such as OpenAI, Anthropic, and others, into your applications.</TD></TR><TR><TD width="157.139px" height="57px"><SPAN>Unified Interface</SPAN></TD><TD width="633.252px" height="57px">&nbsp;Interact with different LLMs using a consistent and standardized API, simplifying development and promoting code reusability.</TD></TR><TR><TD width="157.139px" height="57px"><SPAN>Prompt Management</SPAN></TD><TD width="633.252px" height="57px">&nbsp;Manage and version-control prompts, enabling efficient collaboration and reproducibility.</TD></TR><TR><TD width="157.139px" height="57px"><SPAN>Monitoring and Logging</SPAN></TD><TD width="633.252px" height="57px">&nbsp;Monitor and log LLM interactions for auditing, debugging, and performance analysis.</TD></TR></TBODY></TABLE><P><SPAN>The AI Core LLM SDK streamlines the development process by providing a unified interface for working with LLMs, enabling developers to leverage the power of language models without being tied to specific providers or models.</SPAN></P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarioDeFelipe_0-1710770775666.png" style="width: 400px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/82457i375A8CA4D6EC1D17/image-size/medium?v=v2&amp;px=400" role="button" title="MarioDeFelipe_0-1710770775666.png" alt="MarioDeFelipe_0-1710770775666.png" /></span></P><H1 id="toc-hId-71788990"><SPAN>Conclusion</SPAN></H1><P><SPAN>SAP's suite of AI SDKs empowers organizations to unlock the full potential of artificial intelligence and seamlessly integrate AI capabilities into their applications and workflows. From managing AI scenarios and workflows to deploying machine learning models and leveraging the power of generative AI, these SDKs provide a comprehensive set of tools and utilities to accelerate AI adoption and drive innovation.</SPAN></P><H3 id="toc-hId-133440923"><SPAN>Citations</SPAN></H3><P><SPAN><A href="https://github.com/SAP-docs/sap-artificial-intelligence/tree/main" target="_blank" rel="noopener nofollow noreferrer">https://github.com/SAP-docs/sap-artificial-intelligence/tree/main</A></SPAN></P><P><SPAN><A href="https://pages.community.sap.com/topics/ai-core-artificial-intelligence" target="_blank" rel="noopener noreferrer">https://pages.community.sap.com/topics/ai-core-artificial-intelligence</A></SPAN></P><P><SPAN><A href="https://community.sap.com/t5/technology-blogs-by-members/unleashing-the-power-of-sap-ai-launchpad-amp-sap-ai-core-create-your-first/ba-p/13583759" target="_blank">https://community.sap.com/t5/technology-blogs-by-members/unleashing-the-power-of-sap-ai-launchpad-amp-sap-ai-core-create-your-first/ba-p/13583759</A></SPAN></P><P><SPAN><A href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/libraries-and-sdks" target="_blank" rel="noopener noreferrer">https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/libraries-and-sdks</A></SPAN></P><P><SPAN><A href="https://community.sap.com/t5/technology-blogs-by-sap/what-s-new-in-sap-ai-core-sap-ai-launchpad-in-q2-2022/ba-p/13526476" target="_blank">https://community.sap.com/t5/technology-blogs-by-sap/what-s-new-in-sap-ai-core-sap-ai-launchpad-in-q2-2022/ba-p/13526476</A></SPAN></P><P><SPAN><A href="https://community.sap.com/t5/technology-blogs-by-members/understanding-generative-ai-core-concepts/ba-p/13574898" target="_blank">https://community.sap.com/t5/technology-blogs-by-members/understanding-generative-ai-core-concepts/ba-p/13574898</A></SPAN></P><P><SPAN><A href="https://help.sap.com/docs/sap-ai-core" target="_blank" rel="noopener noreferrer">https://help.sap.com/docs/sap-ai-core</A></SPAN></P><P><SPAN><A href="https://www.linkedin.com/pulse/sap-ai-core-sridevi-aduri-ibhxc" target="_blank" rel="noopener nofollow noreferrer">https://www.linkedin.com/pulse/sap-ai-core-sridevi-aduri-ibhxc</A></SPAN></P><P><SPAN><A href="https://api.sap.com/package/SAPAICore/overview" target="_blank" rel="noopener noreferrer">https://api.sap.com/package/SAPAICore/overview</A></SPAN></P><P><SPAN><A href="https://discovery-center.cloud.sap/serviceCatalog/sap-ai-core" target="_blank" rel="noopener nofollow noreferrer">https://discovery-center.cloud.sap/serviceCatalog/sap-ai-core</A></SPAN></P><P><SPAN><A href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/about-ai-api" target="_blank" rel="noopener noreferrer">https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/about-ai-api</A></SPAN></P><P><SPAN><A href="https://community.sap.com/t5/artificial-intelligence-and-machine-learning-blogs/sap-ai-core-sap-ai-launchpad-a-visual-introduction-part-1/ba-p/13543494" target="_blank">https://community.sap.com/t5/artificial-intelligence-and-machine-learning-blogs/sap-ai-core-sap-ai-launchpad-a-visual-introduction-part-1/ba-p/13543494</A></SPAN></P><P><SPAN><A href="https://github.com/SAP-samples/ai-core-samples" target="_blank" rel="noopener nofollow noreferrer">https://github.com/SAP-samples/ai-core-samples</A></SPAN></P><P><SPAN><A href="https://learning.sap.com/learning-journey/learning-how-to-use-the-sap-ai-core-service-on-sap-business-technology-platform/configuring-sap-ai-core-and-sap-ai-launchpad_a51c5214-d9ab-4f22-bc81-b683d09697fc" target="_blank" rel="noopener noreferrer">https://learning.sap.com/learning-journey/learning-how-to-use-the-sap-ai-core-service-on-sap-business-technology-platform/configuring-sap-ai-core-and-sap-ai-launchpad_a51c5214-d9ab-4f22-bc81-b683d09697fc</A></SPAN></P><P><SPAN><A href="https://developers.sap.com/tutorials/ai-core-helloworld.html" target="_blank" rel="noopener noreferrer">https://developers.sap.com/tutorials/ai-core-helloworld.html</A></SPAN></P><P><SPAN><A href="https://github.com/SAP-samples/btp-generative-ai-hub-use-cases" target="_blank" rel="noopener nofollow noreferrer">https://github.com/SAP-samples/btp-generative-ai-hub-use-cases</A></SPAN></P><P><SPAN><A href="https://github.com/SAP-samples/aicore-multioutput-regression-restaurant-inspections/blob/main/mission/register-general-artifacts.md" target="_blank" rel="noopener nofollow noreferrer">https://github.com/SAP-samples/aicore-multioutput-regression-restaurant-inspections/blob/main/mission/register-general-artifacts.md</A></SPAN></P><P><SPAN><A href="https://github.com/SAP-samples/btp-generative-ai-hub-use-cases/activity" target="_blank" rel="noopener nofollow noreferrer">https://github.com/SAP-samples/btp-generative-ai-hub-use-cases/activity</A></SPAN></P><P><SPAN><A href="https://github.com/SAP-samples/azure-openai-aicore-cap-api" target="_blank" rel="noopener nofollow noreferrer">https://github.com/SAP-samples/azure-openai-aicore-cap-api</A></SPAN></P><P><SPAN><A href="https://github.com/appintheair/api-ai-android-sdk" target="_blank" rel="noopener nofollow noreferrer">https://github.com/appintheair/api-ai-android-sdk</A></SPAN></P><P><SPAN><A href="https://github.com/SAP-samples/btp-generative-ai-hub-use-cases/actions" target="_blank" rel="noopener nofollow noreferrer">https://github.com/SAP-samples/btp-generative-ai-hub-use-cases/actions</A></SPAN></P><P><SPAN><A href="https://github.com/SAP-samples/kyma-runtime-extension-samples" target="_blank" rel="noopener nofollow noreferrer">https://github.com/SAP-samples/kyma-runtime-extension-samples</A></SPAN></P><P><SPAN><A href="https://github.com/gregorwolf/bookshop-demo/blob/main/package.json" target="_blank" rel="noopener nofollow noreferrer">https://github.com/gregorwolf/bookshop-demo/blob/main/package.json</A></SPAN></P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarioDeFelipe_0-1710770775666.png" style="width: 400px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/82457i375A8CA4D6EC1D17/image-size/medium?v=v2&amp;px=400" role="button" title="MarioDeFelipe_0-1710770775666.png" alt="MarioDeFelipe_0-1710770775666.png" /></span></P> 2024-03-19T14:42:07.467000+01:00 https://community.sap.com/t5/technology-blogs-by-sap/predict-personalize-prosper-btp-ai-capabilities-redefining-retail/ba-p/13645171 Predict, Personalize, Prosper: BTP AI Capabilities Redefining Retail Intelligence - Part 3/3 2024-03-22T14:26:42.198000+01:00 dominic_r https://community.sap.com/t5/user/viewprofilepage/user-id/177367 <P>Welcome to the third part of our blog series where we explore how <STRONG>SAP Business Technology Platform</STRONG> <STRONG>(BTP)</STRONG> is revolutionizing retail by enabling predictive insights, personalized interactions and ultimately prosperity in the enterprise. In this part, we provide an overview of the BTP architecture and its transformative capabilities, focusing on key components such as the <STRONG>SAP HANA Vector Engine</STRONG>, <STRONG>SAP GenAI Hub</STRONG> and <STRONG>Cloud Foundry</STRONG>.<BR /><BR /></P><TABLE border="1"><TBODY><TR><TD><A href="https://blogs.sap.com/2023/12/11/predict-personalize-prosper-crafting-tomorrows-retail-experience-with-rag-part-1-3/" target="_self" rel="noopener noreferrer">Part 1 - Predict, Personalize, Prosper: Crafting Tomorrow's Retail Experience with RAG</A></TD></TR><TR><TD><A href="https://blogs.sap.com/2023/12/11/predict-personalize-prosper-reacts-decision-making-in-retail-part-2-3/" target="_self" rel="noopener noreferrer">Part 2 - Predict, Personalize, Prosper: ReAct's Decision-Making in Retail</A></TD></TR><TR><TD><A href="https://community.sap.com/t5/technology-blogs-by-sap/predict-personalize-prosper-btp-ai-capabilities-redefining-retail/ba-p/13645171" target="_self">Part 3 - Predict, Personalize, Prosper: BTP AI Capabilities Redefining Retail Intelligence</A></TD></TR></TBODY></TABLE><H2 id="toc-hId-989841590"><STRONG>Architectural overview of the BTP</STRONG></H2><P>The SAP Business Technology Platform (BTP) is a comprehensive suite of tools and services designed to help companies achieve greater flexibility, innovation and intelligence. At its core, BTP seamlessly integrates various components to provide a unified platform for application development, deployment and management. Leveraging the power of <STRONG>SAP HANA Vector Engine</STRONG>, <STRONG>SAP GenAI Hub</STRONG> and <STRONG>Cloud Foundry</STRONG>, BTP provides retailers with a solid foundation for AI-driven insights and personalized experiences. Below is an architecture overview showing the individual components of an <STRONG>AI Store Assistant</STRONG> mentioned above</P><P><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="AI Store Assistant Architecture" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/84937iD36B80EFE491B23A/image-size/large?v=v2&amp;px=999" role="button" title="dominic_r_0-1711097041932.png" alt="AI Store Assistant Architecture" /><span class="lia-inline-image-caption" onclick="event.preventDefault();">AI Store Assistant Architecture</span></span></P><P>Let's take a closer look at the individual components and highlight their capabilities to enable AI innovation</P><H2 id="toc-hId-793328085"><STRONG>SAP HANA Vector Engine</STRONG></H2><P>At the heart of BTP's AI capabilities is the SAP HANA Vector Engine, a high-performance database optimized for processing vector-based operations. In the context of retail, the <STRONG>SAP HANA Vector Engine</STRONG> serves as a powerhouse for storing embeddings and enables fast and efficient retrieval of relevant data. By using this engine, retailers can seamlessly access and analyze volumes of data understandable to <STRONG>Large Language Models (LLMs)</STRONG>, leading to predictive insights and personalized interactions.&nbsp;More information about the SAP HANA Vector Engine can <A href="https://community.sap.com/t5/technology-blogs-by-sap/sap-hana-cloud-s-vector-engine-announcement/ba-p/13577010" target="_self">be found here.</A></P><H2 id="toc-hId-596814580"><STRONG>SAP GenAI Hub</STRONG></H2><P>The SAP HANA Vector Engine is complemented by the SAP GenAI Hub, a comprehensive platform for the development and deployment of LLM-based AI models. With the GenAI Hub, retailers can access a variety of pre-trained language models and customize them to their specific requirements. With this feature, retailers can send prompts to various Large Language Models (such as&nbsp;<SPAN>GPT-4 by Azure OpenAI or OpenSource Falcon-40b</SPAN>) and use their advanced natural language processing capabilities to generate contextualized responses. The GenAI Hub can be deployed as part of the SAP AI Core. Further information can <A href="https://community.sap.com/t5/technology-blogs-by-sap/generative-ai-hub-out-now/ba-p/13580462" target="_self">be found here</A>.</P><H2 id="toc-hId-400301075"><STRONG>Cloud Foundry</STRONG></H2><P>To bring these capabilities to life, BTP leverages the power of <STRONG>Cloud Foundry</STRONG>, an open source <STRONG>platform-as-a-service (PaaS)</STRONG> environment. By deploying Python-based applications on Cloud Foundry, retailers can quickly develop and deploy AI-driven solutions. As an example, the use of Python frameworks such as <STRONG>Flask</STRONG> (web framework) and <STRONG>LangChain</STRONG> (AI framework) helps to quickly deploy scalable AI applications. In addition, Cloud Foundry provides retailers with the flexibility and scalability they need to adapt to changing business requirements.</P><H2 id="toc-hId-203787570"><STRONG>Example: AI Store Assistant</STRONG></H2><P>To illustrate this architecture in practice, we look at the AI Store Assistant - a revolutionary tool and proof-of-concept for improving operational activities in a store. The <STRONG>AI Store Assistant</STRONG> utilizes BTP's AI capabilities and integrates seamlessly with <STRONG>SAP S/4HANA</STRONG> and <STRONG>Industry Cloud</STRONG> (such as Omnichannel Promotion Pricing Service- OPPS) solutions to retrieve relevant data. Based on prompts generated by the SAP GenAI Hub, the AI Store Assistant can obtain information, make suggestions and ultimately perform these as follow-up actions. In the example below, a prediction can be made for certain product groups or actions can be created for expiring goods. The AI Store Assistant also has the option of providing charts and tables in addition to text.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="AI Store Assistant predicting sales revenue" style="width: 428px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/85092i827417F9D1FA8667/image-size/large?v=v2&amp;px=999" role="button" title="ai_store_assistant_revenue_promotion-ezgif.com-video-to-gif-converter.gif" alt="AI Store Assistant predicting sales revenue" /><span class="lia-inline-image-caption" onclick="event.preventDefault();">AI Store Assistant predicting sales revenue</span></span></P><H2 id="toc-hId-7274065"><STRONG>Conclusion</STRONG></H2><P>In summary, SAP Business Technology Platform is redefining retail intelligence by leveraging advanced AI capabilities to predict, personalize and prosper. Through the seamless integration of SAP HANA Vector Engine, SAP GenAI Hub and Cloud Foundry, the BTP enables retailers to gain new insights and innovation. As we move into the future of retail, let's continue to harness the transformative power of BTP to create personalized and impactful experiences for customers worldwide. Join us on this journey of innovation and discovery as we shape the future of retail intelligence together.</P> 2024-03-22T14:26:42.198000+01:00 https://community.sap.com/t5/technology-blogs-by-sap/augmenting-sap-btp-use-cases-with-ai-foundation-a-deep-dive-into-the/ba-p/13645289 Augmenting SAP BTP Use Cases with AI Foundation: A Deep Dive into the Generative AI Hub 2024-03-25T15:08:29.967000+01:00 Trinidad https://community.sap.com/t5/user/viewprofilepage/user-id/3013 <DIV class=""><DIV class=""><SPAN> Authors: </SPAN><A href="https://community.sap.com/t5/user/viewprofilepage/user-id/7024" target="_blank">Alice Magnani</A><SPAN>, </SPAN><A href="https://community.sap.com/t5/user/viewprofilepage/user-id/42191" target="_blank">Cesare Calabria</A><SPAN>, </SPAN><A href="https://community.sap.com/t5/user/viewprofilepage/user-id/2758" target="_blank">Jacob Tan</A><SPAN>, </SPAN><A href="https://community.sap.com/t5/user/viewprofilepage/user-id/4176" target="_blank">Mostafa Sharaf</A><SPAN>, </SPAN><A href="https://community.sap.com/t5/user/viewprofilepage/user-id/3013" target="_blank">Trinidad Martinez</A><SPAN>.</SPAN><DIV class="">&nbsp;</DIV></DIV></DIV><P>Generative AI is accelerating in the industry, with a McKinsey report stating that Generative AI could add between $2.6 trillion to $4.4 trillion in incremental value to the global economy annually. Companies globally are increasingly using Generative AI, with about one-third of them using it regularly in at least one business function.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Trinidad_0-1711012073586.png" style="width: 560px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/84227i4F16D20BFC742012/image-dimensions/560x257?v=v2" width="560" height="257" role="button" title="Trinidad_0-1711012073586.png" alt="Trinidad_0-1711012073586.png" /></span></P><P>At SAP, we integrate Generative AI technology with industry-specific data and process knowledge to create innovative AI capabilities for our applications. To illustrate how Generative AI can benefit businesses, in this blog we'll walk you through a citizen reporting app for the public administrations industry.</P><P>Our use case involves a fictitious city, "Sagenai City", struggling with managing and tracking maintenance in public areas. The city wants to improve how it handles reported issues from citizens by analyzing social media posts and making informed decisions. A better perception of public administration by citizens is an anticipated outcome.</P><P>The goal of the citizen reporting app is to assist the Maintenance Manager by extracting insights from citizen social posts, classifying them, and creating maintenance notifications in the SAP S/4 HANA Cloud tenant.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Trinidad_1-1711012125813.png" style="width: 571px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/84231iB6512F3CED64F838/image-dimensions/571x280?v=v2" width="571" height="280" role="button" title="Trinidad_1-1711012125813.png" alt="Trinidad_1-1711012125813.png" /></span></P><P>Let’s understand the Citizen Reporting App business flow:</P><OL><LI>A citizen reports an incident through a post on the city's community page on Reddit (we have used Reddit as having a rich and free API, but any social media of your choice can be chosen).</LI><LI>The citizen reporting app receives the post and notifies the responsible persons from the public administration office.</LI><LI>The post is then processed and analyzed by a Large Language Model through SAP’s Generative AI Hub to extract key points and derive insights such as summarizing the issue, identifying the issue type, its urgency level, determining the incident's location, and analyzing the sentiment behind the post.</LI><LI>The Maintenance Manager reviews the incident details extracted by Generative AI and decides whether to approve or reject the incident. As a result, the manager saves time through the reporting process, thanks to the powerful text analysis by Generative AI.</LI></OL><P>To demonstrate this in action please check the following demo video of the Citizen Reporting App, leveraging the power of SAP’s Generative AI.</P><P><A href="https://dam.sap.com/mac/u/a/ytKe6yD.htm?rc=10" target="_blank" rel="noopener noreferrer"><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-03-22 at 09.49.55.png" style="width: 567px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/86002i65F17163DD0A8E5E/image-dimensions/567x319?v=v2" width="567" height="319" role="button" title="Screenshot 2024-03-22 at 09.49.55.png" alt="Screenshot 2024-03-22 at 09.49.55.png" /></span></A></P><P>Before we go into details on how we implemented this proof of concept, let’s review some key concepts.</P><H2 id="toc-hId-989842590">LLM’s Overview</H2><P>Large Language Models (LLMs) have been making waves in the artificial intelligence (AI) landscape. These foundation models trained on broad datasets have expanded their influence beyond natural language to domains such as videos, speech, tabular data, and protein sequences.</P><H3 id="toc-hId-922411804">Understanding Large Language Models</H3><P>Foundation models, a term coined by Stanford researchers, are self-supervised models trained on vast datasets. They can be <SPAN>easily adapted</SPAN> <SPAN>t</SPAN>o a myriad of downstream tasks. Among these, Large Language Models (LLMs) focus on natural language in the form of text.</P><P><SPAN>In some cases, </SPAN>LLMs also exhibit impressive generative capabilities, making them suitable for creating novel content. They are often referred to as generative AI models.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Trinidad_2-1711012125816.png" style="width: 545px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/84230i3B9FDB77B43BE00D/image-dimensions/545x226?v=v2" width="545" height="226" role="button" title="Trinidad_2-1711012125816.png" alt="Trinidad_2-1711012125816.png" /></span></P><P>In this blog we will <SPAN>focus</SPAN> <SPAN>mainly </SPAN>on the LLMs application around Generative AI.</P><P><SPAN>These models leverage transfer learning, a concept that has been in use for decades in the image domain, on a much larger scale. The change of scale was made possible by a set of key-factors, such as improved computing capabilities, the advent of the transformer architecture, and the availability of massive datasets. As a consequence, these large models started to show new emerging capabilities. One of them is in-context learning, which allows to adapt the model to perform a certain task with no need for additional training, just giving instructions in human language in the form of text. This can reduce tremendously the time to value required to implement artificial intelligence for a wide set of tasks. </SPAN></P><P><SPAN>Also, </SPAN>LLMs are typically trained on the task of predicting the next word in a text. This approach requires the model to gain substantial knowledge about the world, making them a form of "lossy compression" of the information available on the internet.</P><H3 id="toc-hId-725898299"><SPAN>Limitations of </SPAN>Large Language Models</H3><P><SPAN>Despite their remarkable capabilities, LLMs come with some limitations. First of all, </SPAN>training these models is time-consuming and expensive. Furthermore, keeping the models' knowledge correct and updated is a challenge. They are also stochastic, meaning minor variations in the prompt can lead to different outputs. <SPAN>T</SPAN><SPAN>here is</SPAN> no way to verify the correctness of the models' answers<SPAN> and finally, they tend to prioritize form over content, so they can generate incorrect but plausible sounding answers.</SPAN></P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Trinidad_3-1711012125819.png" style="width: 400px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/84229iADDAE13577EABDD1/image-size/medium?v=v2&amp;px=400" role="button" title="Trinidad_3-1711012125819.png" alt="Trinidad_3-1711012125819.png" /></span></P><P><SPAN>With the current state of the art, LLMs can help solving many uses cases requiring language understanding and language generation. LLM struggle, instead, in logics and math, and with use cases that require analysis of numerical, structured data. </SPAN>In the following image we share some use case samples that we have classified into good LLM use case and not such a good case for LLMs.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Trinidad_4-1711012125823.png" style="width: 509px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/84233i50D57A9D0BBA43AF/image-dimensions/509x252?v=v2" width="509" height="252" role="button" title="Trinidad_4-1711012125823.png" alt="Trinidad_4-1711012125823.png" /></span></P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Trinidad_5-1711012125823.png" style="width: 163px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/84232iF0106F76BAA808CF/image-dimensions/163x42?v=v2" width="163" height="42" role="button" title="Trinidad_5-1711012125823.png" alt="Trinidad_5-1711012125823.png" /></span></P><H3 id="toc-hId-529384794">Adapting LLMs to Desired Tasks</H3><P>There are several strategies to adapt LLMs to the desired task<SPAN> and work-around some of their limitations. The most widely used are listed below:</SPAN></P><OL><LI>Prompt engineering.<BR />Prompt engineering is the process of designing and refining prompts or instructions given to a language model to elicit desired responses.<BR />The quality of the prompt can greatly help in improving the response <SPAN>model's accuracy, controlling its biases, or generating creative and coherent responses.<BR /><BR /></SPAN></LI><LI>Retrieval Augmented Generation (RAG).<BR />RAG idea is to provide the model with a knowledge base (a document or a corpus of documents) and ask it to answer our prompts based on these documents.<BR /><BR /></LI><LI>Fine-tuning.<BR />Fine-tuning refers to the process of taking a pre-trained model and adapting it to perform a specific task or on a specific dataset. In machine learning, models are typically trained on large datasets to learn general patterns and features. Fine-tuning <SPAN>allows </SPAN>to take advantage of this pre-trained knowledge and apply it to a more specific task or dataset.<BR />The costs involved in fine-tuning can be considerable as they might include computational resources, such as GPU or cloud computing costs, as well as the time and effort required to collect and preprocess data, train the model, and evaluate its performance.</LI></OL><H3 id="toc-hId-332871289">Choosing the Right LLM</H3><P>When choosing an LLM, it's important to consider factors like price, latency, and request limits. Latest and larger models are usually more capable and robust. Consider looking at model benchmarks and leaderboards, such as <A href="https://huggingface.co/spaces/lmsys/chatbot-arena-leaderboard" target="_blank" rel="noopener nofollow noreferrer">Chatbot Arena</A>, to compare the performance of different models.</P><H3 id="toc-hId-136357784">Evaluating LLMs</H3><P><SPAN>Before putting an LLM-based application into production, it is always best practice to test the </SPAN>performance of<SPAN> the</SPAN> LLM<SPAN> for your specific</SPAN><SPAN> task. To do that,</SPAN> you can come up with a sample of data points to test your model. Apply your LLM prompt in batch to the sample and then evaluate the LLM response accuracy. <SPAN>Sometimes, this operation can be challenging, maybe because of the lack of data points to use for testing, or because it is difficult to rate how good is the model output when a language-related task is involved. LLMs can be useful to overcome these challenges. For instance, you can ask an LLM to generate test data points for you. Also, you can use an LLM as a judge, to rate the quality of an LLM-generated text with the criteria that are important for you, for instance creativity, correctness, etc.</SPAN></P><P><STRONG>Libraries / LangChain<BR /></STRONG>There are libraries bridging the gap between traditional software development and Generative AI, to make it easier to implement generative AI technology in an application. Langchain is one of the most well-known but there are other options.</P><P><A href="https://www.langchain.com/" target="_blank" rel="noopener nofollow noreferrer">Langchain</A> is available for python and <SPAN>J</SPAN><SPAN>avascript</SPAN>, and it offers many templates to build prompt effectively, parsers to parse the response output, chains to build sequences of LLM operation, Agents, and model evaluation. Langchain can be used in combination with SAP tools for Generative AI, we will talk about it later in this blog.</P><H2 id="toc-hId--189238440">Overview on SAP’s Generative AI Hub</H2><P>Artificial Intelligence (AI) is revolutionizing every aspect of business, and at SAP, we are committed to harnessing this power to drive business transformation. Our focus is on Business AI, which means AI for every aspect of the business. We continuously strive to build the best technology and leverage the best tools on the market, including strategic partnerships with industry leaders.</P><H3 id="toc-hId--256669226">SAP Business AI Strategy</H3><P>Our <A href="https://www.sap.com/products/artificial-intelligence.html" target="_blank" rel="noopener noreferrer">SAP Business AI</A> strategy is embedded across various business domains including Finance, Supply Chain, HR, Procurement, Marketing and Commerce, Sales and Services, and IT. We offer a complete set of services that enable developers to create solutions with artificial intelligence. These services form the AI Foundation from which developers can pick whatever they need to build their AI- and generative AI-powered extensions and applications on SAP Business Technology Platform (SAP BTP).</P><H3 id="toc-hId--453182731">SAP BTP AI Portfolio</H3><P>Our AI portfolio includes <A href="https://pages.community.sap.com/topics/artificial-intelligence" target="_blank" rel="noopener noreferrer">SAP AI Services</A> to help you automate and optimize corporate processes by adding intelligence to your applications using AI models pretrained on business-relevant data. These services include document information extraction, document classification, personalized recommendations, data attribute recommendation, and translation of software texts and documents.</P><P>As we have <SPAN>seen,</SPAN> Generative AI, a form of artificial intelligence, can produce text, images, and varied content based on its training data. At SAP, we integrate <A href="https://www.sap.com/products/artificial-intelligence/generative-ai.html" target="_blank" rel="noopener noreferrer">Generative AI</A> with extensive industry-specific data and deep process knowledge to create innovative AI capabilities for the SAP applications you use every day. It’s built-in, relevant to your business, and responsible by design.</P><P>We also offer the <A href="https://blogs.sap.com/2023/12/21/generative-ai-hub-out-now/" target="_blank" rel="noopener noreferrer">Generative AI Hub</A>, which provides instant access to a broad range of large language models (LLMs) from different providers. The hub provides tooling for prompt engineering, experimentation, and other capabilities to accelerate the development of your SAP BTP applications infused with generative AI, in a secure and trusted way.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Trinidad_7-1711012125834.png" style="width: 584px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/84236iCDF88D2B9E047FB8/image-dimensions/584x308?v=v2" width="584" height="308" role="button" title="Trinidad_7-1711012125834.png" alt="Trinidad_7-1711012125834.png" /></span></P><H3 id="toc-hId--649696236">Generative AI Hub</H3><P>The <A href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/generative-ai-hub-in-sap-ai-core" target="_blank" rel="noopener noreferrer">Generative AI Hub</A> allows access to a large variety of foundation models, from the hosted or open-source ones to the proprietary and remote models and in the future also models built or fine-tuned by SAP.</P><P>The Generative AI Hub is a new SAP BTP capability offered across two different services: AI Core and AI Launchpad.</P><H3 id="toc-hId--921441110">Deployment of LLMs in SAP AI Core</H3><P>To consume the LLMs through SAP’s Generative AI Hub, we first need to deploy them in SAP AI Core (<A href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/create-deployment-for-generative-ai-model-in-sap-ai-core" target="_blank" rel="noopener noreferrer">Create a Deployment for a Generative AI Model</A>). &nbsp;We leverage AI Core capabilities to provide a standard model inference platform on Kubernetes and serve the LLMs taking care of security aspects, multi-tenancy support, ...</P><P>Check the <A href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/models-and-scenarios-in-generative-ai-hub" target="_blank" rel="noopener noreferrer">Models and Scenarios in the&nbsp;Generative AI Hub</A> up-to-date list of supported models.</P><H3 id="toc-hId--1117954615">Generative AI Hub Capabilities in SAP AI Launchpad</H3><P><A href="https://help.sap.com/docs/ai-launchpad/sap-ai-launchpad/generative-ai-hub" target="_blank" rel="noopener noreferrer">SAP AI Launchpad</A> provides a graphical interface for Generative AI Hub and from there several tools are provided for the developers. These include a playground system where developers can perform prompt engineering and test prompts against different LLMs, and Prompt Management features that allow storing and versioning prompts.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Trinidad_8-1711012125839.png" style="width: 586px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/84239iDE065FF9153A838D/image-dimensions/586x274?v=v2" width="586" height="274" role="button" title="Trinidad_8-1711012125839.png" alt="Trinidad_8-1711012125839.png" /></span></P><H3 id="toc-hId--1314468120">Generative AI Hub SDK</H3><P>The <A href="https://pypi.org/project/generative-ai-hub-sdk/" target="_blank" rel="noopener nofollow noreferrer">Generative AI Hub SDK</A> is a collection of tools, in addition to the existing ai-core-sdk, to support LLM access. It boosts efficiency when working with various LLM models by streamlining the deployment of LLM models and the querying of available models.</P><P><SPAN>At the time of writing this blog, </SPAN>only the Python version is <SPAN>made GA (Generable A</SPAN>vailable<SPAN>)</SPAN>, stay tuned for a JavaScript version!</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Trinidad_9-1711012125845.png" style="width: 548px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/84238iBB6796C98DCAF07B/image-dimensions/548x330?v=v2" width="548" height="330" role="button" title="Trinidad_9-1711012125845.png" alt="Trinidad_9-1711012125845.png" /></span></P><H2 id="toc-hId--1217578618">Deep Dive into the Citizen Reporting App Use Case</H2><P>In the previous sections, we've explored the concept of Generative AI and how SAP's Generative AI Hub can help you implement your own solutions. Now, we're going to delve deeper into our specific use case: the Citizen Reporting app.</P><H3 id="toc-hId--1707495130">Business Scenario</H3><P>The Citizen Reporting app is designed to streamline the process of incidents reporting in social media. The app leverages the capabilities of the Generative AI Hub to gain insights from citizens' social posts. This not only saves time for maintenance managers but also improves the public's perception of the administration.</P><P>The app allows maintenance managers to easily review and manage incidents, including AI insights and classification. Once the relevant incidents are supervised, the app creates Maintenance Notifications in the SAP S/4HANA Cloud tenant.</P><H3 id="toc-hId--1904008635">Solution Architecture</H3><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Trinidad_11-1711012125853.png" style="width: 579px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/84242i770BCDCAB14524A6/image-dimensions/579x291?v=v2" width="579" height="291" role="button" title="Trinidad_11-1711012125853.png" alt="Trinidad_11-1711012125853.png" /></span></P><P>The Citizen Reporting app consists of a server-side application that can be run in SAP BTP Cloud Foundry or Kyma runtime, and a user interface developed with SAP Build Apps. The server-side application provides all the APIs required to get data and start the execution of the actions required by the maintenance manager.</P><P>The server-side application consumes APIs from different BTP Services, including the SAP AI Core service, which provides Generative AI APIs from different foundation models in a trusted and controlled way.</P><P>The Destination service is used to securely connect to the SAP AI Core APIs as well as SAP S/4HANA Cloud APIs to automatically create Maintenance Requests after Maintenance Manager’s approval.</P><H3 id="toc-hId--2100522140">Implementation Steps</H3><P>Let’s go a bit deeper into the implementation by having a look to the different implementation steps:</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Trinidad_12-1711012125857.png" style="width: 557px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/84241iE6251C0EB1D5DAEE/image-dimensions/557x262?v=v2" width="557" height="262" role="button" title="Trinidad_12-1711012125857.png" alt="Trinidad_12-1711012125857.png" /></span></P><H3 id="toc-hId-1997931651">SAP BTP Setup</H3><P>To work with Generative AI hub in SAP Business Technology Platform, the first requirement is to have an SAP BTP sub account with an instance of SAP AI Core. The SAP AI Core instance will provide us with a set of APIs to consume Generative AI Hub from our implementation.</P><P>Once we have our instance of SAP AI Core, we can create instance of the SAP AI Launchpad to have access to a user interface to configure and manage our generative AI deployments.</P><P>As we saw in the architecture diagram, other SAP BTP services like the Cloud Foundry environment, the SAP HANA Cloud Service, <SPAN>SAP Authorization and Trust Management Service (XSUAA) &amp; </SPAN>Destinations Service<SPAN>, would be</SPAN> required for <SPAN>the </SPAN>application and <SPAN>the service instances </SPAN>will need to be created.</P><P><A href="https://dam.sap.com/mac/u/a/iN8jUpD.htm?rc=10" target="_blank" rel="noopener noreferrer"><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-03-25 at 14.50.16.png" style="width: 564px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/86008iBC4B8741C3EE1BFD/image-dimensions/564x318?v=v2" width="564" height="318" role="button" title="Screenshot 2024-03-25 at 14.50.16.png" alt="Screenshot 2024-03-25 at 14.50.16.png" /></span></A></P><H3 id="toc-hId-1801418146">Prompt Engineering</H3><P>Once <SPAN>y</SPAN>our SAP BTP account<SPAN> is</SPAN> ready, we will build the prompt to be sent to the Foundation Model. This is a very important phase to get accurate insights from SAP’s Generative AI Hub. The prompt engineering step is usually recursive and conducted with the help of tools like the AI Launchpad or a Jupiter Notebook, to test and fine-tune the prompt.</P><P>Let’s review how we built our prompt to get insights from the Citizen’s social media posts.</P><P><A href="https://dam.sap.com/mac/app/p/video/asset/preview/W4QJ7Ce?ltr=a&amp;rc=10" target="_blank" rel="noopener noreferrer"><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-03-25 at 14.52.08.png" style="width: 564px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/86010i1439732D049C5821/image-dimensions/564x340?v=v2" width="564" height="340" role="button" title="Screenshot 2024-03-25 at 14.52.08.png" alt="Screenshot 2024-03-25 at 14.52.08.png" /></span></A></P><H3 id="toc-hId-1604904641">Application Skeleton</H3><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Trinidad_13-1711012125862.png" style="width: 586px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/84245iEFF3FB52B6BF6858/image-dimensions/586x280?v=v2" width="586" height="280" role="button" title="Trinidad_13-1711012125862.png" alt="Trinidad_13-1711012125862.png" /></span></P><P>The application flow begins with citizens reporting incidents on social media. The server-side application reads these posts and sends their content, along with a prompt, to SAP's Generative AI Hub. The SAP’s Generative AI Hub generates insights from each post, which are then presented to the Maintenance Manager.</P><P>The manager can choose to approve or reject each incident. Approved incidents result in a maintenance notification being created in SAP S/4 HANA, while all incidents, approved or rejected, are logged in the SAP HANA Cloud database.</P><P>We have implemented this application by building three different modules:</P><UL><LI>Social Media integration</LI><LI>Generative AI Hub integration</LI><LI>SAP S/4 HANA Cloud integration.</LI></UL><P>The full source code of our application is available in the <A href="https://github.com/SAP-samples" target="_blank" rel="noopener nofollow noreferrer">SAP-samples</A>/<A href="https://github.com/SAP-samples/btp-generative-ai-hub-use-cases" target="_blank" rel="noopener nofollow noreferrer"><STRONG>btp-generative-ai-hub-use-cases</STRONG></A> GitHub repository part of the SAP-Samples.</P><H3 id="toc-hId-1576574827">Consuming Generative AI Hub in JavaScript</H3><P>To implement the server side of our social media citizen reporting app in JavaScript, we have leveraged the SAP Cloud application programming model.</P><P><A href="https://dam.sap.com/mac/app/p/video/asset/preview/FezoDGZ?ltr=a&amp;rc=10" target="_blank" rel="noopener noreferrer"><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-03-25 at 14.53.10.png" style="width: 577px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/86011iC21D76FB233E54D6/image-dimensions/577x327?v=v2" width="577" height="327" role="button" title="Screenshot 2024-03-25 at 14.53.10.png" alt="Screenshot 2024-03-25 at 14.53.10.png" /></span></A></P><P>The JavaScript implementation shown in this demo directly calls the SAP AI Core Generative AI Hub APIs through an HTTP POST and <SPAN>shows</SPAN> how to consume the SAP’s Generative AI Hub raw APIs. Please check <A href="https://discovery-center.cloud.sap/protected/index.html" target="_blank" rel="noopener nofollow noreferrer">Generative AI Reference Architecture</A> including a <A href="https://github.com/SAP-samples/btp-cap-genai-rag/blob/main/README.md" target="_blank" rel="noopener nofollow noreferrer">GitHub</A> repository to check other implementation options in TypeScript leveraging Langchain.</P><H3 id="toc-hId-1380061322">Consuming Generative AI Hub in Python</H3><P>To consume Generative AI Hub in Python, we leverage the <A href="https://pypi.org/project/generative-ai-hub-sdk/" target="_blank" rel="noopener nofollow noreferrer">Generative AI Hub SDK</A>, which simplifies the implementation of the calls to the SAP’s Generative AI Hub APIs.</P><P><div class="video-embed-center video-embed"><iframe class="embedly-embed" src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F1hk0E6Lsejs%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D1hk0E6Lsejs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F1hk0E6Lsejs%2Fhqdefault.jpg&amp;key=b0d40caa4f094c68be7c29880b16f56e&amp;type=text%2Fhtml&amp;schema=youtube" width="400" height="225" scrolling="no" title="Augment your SAP BTP Use Cases with AI Foundation: Generative AI Hub integration in Python" frameborder="0" allow="autoplay; fullscreen; encrypted-media; picture-in-picture;" allowfullscreen="true"></iframe></div></P><H3 id="toc-hId-1183547817">SAP S/4 HANA Cloud Integration</H3><P>Once the Maintenance Manager approves an incident, a maintenance notification is created in the SAP S/4 HANA Cloud tenant. We used the SAP Cloud SDK Maintenance Notification Service module to implement this functionality. The user interface calls a function to create the maintenance notification, providing all the required information from the citizen post and the insights generated by the Generative AI Hub.</P><H3 id="toc-hId-987034312">User Interface Implementation</H3><P>The user interface was implemented using SAP Build Apps, a low-code, no-code tool that enabled us to implement our proof of concept quickly, using ready-to-consume UI components. The user interface connects to the backend via OData APIs to retrieve all the details required by the Maintenance Manager.</P><P>All the source code of this application is available on our <A href="https://github.com/SAP-samples/btp-generative-ai-hub-use-cases/tree/main/01-social-media-citizen-reporting" target="_blank" rel="noopener nofollow noreferrer">Github repository</A> for further exploration and includes both the JavaScript as well as the Python version of the backend application among other resources.</P><H2 id="toc-hId-1083923814">Explore further resources on generative AI at SAP</H2><P><STRONG>Source code of our prototype</STRONG></P><UL><LI><A href="https://github.com/SAP-samples" target="_blank" rel="noopener nofollow noreferrer">SAP-samples</A><SPAN>/</SPAN><A href="https://github.com/SAP-samples/btp-generative-ai-hub-use-cases" target="_blank" rel="noopener nofollow noreferrer"><STRONG>btp-generative-ai-hub-use-cases</STRONG></A></LI></UL><P><STRONG>Generative AI at SAP</STRONG></P><UL><LI><A href="https://www.sap.com/bulgaria/products/artificial-intelligence/generative-ai.html" target="_blank" rel="noopener noreferrer">OpenSAP Course | Generative AI with SAP</A></LI><LI><A href="https://pages.community.sap.com/topics/machine-learning" target="_blank" rel="noopener noreferrer">SAP Community | Artificial Intelligence and Machine Learning at SAP</A></LI><LI><A href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/models-and-scenarios-in-generative-ai-hub" target="_blank" rel="noopener noreferrer">Generative AI Hub in SAP AI Core</A></LI><LI><A href="https://help.sap.com/docs/ai-launchpad/sap-ai-launchpad/generative-ai-hub" target="_blank" rel="noopener noreferrer">Generative AI Hub in SAP AI Launchpad </A></LI><LI><A href="https://roadmaps.sap.com/board?range=FIRST-LAST&amp;FT=GEN_AI" target="_blank" rel="noopener noreferrer">Generative AI Roadmap</A></LI><LI><A href="https://discovery-center.cloud.sap/serviceCatalog/sap-ai-core?region=all&amp;tab=feature" target="_blank" rel="noopener nofollow noreferrer">Discovery Center | SAP AI Core and Generative AI Hub</A></LI><LI><A href="https://www.sap.com/germany/about/trust-center/agreements/on-premise/data-processing-agreements.html?sort=latest_desc" target="_blank" rel="noopener noreferrer">Data Processing Agreement</A></LI></UL><P><STRONG>Implementation Samples</STRONG></P><UL><LI><A href="https://github.com/SAP-samples/btp-generative-ai-hub-use-cases" target="_blank" rel="noopener nofollow noreferrer">Social Media Citizen Reporting App</A><U> – GitHub repository</U></LI><LI><A href="https://discovery-center.cloud.sap/protected/index.html" target="_blank" rel="noopener nofollow noreferrer">Generative AI Reference Architecture</A></LI><LI><A href="https://developers.sap.com/tutorial-navigator.html?search=Generative+AI+Hub" target="_blank" rel="noopener noreferrer">Generative AI Hub Tutorials</A></LI></UL><P><STRONG>More sessions on this series</STRONG></P><P>Please check the central blog <A href="https://partneredge.sap.com/en/library/education/products/btp/build/e_ep_use-cases_ai-foundation.html" target="_blank" rel="noopener noreferrer">Augment Your SAP BTP Use Cases With AI Foundation on SAP BTP</A> to get all the details on the sessions part of this series, register for the upcoming sessions and earn a knowledge badge by attending passing the associated web assessment.</P><P><A href="https://partneredge.sap.com/en/library/education/products/btp/build/e_ep_use-cases_ai-foundation.html" target="_blank" rel="noopener noreferrer"><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Trinidad_14-1711012125863.png" style="width: 672px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/84244i63E4D26CBDF9E22A/image-dimensions/672x126?v=v2" width="672" height="126" role="button" title="Trinidad_14-1711012125863.png" alt="Trinidad_14-1711012125863.png" /></span></A></P><H2 id="toc-hId-887410309">Conclusion and Key Takeaways</H2><P>Large Language Models have ushered in a new era in the field of artificial intelligence. While they come with their limitations, their ability to generate novel content and adapt to a wide range of tasks makes them a powerful tool. By understanding these models and how to adapt, choose, and evaluate them, we can leverage their capabilities in various SAP environments and beyond.</P><P>The SAP’s Generative AI Hub offers a streamlined toolset for Generative AI<SPAN>&nbsp;</SPAN><SPAN>solution&nbsp;</SPAN>development, instant access to top-rated foundation models from multiple providers, and<SPAN>&nbsp;</SPAN><SPAN>an elevated level</SPAN><SPAN>&nbsp;</SPAN>of trust and control.<BR /><BR /></P><P>We hope this blog has inspired you to start designing and implementing your own use cases to unlock the power of generative AI in your solutions.&nbsp;Stay tuned for more blogs in this series as we continue to explore the exciting possibilities of generative AI with SAP!</P> 2024-03-25T15:08:29.967000+01:00 https://community.sap.com/t5/technology-blogs-by-sap/boosting-benchmarking-for-reliable-business-ai/ba-p/13650962 Boosting Benchmarking for Reliable Business AI 2024-03-27T20:20:07.257000+01:00 hao_zhi_leong https://community.sap.com/t5/user/viewprofilepage/user-id/1396220 <P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hao_zhi_leong_0-1711529144882.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/87186iA07D619194DE189A/image-size/large?v=v2&amp;px=999" role="button" title="hao_zhi_leong_0-1711529144882.png" alt="hao_zhi_leong_0-1711529144882.png" /></span></P><P>This blog post is part of a series that dives into various aspects of SAP’s approach to generative AI, and its technical underpinnings.</P><P>In the <SPAN><A href="https://community.sap.com/t5/technology-blogs-by-sap/how-sap-s-generative-ai-hub-facilitates-embedded-trustworthy-and-reliable/ba-p/13596153" target="_blank">previous blog post</A></SPAN>&nbsp;of this series, we introduced the SAP generative AI hub, in SAP AI Core. In this blog post, we will discuss a significant aspect – benchmarking of AI models.</P><P>Read the <SPAN><A href="https://blogs.sap.com/2023/12/20/how-saps-generative-ai-architecture-redefines-business-applications/" target="_blank" rel="noopener noreferrer">first blog post</A></SPAN> of the series.</P><P><SPAN><STRONG>Introduction</STRONG></SPAN><SPAN><STRONG>&nbsp;</STRONG></SPAN></P><P>At SAP, we are building business AI - AI which is solving our customers’ business problems and which is an integrated part of SAP’s applications and platforms. By integrating this technology in our applications, our customers can achieve relevant outcomes with direct business value <SPAN><A href="https://www.nomos-elibrary.de/10.5771/0042-059X-2021-3-340/advancements-in-ml-enabled-intelligent-document-processing-and-how-to-overcome-adoption-challenges-in-enterprises-volume-75-2021-issue-3?hitid=00&amp;search-click&amp;page=1" target="_blank" rel="noopener nofollow noreferrer">(Tomasz Janasz et al. 2021).</A></SPAN> While generative AI (GenAI) can create great value for companies, applying this technology to business problems comes with high requirements for correctness and reliability. &nbsp;</P><P>The number of generative AI use cases developed at SAP and the number of AI models which are available, both commercial and open source, is growing quickly. &nbsp;Therefore, we need a systematic approach for selecting the most suitable model for each use case and need to answer the question “What is the best model?” for each particular use case.</P><P>In our previous blog posts, we have discussed how SAP's <SPAN>generative AI hub in SAP AI Core lets developers access the best AI models from our cloud-technology partners, such as Microsoft Azure, leading AI startups, and open-source models in an SAP environment. </SPAN>In this third blog post of the series, we will describe why benchmarking is important for business AI, how it fits into SAP’s AI strategy and what are current best practices for benchmarking and testing AI models, to maximize business value.</P><P><SPAN><STRONG>Why benchmarking matters</STRONG></SPAN></P><P><SPAN>To state the obvious, customers expect their software to work correctly and reliably. Conducting rigorous testing is, therefore, part of any professional software development project. It becomes even more important when the software is used to make important business decisions. Now, customers have similar high expectations regarding correctness of any AI feature. Effective testing helps in identifying biases, inaccuracies, and unexpected behaviors, and helps to ensure that the models align with ethical standards and user expectations. </SPAN></P><P><SPAN>AI testing often utilizes collections of test samples, typically across different tasks, which are organized in standardized benchmarks. Benchmarks allow comparing AI models and have been a measure of progress in AI. </SPAN>Initiatives like Stanford’s Holistic Evaluation of Language Models (<SPAN><A href="https://crfm.stanford.edu/helm/lite/latest/" target="_blank" rel="noopener nofollow noreferrer">HELM</A></SPAN>) or the <SPAN><A href="https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard" target="_blank" rel="noopener nofollow noreferrer">Huggingface Open LLM leaderboard</A></SPAN> compare AI models across multiple tasks and datasets.</P><P><SPAN>Compared to traditional software testing, testing AI models, particularly large language models (LLMs), is still a less mature discipline. In conventional software testing, there are established methodologies, like unit testing, and the behavior of the software is largely predictable and deterministic, as it was programmed by a human developer. AI models resemble 'black boxes' which were trained, rather than explicitly programmed and whose inner workings are hard to understand, even for AI experts. This opacity makes understanding the causes behind outputs difficult, complicating the debugging and improvement processes. Furthermore, the vast and varied nature of language models complicates the creation of comprehensive test sets, as it is nearly impossible to predict all the ways users might interact with the model and the space of potential outputs is nearly unbounded. </SPAN></P><P><SPAN><STRONG>How are models currently being used?</STRONG></SPAN></P><P><SPAN>General-purpose large language models are flexible and have a wide range of applications. However, for specific use cases that require specialized knowledge, these general-purpose models might need fine-tuning or the use of retrieval-augmented generation (RAG) to improve their accuracy and reliability. The high cost of fine-tuning may necessitate the use of smaller models to ensure feasibility. Meanwhile, retrieval-augmented generation systems may require models with larger context window sizes.</SPAN></P><P><SPAN>For any large language model used in a user application, there's a balance to be struck between the responsiveness of the model and the quality of its output. For instance, models like GPT-4 from OpenAI are known for their excellent performance in terms of quality but are restricted by high latency and cost. Other models, such as Gemini Pro, Mixtral 8x7B, GPT-3.5 Turbo, and Llama 2 Chat 70B, provide a good mix of quality, speed, and cost-effectiveness. While these models may not perform as well as GPT-4, they still outperform many other models on the market.</SPAN></P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hao_zhi_leong_1-1711529176026.png" style="width: 249px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/87187i313A16DAA85645F6/image-dimensions/249x184?v=v2" width="249" height="184" role="button" title="hao_zhi_leong_1-1711529176026.png" alt="hao_zhi_leong_1-1711529176026.png" /></span><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hao_zhi_leong_2-1711529195031.png" style="width: 250px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/87188iE484A60A2EFA45A8/image-dimensions/250x184?v=v2" width="250" height="184" role="button" title="hao_zhi_leong_2-1711529195031.png" alt="hao_zhi_leong_2-1711529195031.png" /></span><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hao_zhi_leong_3-1711529204990.png" style="width: 250px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/87189i183BD01BCC3BB8C3/image-dimensions/250x184?v=v2" width="250" height="184" role="button" title="hao_zhi_leong_3-1711529204990.png" alt="hao_zhi_leong_3-1711529204990.png" /></span></P><P style=" text-align: center; "><EM>Figure 1: Quality, Performance &amp; Price Analysis of LLMs (from <A href="https://artificialanalysis.ai/models?parallel_queries=single&amp;prompt_length=long" target="_blank" rel="noopener nofollow noreferrer">Artificial Analysis</A>)</EM></P><P><SPAN>Therefore, choosing the right large language model requires a careful evaluation of the trade-offs between quality, speed, and cost. This underscores the importance of comprehensive benchmarking when assessing different models.</SPAN></P><P><SPAN><STRONG>From “eyeballing” to supervised evaluation</STRONG></SPAN></P><P><SPAN>Existing AI benchmarks are focused on academic datasets typically created from public sources, like Wikipedia.</SPAN> They do not yet sufficiently cover enterprise use cases <SPAN>which require data from specific business domain</SPAN><A href="#_ftn1" target="_blank" rel="noopener nofollow noreferrer"><SPAN>[1]</SPAN></A><SPAN>. Therefore, additional testing is required. </SPAN><SPAN>Let us investigate the testing process for generative AI in more detail.</SPAN></P><P><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="hao_zhi_leong_4-1711529332785.png" style="width: 796px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/87191iB8B0521E5A51E399/image-dimensions/796x160?v=v2" width="796" height="160" role="button" title="hao_zhi_leong_4-1711529332785.png" alt="hao_zhi_leong_4-1711529332785.png" /></span></P><P style=" text-align: center; "><EM>Figure 2: Three approaches to AI model evaluation</EM></P><P><SPAN>Testing and evaluating AI models follows an iterative approach. </SPAN><SPAN>When teams are ideating on new generative AI use cases, they typically start experimenting with various AI models in a “playground” environment, such as the generative AI hub in </SPAN><SPAN><A href="https://discovery-center.cloud.sap/serviceCatalog/sap-ai-launchpad?region=all" target="_blank" rel="noopener nofollow noreferrer">SAP AI Launchpad</A></SPAN><SPAN> (read more about it in </SPAN><SPAN><A href="https://community.sap.com/t5/technology-blogs-by-sap/how-sap-s-generative-ai-hub-facilitates-embedded-trustworthy-and-reliable/ba-p/13596153" target="_blank">blog post 2</A></SPAN><SPAN> of this series, or this </SPAN><SPAN><A href="https://blogs.sap.com/2024/01/09/ai-foundation-on-sap-btp-q4-2023-release-highlights/" target="_blank" rel="noopener noreferrer">blog post</A></SPAN><SPAN>). This environment allows for rapid prototyping via prompt engineering. SAP AI Launchpad also </SPAN><SPAN>allows sending prompts to different models for easy comparison. Compared to traditional AI models, generative AI models allow fast prototyping and a first feasibility check without the significant upfront investment of creating training and test data sets.</SPAN></P><P><SPAN>&nbsp;</SPAN></P><P><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="hao_zhi_leong_7-1711529592680.png" style="width: 692px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/87194i281584E3A469B444/image-dimensions/692x419?v=v2" width="692" height="419" role="button" title="hao_zhi_leong_7-1711529592680.png" alt="hao_zhi_leong_7-1711529592680.png" /></span></P><P style=" text-align: center; "><EM>Figure 3: Prompt Editor in SAP AI Launchpad</EM></P><P><SPAN>However, simply “eyeballing” a few prompt-answer pairs is not sufficient beyond the prototyping stage. Developers need more robust and reproducible tests. &nbsp;These tests should be automated so that they can be conducted as a part of automated testing and release pipelines. Automated testing is also important for regression testing, when the application, the input data or the underlying model have been changed. Finally, these methods should cater to diverse use case scenarios and languages, aiding in informed technology choices and application enhancements </SPAN></P><P><SPAN>The second stage in benchmarking models is using a large language model as a judge. </SPAN>This approach requires a test set of inputs but does not require ground truth references, i.e. it does not require the expected output or label. Instead, it uses the ability of powerful large language models to score the output – using one AI model to score another AI model. Employing language models as a judge sidesteps the expensive creation of human references, making it an efficient method to scale the evaluation after the eyeballing step. While <SPAN><A href="https://arxiv.org/pdf/2303.16634.pdf" target="_blank" rel="noopener nofollow noreferrer">research shows high correlation between language models as a judge and human scores</A></SPAN> (Liu, et al. 2023), a downside is the potential for bias or errors in the automatic judgments. Thus, the evaluation results should not be trusted blindly but undergo additional testing, either with a supervised test set, which we describe next, or human evaluation.</P><P><SPAN>The third stage is supervised evaluation, consisting of a test set of model inputs and expected outputs, usually provided by human domain experts to ensure they are accurate and reliable. These test sets should cover a wide range of expected inputs including edge cases and hard examples. The model output can be compared to the expected outputs automatically with an automated metric which measures the agreement between model outputs and human reference, producing a measure on the model’s performance. Examples for metrics are statistical measures, like accuracy, precision and recall, or AI-specific metrics, like the BLEU (Bilingual Evaluation Understudy) score which is commonly used in machine translation evaluation to measure the similarity of generated translations to human reference translations.</SPAN></P><P><SPAN>Supervised evaluation is the most reliable way to benchmark AI models, but it is also the costliest. Therefore, it makes sense to start with the simpler and cheaper prompt-engineering approaches, then enhance the tests using language models as a judge, and finally move to supervised evaluation.</SPAN> An overview of these evaluation methods is depicted in Figure 3.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="hao_zhi_leong_8-1711529852386.png" style="width: 709px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/87205i628BEC6CB5F4C3BA/image-dimensions/709x406?v=v2" width="709" height="406" role="button" title="hao_zhi_leong_8-1711529852386.png" alt="hao_zhi_leong_8-1711529852386.png" /></span></P><P style=" text-align: center; "><EM>Figure 4: Ways of evaluating LLMs</EM></P><P><SPAN><STRONG>Evaluation in practice: document processing with LLMs</STRONG></SPAN><SPAN><STRONG>&nbsp;</STRONG></SPAN></P><P><SPAN>Let us illustrate this with an example AI use case at SAP. </SPAN><SPAN><A href="https://help.sap.com/docs/document-information-extraction?locale=en-US&amp;state=PRODUCTION&amp;version=SHIP" target="_blank" rel="noopener noreferrer">Document Information Extraction</A></SPAN><SPAN> is an SAP AI service which extracts information from business documents, such as invoices or purchase orders. The service was recently enhanced with </SPAN><SPAN><A href="https://community.sap.com/t5/technology-blogs-by-sap/introducing-document-information-extraction-premium-edition-unleashing-the/ba-p/13574704" target="_blank">large language model capabilities</A></SPAN><SPAN> which greatly enhances its flexibility to process more document types and support more languages. After an initial prototyping phase, which showed the initial feasibility of using large language models, the team conducted a supervised evaluation of different large language models on a subset of header fields. We report the extraction accuracy of each model prompted in a zero-shot fashion relative to a fully supervised baseline. Figure 4 shows the anonymized results. We can see that some of the models can achieve high extraction accuracy, rivaling supervised models. But the results also show that the extraction accuracy between models varies, illustrating the importance of benchmarking. The main business value of large language model in this scenario is their flexibility: allowing users to process any type of document in almost any language (although the exact language coverage differs between models). It is important to note that large language models are several orders of magnitude larger and more expensive than the supervised model. All these factors need to be considered when producing AI.</SPAN></P><P><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="hao_zhi_leong_6-1711529489955.png" style="width: 706px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/87193i90C7031D815FABBF/image-dimensions/706x397?v=v2" width="706" height="397" role="button" title="hao_zhi_leong_6-1711529489955.png" alt="hao_zhi_leong_6-1711529489955.png" /></span></P><P style=" text-align: center; "><EM>Figure 5: Benchmarking results for information extraction from documents using zero-shot prompting on a subset of header fields. Results are relative to a supervised baseline. Model names are anonymized.</EM><SPAN>&nbsp;</SPAN></P><P><SPAN><STRONG>Benchmarking for Enterprise AI</STRONG></SPAN></P><P>To enhance the state of AI benchmarking for enterprise use cases, SAP is teaming up with its academic partners. In 2023, SAP joined the Stanford HAI Corporate Affiliate Program. Under this program, SAP is now starting a collaboration with the Stanford Center for Research on Foundation Models <SPAN>(CRFM) on the Holistic Evaluation of Language Models (HELM) project to study specific enterprise AI use cases. </SPAN></P><P><SPAN><STRONG>Conclusion</STRONG></SPAN></P><P>In this blog post, we have outlined the importance and the challenges of benchmarking or business AI. We have recommended three stages of evaluation as current best practices for benchmarking, going from quick eyeballing of examples to using language models as a judge and supervised evaluation. This helps to quickly establish a first feasibility check and build more robust and reliable tests in an iterative manner<SPAN>. The field of AI benchmarking is still evolving, and we can be sure that we will see more benchmarks and test methodologies covering, for example AI safety, trustworthy AI, and industry verticals, in the future. </SPAN></P><P><SPAN><STRONG>References</STRONG></SPAN></P><P>Tomasz Janasz, Peter Mortensen, Christian Reisswig, Tobias Weller, Maximilian Herrmann, Ivona Crnoja, and Johannes Höhne. "Advancements in ML-enabled intelligent document processing and how to overcome adoption challenges in enterprises."&nbsp;<EM>Die Unternehmung</EM>&nbsp;75, no. 3 (2021): 340-358.</P><P>Yang Liu, Dan Iter, Yichong Xu, Shuohang Wang, Ruochen Xu, and Chenguang Zhu. "GPTEval: NLG evaluation using GPT-4 with better human alignment."&nbsp;<EM>arXiv preprint arXiv:2303.16634</EM>&nbsp;(2023).</P><P><A href="#_ftnref1" target="_blank" rel="noopener nofollow noreferrer"><SPAN>[1]</SPAN></A> <SPAN>But see the recently released </SPAN><SPAN><A href="https://huggingface.co/blog/leaderboards-on-the-hub-patronus" target="_blank" rel="noopener nofollow noreferrer">Enterprise Scenarios Leaderboard</A></SPAN><SPAN> by Patronus as a first benchmark for enterprise use cases</SPAN></P> 2024-03-27T20:20:07.257000+01:00 https://community.sap.com/t5/enterprise-resource-planning-blogs-by-sap/demystifying-transformers-and-embeddings-some-genai-concepts/ba-p/13652933 Demystifying Transformers and Embeddings: Some GenAI Concepts 2024-03-28T21:07:49.791000+01:00 Louenas https://community.sap.com/t5/user/viewprofilepage/user-id/3372 <P><STRONG>Introduction:</STRONG></P><P>Generative AI (GenAI) keeps generating so much news and so many innovative applications in many domains and industries. The potential impact of GenAI on businesses and society is becoming difficult to deny. Thought leaders have compared the impact of GenAI to the invention of the transistor, the internet, and even FIRE.</P><P>Being at SAP part of the Partner Ecosystem Success group, I had the opportunity to talk to partners and customers, testifying that Business AI is first on the agenda, as SAP's CEO Christian K. and Walter S., Head of AI at SAP, expressed in this <A href="https://www.linkedin.com/posts/christian-klein_exploring-the-future-of-generative-ai-in-activity-7135346329752387584-CQwl/" target="_blank" rel="noopener nofollow noreferrer">short video</A>.</P><P>SAP is at the forefront of this new enterprise revolution and rightfully so, as SAP applications constitute the digital platform of business in the world, where the oil of Gen Business AI being the business Data is being generated and transformed. As the saying goes, with great power comes great responsibility; therefore, SAP is strategically focusing on Relevant, Reliable, and Responsible AI.</P><P>On the GenAI technology news from SAP, the following are the latest:</P><P><A href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/generative-ai-hub-in-sap-ai-core" target="_blank" rel="noopener noreferrer">Generative AI hub</A>: This is the place where SAP and its ecosystem will integrate LLMs and AI into new business processes in a cost-efficient manner.</P><P><A href="https://pages.community.sap.com/topics/joule" target="_blank" rel="noopener noreferrer">Joule</A>: The Generative Business AI Assistant from SAP. This will become the main UX for SAP Applications like S/4HANA Cloud and SuccessFactors HCM, providing information retrieval, navigational assistance, transitional assistance, and analytics assistance with ad-hoc and natural language querying capabilities.</P><P><A href="https://community.sap.com/t5/technology-blogs-by-sap/announcing-general-availability-of-sap-build-code-speed-up-development-with/ba-p/13646073" target="_blank">SAP Build Code</A>: This is where the developer community will build new user experiences with such speed of development thanks to embedded productivity tools powered with GenAI.</P><P><A href="https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-vector-engine-guide/introduction" target="_blank" rel="noopener noreferrer">SAP HANA Database Vector Engine</A>: This is the in-memory database from SAP, integrating under one single APIs set all the required engines for transactional workloads, Analytics/ML, and now GenAI thanks to the added support for a Vector engine. The Vector engine is the technical component used for managing Embeddings and using them to ground GenAI business use cases. Grounding is a term used in the context of RAG (Retrieval-Augmented Generation) to condition the LLM with the relevant context and therefore limit hallucinations.</P><P><STRONG>Understanding Transformers and Embeddings:</STRONG></P><P>Talking to partners and customers about GenAI is fun, but for more productive brainstorming, it's sometimes important to level set on the technical side with some GenAI basics, such as Embeddings and Transformers.</P><P>There are many great blogs and videos explaining these topics in detail using GPT-2, so this is a great resource as most LLMs use a very similar architecture. The resources that helped me most and seemed to be the best for people with technical background are from Niels Rogge from HuggingFace:</P><UL><LI><A href="https://www.youtube.com/watch?v=C6ZszXYPDDw" target="_blank" rel="noopener nofollow noreferrer">Transformers demystified: how do ChatGPT, GPT-4, LLaMa work?</A></LI><LI><A href="https://www.youtube.com/watch?v=IGu7ivuy1Ag" target="_blank" rel="noopener nofollow noreferrer">How a Transformer works at inference vs training time</A></LI></UL><P>Transformers like GPT act on tokens. Tokens are sub-words, and all the LLMs sub-words is the vocabulary. GPT-2 has a vocabulary size of 50,257 tokens, with each token represented by an Embedding of 768 dimensions. In comparison, GPT-4 seems to have 100,256 tokens and a default embedding vector of 1,536 dimensions (GPT-4 has a higher size of 3,072 dimensions and comes with the text-embedding-3-large model).</P><P>The tokens are produced with a tokenization ML process that tries to maximize the compression of language into an adequate vocabulary size. In GPT, the Embeddings are encoded into vectors using a training phase through the Transformer (see the 2nd from Niels).</P><P>You can experiment with tokenization on OpenAI <A href="https://www.openai.com/tokenizer" target="_blank" rel="noopener nofollow noreferrer">here</A>. For example, "hello world, my name is" will produce these 6 tokens: ['hello'- ' world' - ',' - ' my' - ' name' - ' is']. In French, when translated literally to "bonjour monde, mon nom est," it produces 7 tokens. Less common words will produce more tokens; therefore - fun fact - non-English languages will tend to produce more tokens, i.e., higher dollar cost for the same number of language words of a given prompt.</P><P>One forward pass through the Transformer architecture of GPT-2, i.e., predicting one next token, can be summarized in Python as follows. The code is self-explanatory with detailed inline comments.</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-python"><code>from transformers import AutoTokenizer, AutoModelForCausalLM import torch # Load the GPT-2 tokenizer and model tokenizer = AutoTokenizer.from_pretrained("gpt2") model = AutoModelForCausalLM.from_pretrained("gpt2") # Prompt prompt = "hello, my name is" # Tokenize the input text and return their IDs input_ids = tokenizer(prompt, return_tensors="pt").input_ids # Pass the tokenized input through the GPT-2 model to get the logits (Unnormalized embeddings) representing the likelihood scores of each possible next word. logits = model(input_ids).logits # slices the output to get the logits only for the last position in the sequence, as we're predicting the very next word next_token_logits = logits[:, -1, :] # finds the index (ID) of the word with the highest probability score. next_token_id = torch.argmax(next_token_logits, dim=-1) # Decode i.e. convert the numerical token ID back into its corresponding word. next_token = tokenizer.decode(next_token_id[0]) # Print the predicted next token print(f"Next token is {next_token}")</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>When running this program on a <A href="https://colab.research.google.com/drive/1OVFfTrHtCdmcBSJRA_XO-5kAYurQMS4I?usp=sharing" target="_blank" rel="noopener nofollow noreferrer">Jupiter Notebook</A> or Visual Studio Code, the next keyword will be "John." As a developer, you can add a loop to keep appending the next_token to the end of the prompt and perform a forward pass to see what the following tokens will be.</P><P>The videos above from Niels are very informative but could be a bit technical for some community members. To make it easier to explain, I spent a lot of time thinking about how to demonstrate the concepts without resorting to the phrase “Some magic happens here…”. Here is what I came up with, hoping it will help you understand and explain broader GenAI topics to your partners and customers.</P><P>Imagine a 3-dimensional space representing some concepts like Fruits, Programming languages, and Software companies.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Louenas_0-1711655043097.png" style="width: 400px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/88229i690C1A63DC5717C1/image-size/medium?v=v2&amp;px=400" role="button" title="Louenas_0-1711655043097.png" alt="Louenas_0-1711655043097.png" /></span></P><P>The following matrix with the name "embedding" is the algebraic representation of such a universe. The labels set is the vocabulary, and the X, Y, and Z coordinates are the corresponding embedding vectors. Please continue through the Python code, as it's purposefully well-documented to be self-explanatory.</P><P>&nbsp;</P><P>&nbsp;</P><pre class="lia-code-sample language-python"><code>import numpy as np import random # Pre-defined (random) word embeddings embeddings = { # Fruits I love "Apple": np.array([0.85, 0.10, 0]), "Banana": np.array([0.91, 0.05, 0]), "Orange": np.array([0.90, 0.06, 0]), "Figs": np.array([0.88, 0.10, 0]), # Programming Languages I know "Java": np.array([0.10, 0, 0.85]), "JavaScript": np.array([0.05, 0, 0.91]), "Python": np.array([0.06, 0, 0.90]), "ABAP": np.array([0.10, 0, 0.88]), # Enterprise software companies :) "SAP": np.array([0, 0.85, 0.10]), "Oracle": np.array([0, 0.91, 0.05]), "Microsoft": np.array([0, 0.90, 0.06]), "Salesforce": np.array([0, 0.88, 0.10]), } # Prompt prompt = "I love ABAP and" # Split the prompt into individual words prompt_words = prompt.split() # Function to get embedding for a word # Return a vector of ones (identity vector) if the word is not in the vocabulary # Since 'I', 'love, 'and' are not in our vocabulary, it will get an embedding of [1, 1, 1] def get_embedding(word): return embeddings.get(word, np.ones(3)) # Calculate the average embedding of the prompt prompt_embedding = np.mean([get_embedding(word) for word in prompt_words], axis=0) # Get our vocabulary vocabulary = list(embeddings.keys()) # Remove words in the prompt from the vocabulary so that they won't be used to complete the prompt filtered_vocabulary = [word for word in vocabulary if word not in prompt_words] # Calculate dot products between the prompt embedding and the remaining vocabulary embeddings dot_products = {word: np.dot(prompt_embedding, get_embedding(word)) for word in filtered_vocabulary} # Add some randomness in the chosen next word Sort the words by their dot products and select the top two top_two_words = sorted(dot_products, key=dot_products.get, reverse=True)[:2] # Randomly select one of the two highest words. predicted_word = random.choice(top_two_words) print(f"Predicted next word: {predicted_word}")</code></pre><P>&nbsp;</P><P>&nbsp;</P><P>When running this code on a <A href="https://colab.research.google.com/drive/1uneQbX6Mhx4dUcVP5lf2mN8JtfBLTNSF?usp=sharing" target="_blank" rel="noopener nofollow noreferrer">Jupiter Notebook</A> or Visual Studio Code, you will be able to complete the prompts with the next programming language that I love <span class="lia-unicode-emoji" title=":slightly_smiling_face:">🙂</span> I you type "I like Apple and" it will complete with another fruit. Go ahead and experiment with you own categories and I hope this simulation can help you appreciate the scale of a real LLM like GPT-4 Turbo that acts on a vocabulary of 100,256 tokens and Embedding vectors of 3072 dimensions!!!</P><P>This simple code can predict the next word, classify words, etc. from the given vocabulary.</P><P><STRONG>Conclusion:</STRONG></P><P>To be clear, this is a very simplistic illustration of how high school algebra, i.e., matrix multiplication, is at the centre of today's technology revolution. Among other things, the Transformer neural networks like GPUs/TPUs/LPUs for their great capabilities in matrix operations and parallelization of such workloads. It's important not to underestimate other concepts in the Transformer architecture, such as tokenization, encoding, embedding, attention, and the neural network architecture of the Transformers, as well as Reinforcement Learning, Alignment, etc.</P><P>Understanding the technical concepts behind GenAI, such as Transformers and Embeddings, is crucial for productive brainstorming and discussions on GenAI applications in various domains and industries. This blog post aimed to provide a primer on these concepts, encouraging readers to explore the provided resources and code examples to deepen their understanding.</P> 2024-03-28T21:07:49.791000+01:00 https://community.sap.com/t5/artificial-intelligence-and-machine-learning-blogs/bring-open-source-llms-into-sap-ai-core/ba-p/13655167 Bring Open-Source LLMs into SAP AI Core 2024-04-04T14:55:04.919000+02:00 YatseaLi https://community.sap.com/t5/user/viewprofilepage/user-id/7022 <P>The open-source community surrounding Large Language Models (LLMs) is evolving rapidly, with new models(model architectures), backends(inference engines), libraries, and tooling constantly emerging. These developments enable the running of LLMs locally or on self-hosted environments. SAP AI Core is a service in the SAP Business Technology Platform that is designed to handle the execution and operations of your AI assets in a standardized, scalable, and hyperscaler-agnostic way. In this blog post series, we will explore various options for running popular open-source Large Language Models like Mistral, Mixtral, LlaVA, Gemma, Llama 2, etc., in <a href="https://community.sap.com/t5/c-khhcw49343/SAP+AI+Core/pd-p/73554900100800003641" class="lia-product-mention" data-product="405-1">SAP AI Core</a>, which complements SAP Generative AI Hub with self-hosted open-source LLMs&nbsp;We'll utilize widely adopted open-source LLM tools or backends such as <A href="https://ollama.com/" target="_blank" rel="noopener nofollow noreferrer">Ollama</A>, <A href="https://localai.io/" target="_blank" rel="noopener nofollow noreferrer">LocalAI</A>, <A href="https://github.com/ggerganov/llama.cpp/tree/master/examples/server" target="_blank" rel="noopener nofollow noreferrer">llama.cpp</A> and <A href="https://docs.vllm.ai" target="_blank" rel="noopener nofollow noreferrer">vLLM</A>, among others, through the BYOM (Bring Your Own Model) approach. The <A href="https://github.com/SAP-samples/btp-generative-ai-hub-use-cases/tree/main/10-byom-oss-llm-ai-core" target="_blank" rel="noopener nofollow noreferrer">source code</A> of AI Core sample app <STRONG>byom-oss-llm-ai-core</STRONG> used in this blog post series are delivered as an SAP example under <A href="https://github.com/SAP-samples/btp-generative-ai-hub-use-cases/blob/main/LICENSE" target="_blank" rel="noopener nofollow noreferrer">Apache 2.0 license</A>. Not part of SAP product.<BR /><BR /></P><TABLE border="0" width="713" cellspacing="0" cellpadding="0"><TBODY><TR><TD width="500">Blog post series of Bring Open-Source LLMs into SAP AI Core</TD></TR><TR><TD width="500"><A href="https://blogs.sap.com/?p=1788496" target="_blank" rel="noopener noreferrer">Part 1 – Bring Open-Source LLms into SAP AI Core: Overview (this blog post)</A><BR />Part 2 – Bring Open-Source LLMs into SAP AI Core with Ollama (To be published)<BR />Part 3 – Bring Open-Source LLMs into SAP AI Core with LocalAI (To be published)<BR />Part 4 – Bring Open-Source LLMs into SAP AI Core with llama.cpp (To be published)<BR />Part 5 – Bring Open-Source LLMs into SAP AI Core with vLLM (to Te published)<BR /><BR />Note: You can try it out the sample AI Core sample app <STRONG>byom-oss-llm-ai-core </STRONG>by following its manual <A href="https://github.com/SAP-samples/btp-generative-ai-hub-use-cases/tree/main/10-byom-oss-llm-ai-core" target="_self" rel="nofollow noopener noreferrer">here</A> with all the technical details. The following blog posts will just wrap up the technical details of each option.</TD></TR></TBODY></TABLE><P>We'll begin the series of blog posts with some overview introduction of bringing open-source LLMs into SAP AI Core.</P><H2 id="toc-hId-990765086">Overview</H2><P>The SAP Business API strategy aims to infuse SAP business applications with intelligence by integrating cutting-edge AI technologies. An essential component of this strategy involves fostering partnerships and investments within the AI ecosystem. In addition to collaboration with proprietary AI vendors as illustrated in this diagram, the open-source commercially viable foundation models are also supported through BYOM(Bring Your Own Models) approach, in which SAP AI Core is&nbsp;leveraged as a start-of-art and enterprise-ready AI Infrastructure as a Service to deploy and infer open-source LLMs. Notably, an open-source foundation model (falcon-40b) is already available in the <A href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/generative-ai-hub-in-sap-ai-core" target="_self" rel="noopener noreferrer">SAP Generative AI Hub</A> within SAP AI Core.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAP Business AI Strategy" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/89484i126B5A838C1465FF/image-size/large?v=v2&amp;px=999" role="button" title="sap-business-ai-strategy.jpg" alt="SAP Business AI Strategy" /><span class="lia-inline-image-caption" onclick="event.preventDefault();">SAP Business AI Strategy</span></span></P><P>On the flip side, within the open-source community of LLMs, an increasing number of high-performing models such as Mistral, Mixtral, Gemma, LLaVa, LLaMA-2, etc., are emerging. These models have the potential to drop in and replace GPT-3.5 in certain use cases.&nbsp;</P><H3 id="toc-hId-923334300">Sample#1: Customer Message Processing in <A href="https://github.com/SAP-samples/btp-industry-use-cases/tree/main/04-customer-interaction-gpt4" target="_self" rel="nofollow noopener noreferrer">Intelligent Customer Interaction</A> use case</H3><P data-unlink="true">In our Intelligent Customer Interaction sample use case, we have used GPT3.5 to process the customer message. Details of this implementation can be found in our blog post <A href="https://blogs.sap.com/2023/06/20/integrating-gpt-chat-api-with-sap-cap/" target="_blank" rel="noopener noreferrer">Integrate with GPT Chat API for Advanced Text Processing</A>. Now, this task can potentially be accomplished using Mistral-7b with comparable results.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Customer Message Processing with Mistral-7b" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/89670iD58EBC558884C939/image-size/large?v=v2&amp;px=999" role="button" title="customer-message-processing-mistral.jpg" alt="Customer Message Processing with Mistral-7b" /><span class="lia-inline-image-caption" onclick="event.preventDefault();">Customer Message Processing with Mistral-7b</span></span></P><H3 id="toc-hId-726820795">Sample#2: Public Facilities Issue Spotter for <A href="https://github.com/SAP-samples/btp-generative-ai-hub-use-cases/tree/main/01-social-media-citizen-reporting" target="_blank" rel="noopener nofollow noreferrer">Citizen Reporting</A> use case</H3><P>We can enhance the citizen reporting use case with <A href="https://github.com/haotian-liu/LLaVA" target="_self" rel="nofollow noopener noreferrer">LLaVa</A> model's vision capability by automatically analyzing images and identifying public facility issues. This simplifies the user experience in the citizen reporting use case, allowing users to take and upload photos to report an issue through the app effortlessly. Certainly, the same use case can be achieved with GPT-4V when it is available SAP Generative AI Hub.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Public Facilities Issue Spotter powered by LLaVa Vision" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/89688i3A2F278E696CF694/image-size/large?v=v2&amp;px=999" role="button" title="llava-vision-sample.jpg" alt="Public Facilities Issue Spotter powered by LLaVa Vision" /><span class="lia-inline-image-caption" onclick="event.preventDefault();">Public Facilities Issue Spotter powered by LLaVa Vision</span></span></P><P>This is just a few samples about what the open-source LLMs can help in business context. Next, let's evaluate the rationale of why running open-source LLMs with SAP AI Core.</P><DIV class=""><H2 id="toc-hId-401224571">Why running open-source LLMs with SAP AI Core?</H2></DIV><UL><LI><P>Data Protection &amp; Privacy: Ensure compliance with stringent data protection and privacy regulations by leveraging SAP AI Core's robust security measures. Particularly in contexts where strict data protection and privacy policy and regulations prohibit the transmission of data to external proprietary LLMs. A self-hosted LLM with SAP AI Core becomes a complement for SAP Generative AI Hub.</P></LI><LI><P>Security: Safeguard your data and applications with state-of-the-art security protocols and infrastructure provided by SAP AI Core.</P></LI><LI><P>Cost-Effectiveness: Benefit from cost-effective solutions without compromising on quality or security, SAP AI Core offers efficient resource allocation(GPU) and dynamic scalability.</P></LI><LI><P>Flexibility of Choices: Enjoy the flexibility to choose from a variety of open-source LLMs and LLM backends, tailored to your specific business needs and requirements.</P></LI><LI><P>Making Open-Sourced LLMs Enterprise Ready: Elevate open-source LLMs to enterprise-level standards by integrating them seamlessly with SAP AI Core, ensuring reliability, scalability, and performance.</P></LI></UL><H2 id="toc-hId-204711066">How to bring open-source LLMs into SAP AI Core?</H2><P>Now, let's go straight to the most interesting part, bringing the open-source LLMs into SAP AI Core through BYOM approach. Let's start with explanation of some basic concepts around LLM.</P><H3 id="toc-hId-137280280">Basic concepts:</H3><UL><LI>LLM vs LMM<UL><LI>Large Language Model(LLM): A type of machine learning model designed to process and generate human-like text. For instance, GPT-3.5, Mistral etc.</LI><LI>Large Multi-modality Model(LMM): a more versatile type of machine learning model that can handle multiple modalities of data, such as text, images, audio, video, etc. These models are designed to process and generate content across different media formats. e.g. GPT-4V, LLaVa etc</LI></UL></LI><LI>Model Architecture, Model Family and Models<UL><LI>Model architecture: Refers to the structural design and organization of the neural network used for natural language processing tasks.</LI><LI>Model Family: Refers to a group of related LLMs that share similar architectural principles, training methodologies, and objectives. For instance, LLaMa-2 is a model family.</LI><LI>Models refer to individual instances or versions within a model family, each with its own specific architecture, parameters, and trained weights. e.g. models LLaMa2-7b,&nbsp;LLaMa2-13b,&nbsp;LLaMa2-70b belongs the model family LLaMa-2.</LI></UL></LI><LI>Non-Quantization vs Quantization: A trade-off between efficiency and accuracy for model inference<BR /><UL><LI>Non-quantization, also referred to as full-precision or floating-point representation, involves storing the model parameters using full precision floating-point numbers (e.g., 32-bit or 16-bit floating-point), which maintains the model's highest possible accuracy with much higher computational resources.</LI><LI>Quantization is the process of reducing the precision of the parameters/weights in AI Models from floating-point numbers (typically 32-bit or 16-bit floating-point) to a lower bit precision, such as 8-bit integers or even lower, which can reduce the memory footprint and computational requirements of the model on the cost of accuracy loss. In this sample, we test the model with Quantization, like Q5_K_M, AWQ etc, which keep a balance of good model accurracy and inference efficiency.</LI></UL></LI><LI>LLM Backend or Inference Engine: Refers to the computational framework or infrastructure responsible for executing inference tasks with the trained LLM model. for example, <A href="https://huggingface.co/docs/transformers/en/index" target="_self" rel="nofollow noopener noreferrer">transformer</A>, <A href="https://github.com/ggerganov/llama.cpp/tree/master/examples/server" target="_blank" rel="noopener nofollow noreferrer">llama.cpp</A> and <A href="https://docs.vllm.ai" target="_blank" rel="noopener nofollow noreferrer">vLLM</A> support multiple models with different model architectures for inference.</LI><LI>Model Hub: Refers to a centralized repository or platform where pre-trained LLM models are stored, managed, and made accessible to users for model inference tasks. The Model Hub serves as a resource hub for developers, researchers, and practitioners interested in leveraging pre-trained LLM models for their applications. <A href="https://huggingface.co" target="_blank" rel="noopener nofollow noreferrer">Hugging Face</A> is a great example of Model Hub.</LI></UL><H3 id="toc-hId--59233225">Solution Architecture:</H3><P>In this sample of Bringing Open-Source LLMs App in SAP AI Core, I have implemented four options(<A href="https://ollama.com/" target="_blank" rel="noopener nofollow noreferrer">Ollama</A>, <A href="https://localai.io/" target="_blank" rel="noopener nofollow noreferrer">LocalAI</A>, <A href="https://github.com/ggerganov/llama.cpp/tree/master/examples/server" target="_blank" rel="noopener nofollow noreferrer">llama.cpp</A> and <A href="https://docs.vllm.ai" target="_blank" rel="noopener nofollow noreferrer">vLLM</A>) which allow you can bring your preferred LLMs through configuration into SAP AI Core with OpenAI-compatible APIs. Some options(Ollama and LocalAI) even enables you to download and switch the model efficiently and dynamically during run-time.</P><P>In principle, there are three essential parts for bringing an open-source LLM/LMM into SAP AI Core</P><UL><LI>Commercially viable Open-Source or Open-Weight Models: e.g. Mistral, Mixtral, LLaVa etc.</LI><LI>Public accessible Model Hub: For instance, Ollama Model Library tailored for Ollama, hugging face as a general purposed model repository.</LI><LI>Custom LLM lnference Server in SAP AI Core: You can bring your own code to implement an inference server, for example, in the blog post <A href="https://community.sap.com/t5/technology-blogs-by-sap/running-language-models-deploy-llama2-7b-on-ai-core/ba-p/13557544" target="_self">Running Language Models – Deploy Llama2 7b on AI Core&nbsp;</A>by <A href="https://community.sap.com/t5/user/viewprofilepage/user-id/4997" target="_self">felixbartler</A>, it shows a great sample to implement a custom inference server with <A href="https://huggingface.co/docs/transformers/en/index" target="_self" rel="nofollow noopener noreferrer">hugging face transformer</A>. Alternatively, there are open-source and ready-to-use llm inference servers which can be reused in SAP AI Core, like <A href="https://ollama.com/" target="_blank" rel="noopener nofollow noreferrer">Ollama</A>, <A href="https://localai.io/" target="_blank" rel="noopener nofollow noreferrer">LocalAI</A>, <A href="https://github.com/ggerganov/llama.cpp/tree/master/examples/server" target="_blank" rel="noopener nofollow noreferrer">llama.cpp</A> and <A href="https://docs.vllm.ai" target="_blank" rel="noopener nofollow noreferrer">vLLM</A> with minimal custom code as a custom Dockerfile and configurable serving template adapted for SAP AI Core. <STRONG>Ollama is recommended for its simplicity and efficiency</STRONG>.</LI></UL><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="01-Solution Architecture" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/89478i67B81F96FA2FF556/image-size/large?v=v2&amp;px=999" role="button" title="solution-architecture.jpg" alt="01-Solution Architecture" /><span class="lia-inline-image-caption" onclick="event.preventDefault();">01-Solution Architecture</span></span></P><DIV class=""><H3 id="toc-hId--255746730">Why leverage Ollama, LocalAI, llama.cpp and vLLM as LLM inference Server within SAP AI Core?</H3></DIV><P>Ollama, LocalAI, llama.cpp and vLLM offer a comprehensive solution for running Large Language Models (LLMs) locally or in self-hosted environments. Their full stack capabilities include:</P><UL><LI>Model Management: Dynamically pull or download LLMs from model repository through API during run-time (exclusive to Ollama and LocalAI. vLLM provides seamless integration with Hugging Face models)</LI><LI>Running LLM efficiently with GPU Acceleration in SAP AI Core using open-source backends such as llama.cpp, vllm, transformer, exllama etc.</LI><LI>Serving with built-in OpenAI-compatible chat completion and embedding APIs. Exact the same APIs in SAP Generative AI Hub.</LI><LI>Easy deployment and setup with the need for minimal custom code deployment in SAP AI Core, simply just a custom Dockerfile and a configurable serving template adapted for SAP AI Core.</LI><LI>Commercially viability: They are all under MIT licenses or Apache 2.0 License.</LI></UL><P>Let's have a close look at each option from different aspects list above.</P><DIV class=""><H3 id="toc-hId--452260235">Ollama vs LocalAI in context of SAP AI Core</H3></DIV><TABLE><TBODY><TR><TD width="20%">&nbsp;</TD><TD width="40%"><STRONG><STRONG><A href="https://ollama.com/" target="_blank" rel="noopener nofollow noreferrer"><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="ollama" style="width: 46px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/89795i19F454822DC27E80/image-dimensions/46x65?v=v2" width="46" height="65" role="button" title="ollama" alt="ollama" /></span></A></STRONG></STRONG><STRONG><A href="https://ollama.com/" target="_blank" rel="noopener nofollow noreferrer">Ollama</A></STRONG>(<EM>Recommended</EM>)</TD><TD width="40%"><STRONG><A href="https://localai.io/" target="_blank" rel="noopener nofollow noreferrer"><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="257361158-0966aa2a-166e-4f99-a3e5-6c915fc997dd" style="width: 76px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/89802i74AAA2D3ADACAD65/image-dimensions/76x62?v=v2" width="76" height="62" role="button" title="257361158-0966aa2a-166e-4f99-a3e5-6c915fc997dd" alt="257361158-0966aa2a-166e-4f99-a3e5-6c915fc997dd" /></span>LocalAI</A></STRONG></TD></TR><TR><TD><STRONG>Description</STRONG></TD><TD>"Ollama: Get up and running with Llama 2, Mistral, Gemma, and other large language models."</TD><TD>"LocalAI is the free, Open Source OpenAI alternative. LocalAI act as a drop-in replacement REST API that’s compatible with OpenAI API specifications for local inferencing..."</TD></TR><TR><TD><STRONG>Recommendation<BR /></STRONG></TD><TD>Recommended if just inference LLMs/LMMs in SAP AI Core. See its AI capabilities below for detail.</TD><TD>Recommended if speech recognition, speech generation and image generation are also required apart from LLMs/LMMs.</TD></TR><TR><TD><STRONG>AI Capabilities</STRONG></TD><TD>-Text generation<BR />-Vision<BR />-Text Embedding</TD><TD>-Text generation<BR />-Vision<BR />-Text Embedding<BR />-Speech to Text<BR />-Text to Speech<BR />-Image Generation</TD></TR><TR><TD><STRONG>Installation &amp; Setup</STRONG></TD><TD>Easy installation and setup</TD><TD>Assure to use the corresponding docker image or build with the right variables for GPU acceleration.</TD></TR><TR><TD><STRONG>GPU Acceleration</STRONG></TD><TD>Automatically detect and apply GPU acceleration</TD><TD>Supported. Require additional configuration on individual model along side with GPU built docker image.</TD></TR><TR><TD><STRONG>Model Management</STRONG></TD><TD>Built-in model management through CLI commands or APIs</TD><TD><A href="https://localai.io/models/" target="_blank" rel="noopener nofollow noreferrer">Experimental model gallery</A><BR />May require additional configuration for GPU acceleration per model</TD></TR><TR><TD><STRONG>Supported Backends</STRONG></TD><TD>llama.cpp</TD><TD>multi-backend support and backend agnostic. Default backend as llama.cpp, also support extra backends such as vLLM, rwkv, huggingface transformer, bert, whisper.cpp etc. Please check its <A href="https://localai.io/model-compatibility/" target="_blank" rel="noopener nofollow noreferrer">model compatibility table</A> for details</TD></TR><TR><TD><STRONG>Supported Models</STRONG></TD><TD><A href="https://ollama.com/library" target="_blank" rel="noopener nofollow noreferrer">Built-in Model Library</A></TD><TD><A href="https://localai.io/models/" target="_blank" rel="noopener nofollow noreferrer">Experimental Model Gallery</A></TD></TR><TR><TD><STRONG>Model Switching</STRONG></TD><TD>Seamless model switching with automatic memory management</TD><TD>Supported</TD></TR><TR><TD><STRONG>APIs</STRONG></TD><TD>-<A href="https://github.com/ollama/ollama/blob/main/docs/api.md#pull-a-model" target="_self" rel="nofollow noopener noreferrer">Model Management API</A><BR />-<A href="https://github.com/ollama/ollama/blob/main/docs/openai.md" target="_self" rel="nofollow noopener noreferrer">OpenAI-compatible chat/complemtion API</A><BR />-<A href="https://github.com/ollama/ollama/blob/main/docs/api.md#generate-embeddings" target="_self" rel="nofollow noopener noreferrer">Embedding API</A></TD><TD>-<A href="https://localai.io/models/" target="_self" rel="nofollow noopener noreferrer">Model Management API</A><BR />-<A href="https://localai.io/features/text-generation/#chat-completions" target="_self" rel="nofollow noopener noreferrer">OpenAI-compatible chat/complemtion API</A><BR />-<A href="https://localai.io/features/embeddings/" target="_self" rel="nofollow noopener noreferrer">Embedding API</A></TD></TR><TR><TD><STRONG>Model Customization</STRONG></TD><TD>supported</TD><TD>supported</TD></TR><TR><TD><STRONG>License</STRONG></TD><TD>MIT</TD><TD>MIT</TD></TR></TBODY></TABLE><P>&nbsp;</P><DIV class=""><H3 id="toc-hId--648773740">llama.cpp vs vLLM in context of SAP AI Core</H3><TABLE><TBODY><TR><TD width="20%">&nbsp;</TD><TD width="40%"><STRONG><A href="https://github.com/ggerganov/llama.cpp/tree/master/examples/server" target="_blank" rel="noopener nofollow noreferrer"><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="230134379-7181e485-c521-4d23-a0d6-f7b3b61ba524" style="width: 200px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/89806i97496A46E8B43857/image-size/small?v=v2&amp;px=200" role="button" title="230134379-7181e485-c521-4d23-a0d6-f7b3b61ba524" alt="230134379-7181e485-c521-4d23-a0d6-f7b3b61ba524" /></span>llama.cpp</A></STRONG></TD><TD width="40%"><STRONG><A href="https://docs.vllm.ai" target="_blank" rel="noopener nofollow noreferrer"><span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="vllm-logo-text-light" style="width: 200px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/89809iC5FFE0775E389D52/image-size/small?v=v2&amp;px=200" role="button" title="vllm-logo-text-light" alt="vllm-logo-text-light" /></span>vLLM</A></STRONG></TD></TR><TR><TD width="20%"><STRONG>Description</STRONG></TD><TD width="40%">"The main goal of llama.cpp is to enable LLM inference with minimal setup and state-of-the-art performance on a wide variety of hardware - locally and in the cloud."</TD><TD width="40%">"A high-throughput and memory-efficient inference and serving engine for LLMs"</TD></TR><TR><TD><STRONG>AI Capabilities</STRONG></TD><TD>-Text generation<BR />-Vision<BR />-Text Embedding</TD><TD>-Text generation<BR />-Vision<BR />-Text Embedding</TD></TR><TR><TD><STRONG>Deployment &amp; Setup</STRONG></TD><TD>Easy deployment via docker. Many <A href="https://github.com/ggerganov/llama.cpp/tree/master/examples/server" target="_blank" rel="noopener nofollow noreferrer">arguments</A> to explore on starting llama.cpp server</TD><TD>Easy deployment via docker. Many <A href="https://docs.vllm.ai/en/latest/models/engine_args.html" target="_blank" rel="noopener nofollow noreferrer">engine arguments</A> on starting vllm.entrypoints.openai.api_server</TD></TR><TR><TD><STRONG>GPU Acceleration</STRONG></TD><TD>Supported</TD><TD>Supported</TD></TR><TR><TD><STRONG>Model Management</STRONG></TD><TD>Not supported. Need external tool(wget etc) to download models from Hugging Face</TD><TD>Seamless integration with popular HuggingFace models</TD></TR><TR><TD><STRONG>Supported Quantization</STRONG></TD><TD>1.5-bit, 2-bit, 3-bit, 4-bit, 5-bit, 6-bit, and 8-bit integer quantization</TD><TD>GPTQ, AWQ, SqueezeLLM, FP8 KV Cache</TD></TR><TR><TD><STRONG>Supported Models</STRONG></TD><TD><A href="https://github.com/ggerganov/llama.cpp" target="_blank" rel="noopener nofollow noreferrer">https://github.com/ggerganov/llama.cpp</A> &gt; Supported models</TD><TD><A href="https://docs.vllm.ai/en/latest/models/supported_models.html" target="_blank" rel="noopener nofollow noreferrer">Supported Model</A></TD></TR><TR><TD><STRONG>Model Switching</STRONG></TD><TD>Not supported. One deployment for one model.</TD><TD>Not supported. One deployment for one model.</TD></TR><TR><TD><STRONG>APIs</STRONG></TD><TD>-OpenAI-compatible chat/complemtion API<BR />-Embedding API</TD><TD>-OpenAI-compatible chat/complemtion API<BR />-Embedding API</TD></TR><TR><TD><STRONG>License</STRONG></TD><TD>MIT</TD><TD>Apache-2.0 license</TD></TR></TBODY></TABLE><P data-unlink="true">In this sample, I choose llama.cpp and vLLM server for their popularity. Similarly, the same approach is applicable to <A href="https://github.com/abetlen/llama-cpp-python?tab=readme-ov-file#openai-compatible-web-server" target="_self" rel="nofollow noopener noreferrer">llama-cpp-python's OpenAI-compatible Web Server</A> or <A href="https://github.com/haotian-liu/LLaVA?tab=readme-ov-file#launch-a-controller" target="_self" rel="nofollow noopener noreferrer">LLaVa&nbsp;'s API Server</A> etc.</P><H3 id="toc-hId--920518614">Test Summary</H3><P>I have conducted some tests on three open-source models(mistral-7b, mixtral, llava-7b) within SAP AI Core, such as:</P><UL><LI>chain of thought</LI><LI>general Q&amp;A</LI><LI>write a haiku about Run Ollama etc. in AI Core,</LI><LI>customer message process in intelligent customer interaction(json mode),</LI><LI>public facility issue spotter in citizen reporting(llava vision&nbsp; with json mode).</LI></UL><P>Overall, the&nbsp;quality of text generation is <STRONG>good engough</STRONG> in my test cases.</P><P>Let's have a look at the generation speed by <STRONG>token# generation per second</STRONG> in my test cases. Since Ollama, LocalAI and llama.cpp are using the same backend as llama.cpp, so they almost share the same results.</P><P><STRONG>Important note</STRONG>: Due to the limited number of my test cases, the test result may not be accurrate and objective. And it may yield different result with some other use cases. To choose an open-source LLM and its backend, you should conduct test based on your use cases.</P><H4 id="toc-hId--1410435126">&nbsp;</H4><H4 id="toc-hId--1606948631">Mistral-7b on Ollama, LocalAI and llama.cpp</H4><TABLE border="1" width="100%"><TBODY><TR><TD width="50%"><STRONG>Model</STRONG>:&nbsp;<A href="https://ollama.com/library/mistral:7b-instruct-q5_K_M" target="_self" rel="nofollow noopener noreferrer">mistral:7b-instruct-q5_K_M</A> (5.1 G)</TD><TD width="50%"><STRONG>Resource Plan of SAP AI Core</STRONG>: infer.s</TD></TR><TR><TD width="50%">Ollama, LocalAI and llama.cpp</TD><TD width="50%">Avg token generation per second: 30~40.<BR />Response time less than 10s in all of test cases</TD></TR></TBODY></TABLE><P>Here is one of sample log screenshot in SAP AI Core about token# per second of mistral on Ollama, LocalAI and llama.cpp&nbsp;</P><P><SPAN><STRONG><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ollama_mistral_token_per_sec_2.jpg" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/91260i75D356A5E94EDC9F/image-size/large?v=v2&amp;px=999" role="button" title="ollama_mistral_token_per_sec_2.jpg" alt="ollama_mistral_token_per_sec_2.jpg" /></span><BR /></STRONG></SPAN></P><H4 id="toc-hId--1803462136">&nbsp;</H4><H4 id="toc-hId--1999975641">Mistral-7b on vLLM</H4><TABLE border="1" width="100%"><TBODY><TR><TD width="49.81036662452592%"><STRONG>Model</STRONG>:&nbsp;<A href="https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.2-AWQ" target="_self" rel="nofollow noopener noreferrer">Mistral-7B-Instruct-v0.2-AWQ</A> (4.15 G)</TD><TD width="50.06321112515803%"><STRONG>Resource Plan of SAP AI Core</STRONG>: infer.s</TD></TR><TR><TD width="49.81036662452592%"><P>vLLM with the following engine arguments</P><DIV><DIV>--dtype half</DIV><DIV>--gpu-memory-utilization 0.95</DIV><DIV>--enforce-eager</DIV><DIV>--max-model-len 2048</DIV><DIV>--max-num-batched-tokens 2048</DIV><DIV>--max-num-seqs 2048</DIV><DIV>--quantization awq</DIV></DIV></TD><TD width="50.06321112515803%"><P>Avg token generation per second: 40~50<BR />Response time less than 8s in all of test cases</P><P>encounter error "cuda out of memory" on max-model-len etc as 4096 or beyond.</P></TD></TR></TBODY></TABLE><P>Here is one of sample log screenshot in SAP AI Core about token# per second of mistral on vLLM. The calculation of avg generation throghput in vLLM in screenshot below seems different from llama.cpp backend. In fact, vLLM's response time is slightly faster than Ollama given the same task in my test cases. Also the response time may also attribute to its quantization method.</P><H4 id="toc-hId-2098478150"><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vllm_token_per_sec_2.jpg" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/91261iDE7E07274970FAF6/image-size/large?v=v2&amp;px=999" role="button" title="vllm_token_per_sec_2.jpg" alt="vllm_token_per_sec_2.jpg" /></span></H4><H4 id="toc-hId-1901964645">&nbsp;</H4><H4 id="toc-hId-1705451140">Mixtral on Ollama, LocalAI and llama.cpp</H4><TABLE border="1" width="100%"><TBODY><TR><TD width="50%"><SPAN><STRONG>Model</STRONG>: <A href="https://ollama.com/library/mixtral:8x7b-instruct-v0.1-q4_0" target="_self" rel="nofollow noopener noreferrer">mixtral:8x7b-instruct-v0.1-q4_0</A> (26 G)</SPAN></TD><TD width="50%"><SPAN>&nbsp;<STRONG>Resource Plan of SAP AI Core</STRONG>: infer.l</SPAN></TD></TR><TR><TD width="50%">Ollama, LocalAI and llama.cpp</TD><TD width="50%">Avg token generation per second: 4~6<BR />Response time take up to 60 s for customer message process use case. It seems due to insufficient GPU VRAM.&nbsp; Resource plan infer.l only has 1 T4 GPU(16 G VRAM)&nbsp; though 58 G RAM. Only 17 layers out of 33 layers in mixtral are offloaded to GPU.</TD></TR></TBODY></TABLE><P>Here is one of sample log screenshot in SAP AI Core about token# per second of mixtral on Ollama, LocalAI and llama.cpp.&nbsp;</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ollama_mixtral_token_per_sec.jpg" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/91330i6FBBF5C5F1AF7054/image-size/large?v=v2&amp;px=999" role="button" title="ollama_mixtral_token_per_sec.jpg" alt="ollama_mixtral_token_per_sec.jpg" /></span></P><H4 id="toc-hId-1508937635">&nbsp;</H4><H4 id="toc-hId-1312424130">Mixtral on vLLM</H4><TABLE border="1" width="100%"><TBODY><TR><TD width="50%"><SPAN><STRONG>Model</STRONG>:&nbsp;<A href="https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-AWQ" target="_self" rel="nofollow noopener noreferrer">Mixtral-8x7B-Instruct-v0.1-AWQ</A> (24.65 G)</SPAN></TD><TD width="50%"><SPAN><STRONG>Resource Plan of SAP AI Core</STRONG>: infer.l</SPAN></TD></TR><TR><TD width="50%"><P>vLLM with the following engine arguments</P><DIV><DIV>--dtype half</DIV><DIV>--gpu-memory-utilization 0.95</DIV><DIV>--enforce-eager</DIV><DIV>--max-model-len 512</DIV><DIV>--max-num-batched-tokens 512</DIV><DIV>--max-num-seqs 512</DIV><DIV>--quantization awq</DIV></DIV></TD><TD width="50%">error with Cuda out of memory even with max-model-len as 512<BR />Likely it is a bug of vLLM according to <A href="https://github.com/vllm-project/vllm/issues/2248" target="_self" rel="nofollow noopener noreferrer">this issue</A></TD></TR></TBODY></TABLE><H4 id="toc-hId-1284094316">&nbsp;</H4><H4 id="toc-hId-1087580811">Llava on Ollama</H4><TABLE border="1" width="100%"><TBODY><TR><TD width="50%"><SPAN><STRONG>Model</STRONG>:&nbsp;<A href="https://ollama.com/library/llava:7b-v1.6" target="_self" rel="nofollow noopener noreferrer">llava:7b-v1.6</A> (4.7 G)</SPAN></TD><TD width="50%"><SPAN><STRONG>Resource Plan of SAP AI Core</STRONG>: infer.s</SPAN></TD></TR><TR><TD width="50%">Ollama</TD><TD width="50%">Avg token generation per second: 40~50<BR />Response time less than 10 s for public facility issue use case with json output.</TD></TR></TBODY></TABLE><H3 id="toc-hId-1184470313"><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ollama_llava_token_per_sec.jpg" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/91370i17B24BEFB9C01213/image-size/large?v=v2&amp;px=999" role="button" title="ollama_llava_token_per_sec.jpg" alt="ollama_llava_token_per_sec.jpg" /></span></H3><H3 id="toc-hId-987956808">Try it out</H3><P>Please refer to <A href="https://github.com/SAP-samples/btp-generative-ai-hub-use-cases/tree/main/10-byom-oss-llm-ai-core" target="_self" rel="nofollow noopener noreferrer">this manual</A> to try it out. The source code of this sample is released under Apache 2.0 license. You should be accountable for your own choice of commercially viable open-source LLMs/LMMs.</P><H2 id="toc-hId-1084846310">Explore further resources on generative AI at SAP</H2><UL><LI><A href="https://community.sap.com/t5/technology-blogs-by-sap/augmenting-sap-btp-use-cases-with-ai-foundation-a-deep-dive-into-the/ba-p/13645289" target="_blank">Augmenting SAP BTP Use Cases with AI Foundation: A Deep Dive into the Generative AI Hub</A></LI><LI><A href="https://www.sap.com/bulgaria/products/artificial-intelligence/generative-ai.html" target="_blank" rel="noopener noreferrer">OpenSAP Course | Generative AI with SAP</A></LI><LI><A href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/models-and-scenarios-in-generative-ai-hub" target="_blank" rel="noopener noreferrer">Generative AI Hub in SAP AI Core</A></LI><LI><A href="https://help.sap.com/docs/ai-launchpad/sap-ai-launchpad/generative-ai-hub" target="_blank" rel="noopener noreferrer">Generative AI Hub in SAP AI Launchpad </A></LI><LI><A href="https://roadmaps.sap.com/board?range=FIRST-LAST&amp;FT=GEN_AI" target="_blank" rel="noopener noreferrer">Generative AI Roadmap</A></LI><LI><A href="https://discovery-center.cloud.sap/serviceCatalog/sap-ai-core?region=all&amp;tab=feature" target="_blank" rel="noopener nofollow noreferrer">Discovery Center | SAP AI Core and Generative AI Hub</A></LI></UL><H2 id="toc-hId-888332805">Summary</H2><P>Self-hosted open-source LLMs in SAP AI Core with BYOM complement SAP Generative AI Hub by combining the efficiency and innovations of open-source LLM community with enterprise-grade security and scalability of SAP AI Core, which make open-source LLMs ready for enterprise. This also open the door of open-source LLM to SAP partners and customer for AI adoption in their business.</P><P><STRONG><EM>Disclaimer</EM></STRONG><EM>: SAP notes that posts about potential uses of generative AI and large language models are merely the individual poster's ideas and opinions, and do not represent SAP's official position or future development roadmap. SAP has no legal obligation or other commitment to pursue any course of business, or develop or release any functionality, mentioned in any post or related content on this website.</EM></P></DIV> 2024-04-04T14:55:04.919000+02:00 https://community.sap.com/t5/technology-blogs-by-sap/ai-foundation-on-sap-btp-q1-2024-release-highlights/ba-p/13639750 AI Foundation on SAP BTP: Q1 2024 Release Highlights 2024-04-05T09:47:35.574000+02:00 Paul_P https://community.sap.com/t5/user/viewprofilepage/user-id/64 <P style=" text-align : left; "><SPAN>AI Foundation is SAP’s all-in-one AI toolkit, offering developers AI that’s ready-to-use, customizable, grounded in business data, and supported by leading generative AI foundation models. It is also the basis for AI capabilities that SAP embeds across its portfolio.</SPAN></P><P style=" text-align : left; "><SPAN><SPAN>If you are not already familiar with the different capabilities of the AI Foundation stack represented below, read this introductory&nbsp;<A href="https://blogs.sap.com/2023/11/30/ai-foundation-saps-all-in-one-ai-toolkit-for-developers/" target="_blank" rel="noopener noreferrer">blog post.<BR /><BR /></A></SPAN></SPAN><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AI-Foundation-SAP-BTP.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/81465i6E1061D8322B1D6B/image-size/large?v=v2&amp;px=999" role="button" title="AI-Foundation-SAP-BTP.png" alt="AI-Foundation-SAP-BTP.png" /></span><SPAN><SPAN><BR /><SPAN>Let's delve into the Q1 2024 release highlights of the AI Foundation, including innovations for the Document Information Extraction service, SAP Translation Hub, SAP AI Core and SAP HANA Cloud.</SPAN>&nbsp;</SPAN></SPAN></P><H2 id="toc-hId-989042936"><STRONG><SPAN>AI Services<SPAN>&nbsp;</SPAN></SPAN></STRONG></H2><H3 id="toc-hId-921612150"><STRONG><SPAN>Document Processing -&nbsp;<A href="https://discovery-center.cloud.sap/index.html#/serviceCatalog/document-information-extraction?region=all" target="_self" rel="nofollow noopener noreferrer">Document Information Extraction<BR /></A></SPAN></STRONG></H3><P style=" text-align : left; "><STRONG><SPAN><SPAN><STRONG>New:&nbsp;<SPAN class=""><SPAN class="">Combine Different Setup Types When Adding Data Fields to Schemas</SPAN></SPAN></STRONG></SPAN></SPAN></STRONG></P><P style=" text-align : left; "><SPAN>Users can now combine header fields with different setup types in the same schema.<BR />They can add header fields with the following setup types to a schema created for a standard document type (e.g. invoice) or custom document type:&nbsp;<SPAN>&nbsp;</SPAN></SPAN></P><UL style=" text-align : left; "><LI><SPAN>auto (with and without a default extractor)<SPAN>&nbsp;</SPAN></SPAN></LI><LI><SPAN><SPAN>manual<SPAN>&nbsp;</SPAN></SPAN></SPAN></LI></UL><P>This extends the scope of the existing standard schemas from SAP, such as for the invoice document and reduce time to value for new business fields (key-value pairs) that need to be extracted from documents.<SPAN>&nbsp;</SPAN></P><P><STRONG>New:&nbsp;<SPAN class=""><SPAN class="">Conversion of Country Specific Unit of Measure Values to&nbsp;ISO&nbsp;Format</SPAN></SPAN></STRONG></P><P><SPAN>The conversion of country specific unit of measure values into ISO format for invoice documents has been improved.<SPAN>&nbsp;For instance, t<SPAN>he processing of certain locale-specific unit of measures (e.g. German 'Stk.' for 'Stück' / 'piece'). Users can expect improved quality of extraction and faster business process execution.<SPAN>&nbsp;</SPAN></SPAN></SPAN></SPAN></P><P><STRONG>New:&nbsp;Purchase order number extraction from line-item level&nbsp;</STRONG></P><P><SPAN>Users can extract purchase order numbers that are available on-line item field level from invoice documents.<SPAN>&nbsp;It allows a faster&nbsp;<SPAN>execution of accounts payable processes when there are multiple PO numbers listed in the tables of supplier invoices.</SPAN></SPAN></SPAN></P><P><STRONG>New:&nbsp;New Invoice Supported Language –&nbsp;Japanese</STRONG></P><P><SPAN>The Document Information Extraction service supports now the Japanese language for invoice documents, improving global coverage.</SPAN></P><P><STRONG>New: Better Models for the Extraction of Standard Document Types</STRONG></P><P>The machine learning models for the extraction of&nbsp;<EM><SPAN class="">invoice,&nbsp;<EM><SPAN class="">paymentAdvice, and&nbsp;<EM><SPAN class="">purchaseOrder&nbsp;</SPAN></EM></SPAN></EM></SPAN></EM><SPAN class=""><SPAN class=""><SPAN class="">documents have been improved.&nbsp;</SPAN></SPAN></SPAN><SPAN class=""><SPAN class=""><SPAN class="">Users can expect improvements in particular when extracting dates, amounts, tax ID, bank accounts.&nbsp;</SPAN></SPAN></SPAN></P><UL><LI><SPAN>Invoices: higher extraction accuracy can be expected for Japan, Hungary, Türkiye, and Romania.&nbsp;<SPAN>&nbsp;</SPAN></SPAN></LI><LI><SPAN>Purchase orders: improved extraction accuracy can be expected for Spanish purchase orders.</SPAN></LI><LI><SPAN><SPAN>Payment advice: more consistent column extraction and improved extraction of amounts in line-items.</SPAN></SPAN></LI></UL><P>Get started with <A href="https://discovery-center.cloud.sap/index.html#/serviceCatalog/document-information-extraction?region=all" target="_self" rel="nofollow noopener noreferrer">Document Information Extraction.</A></P><H3 id="toc-hId-725098645"><STRONG><SPAN>Machine Translation -&nbsp;<A href="https://discovery-center.cloud.sap/index.html#/serviceCatalog/sap-translation-hub?region=all" target="_self" rel="nofollow noopener noreferrer">SAP Translation Hub</A></SPAN></STRONG></H3><P><STRONG>New: User settings for the document translation UI&nbsp;</STRONG></P><P><SPAN>Users can define the preferred UI language and theme in the application, which will be carried over across software and document translation UIs, thus improving the overall user experience.<SPAN>&nbsp;<SPAN>They can also define the preferred source and target languages to translate content using the application, which will apply only while using the document translation UI. It automates the translation process by not having to define the source and target language every time the application opens.<SPAN>&nbsp;</SPAN></SPAN></SPAN></SPAN></P><P><STRONG>New: Updated tile in SAP BTP</STRONG></P><P><SPAN class=""><SPAN class="">As part of the efforts of migrating the application<SPAN class=""> for <SPAN class="">software <SPAN class="">translation<SPAN class=""> to the multi-cloud environment, the tile available on SAP Business Technology Platform has been renamed, from Document Translation to SAP Translation Hub. <SPAN class="">T<SPAN class="">hat’s <SPAN class="">one of the last steps towards completing the migration planned in Q2 2024.<STRONG><BR /></STRONG></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P><P><SPAN class=""><SPAN class="">Get started with <A href="https://discovery-center.cloud.sap/index.html#/serviceCatalog/sap-translation-hub?region=all" target="_self" rel="nofollow noopener noreferrer">SAP Translation Hub.</A></SPAN></SPAN></P><H2 id="toc-hId-399502421">Generative AI Management &amp; AI Workload Management</H2><H3 id="toc-hId-332071635"><STRONG><SPAN class=""><A href="https://discovery-center.cloud.sap/index.html#/serviceCatalog/sap-ai-core?region=all" target="_self" rel="nofollow noopener noreferrer">SAP AI Core</A></SPAN></STRONG></H3><P><STRONG><SPAN class=""><SPAN class="">New:&nbsp;Availability of additional large language models in the generative AI hub</SPAN></SPAN></STRONG></P><P><SPAN>Integration of additional large language models (LLM):</SPAN></P><UL><LI>Google PaLM 2 for text (text-bison), PaLM 2 for chat (chat-bison), and embeddings for text (textembedding-gecko)</LI><LI>Google Gemini Pro</LI><LI>Updates to Microsoft Azure OpenAI model versions</LI></UL><P>You can now leverage a greater selection of "best-to-fit" LLMs for your use case, ease exploration over market-leading generative AI models, without the need to go through lengthy contractual, legal discussions and finally harmonize lifecycle management across models.</P><P>Find more information <A href="https://me.sap.com/notes/3437766" target="_blank" rel="noopener noreferrer">here</A>.</P><P><STRONG><SPAN class=""><SPAN class="">New: <SPAN class="">SDK for support of large language models<BR /></SPAN></SPAN></SPAN></STRONG></P><P><SPAN>We introduced a series of features in SAP AI Core:<SPAN>&nbsp;</SPAN></SPAN></P><UL><LI><SPAN>Technical libraries that simplify inference on large language models (LLMs) by automatically injecting the correct headers and paths into each request. It improves the extensibility, allowing users to add additional adaptations as needed.<SPAN>&nbsp;</SPAN></SPAN></LI><LI><SPAN>Tooling for the effective integration and use of LLMs with LangChain in the context of the generative AI hub. It simplifies the developer experience with ready-to-use libraries for access to LLMs deployed using the generative AI hub.<SPAN>&nbsp;</SPAN></SPAN></LI><LI><SPAN><SPAN>A new library, the </SPAN></SPAN><A href="https://pypi.org/project/generative-ai-hub-sdk/" target="_self" rel="nofollow noopener noreferrer">ai-core-llm-sdk</A>, in addition to enhancements to the existing <EM>ai-core-sdk</EM>, to accommodate the required changes to support LLM access. It boosts efficiency when working with various LLM models by streamlining the deployment of LLM models and the querying of available models.</LI></UL><P>Get started with <A href="https://discovery-center.cloud.sap/index.html#/serviceCatalog/sap-ai-core?region=all" target="_self" rel="nofollow noopener noreferrer">SAP AI Core.</A></P><H2 id="toc-hId-6475411"><STRONG><SPAN>Business Data &amp; Context<SPAN>&nbsp;</SPAN></SPAN></STRONG></H2><H3 id="toc-hId--60955375"><A href="https://discovery-center.cloud.sap/missiondetail/3643/3686/" target="_blank" rel="noopener nofollow noreferrer"><STRONG><SPAN>SAP HANA Cloud</SPAN></STRONG></A></H3><P><STRONG>New: Support for storage and retrieval of vector embeddings in SAP HANA Cloud, called SAP HANA Cloud vector engine&nbsp;<SPAN>&nbsp;</SPAN></STRONG></P><P><SPAN>A vector datastore manages unstructured data - such as text, images, or audio - in high-dimensional vector space as vector embeddings, to provide long-term memory and better context to AI models. This makes it easy to find and retrieve similar objects quickly, for example, by asking a question using natural language. This both simplifies interactions with large language models (LLMs) and empowers developers to securely implement generative AI in applications.<SPAN>&nbsp;</SPAN></SPAN></P><P>SAP HANA Cloud vector engine can now natively store and search vector embeddings, which are numerical representations of objects, along with business data as part of its industry-leading multi-model processing capabilities to power intelligent data applications.</P><P>With these vector capabilities, SAP HANA Cloud will enable Retrieval Augmented Generation (RAG), facilitating the combination of LLMs with private business data. These applications learn and adapt to new information, enabling automated decision-making.</P><P>Key benefits of the SAP HANA Cloud vector engine include:</P><UL><LI><STRONG>Multi-model</STRONG>: Users can unify all types of data into a single database to build innovative applications using an efficient data architecture and in-memory performance. By adding vector storage and processing to the same database already storing relational, graph, spatial, and even JSON data, application developers can create next-generation solutions that interact more naturally with the user.</LI><LI><STRONG>Enhanced search and analysis</STRONG>: Businesses can now apply semantic and similarity search to business processes using documents like contracts, design specifications, and even service call notes.</LI><LI><STRONG>Personalized recommendations</STRONG>: Users can benefit from an improved overall experience with more accurate and personalized suggestions.</LI><LI><STRONG>Optimized large language models</STRONG>: The output of LLMs is augmented with more effective and contextual data.</LI></UL><P>To deep dive into the&nbsp;<SPAN>SAP HANA Cloud Vector Engine, read these blog posts by our experts:</SPAN></P><UL><LI><A href="https://community.sap.com/t5/technology-blogs-by-sap/vectorize-your-data-sap-hana-cloud-s-vector-engine-for-unified-data/ba-p/13579558" target="_blank"><SPAN>Vectorize your Data: SAP HANA Cloud's Vector Engine for Unified Data Excellence</SPAN></A></LI><LI><A href="https://community.sap.com/t5/technology-blogs-by-sap/from-developer-s-desk-sap-hana-cloud-vector-engine/ba-p/13589792" target="_blank"><SPAN>From Developer's Desk: SAP HANA Cloud Vector Engine</SPAN></A></LI></UL><H2 id="toc-hId--386551599"><STRONG>Build business-ready AI applications with SAP and stay updated!&nbsp;</STRONG></H2><UL><LI><SPAN>Leverage the AI Foundation capabilities by visiting the <A href="https://discovery-center.cloud.sap/index.html#/viewServices?category=ai" target="_self" rel="nofollow noopener noreferrer">SAP Discovery Center</A>. Compare and select the service that fits most to your business needs. </SPAN></LI><LI><SPAN>Explore the <A href="https://roadmaps.sap.com/board?range=FIRST-LAST&amp;PRODUCT=73554900100800002858&amp;PRODUCT=73554900100800002861&amp;PRODUCT=73554900100800002881&amp;PRODUCT=73554900100800003641&amp;PRODUCT=73554900100800003847&amp;PRODUCT=73555000100800000086&amp;PRODUCT=73555000100800003283#Q4%202023" target="_self" rel="noopener noreferrer">AI Foundation roadmap</A> to discover past and upcoming innovations.&nbsp;</SPAN></LI><LI><SPAN><SPAN>Engage with our community of SAP experts through <A href="https://pages.community.sap.com/topics/machine-learning" target="_self" rel="noopener noreferrer">Q&amp;A and blog posts</A>.</SPAN></SPAN></LI></UL><P>See you next quarter for exciting innovations!</P> 2024-04-05T09:47:35.574000+02:00 https://community.sap.com/t5/gurugram-blog-posts/sap-stammtisch-plus-gurgaon-may-2024-h1/ba-p/13678318 SAP Stammtisch Plus - Gurgaon - May 2024 (H1) 2024-04-22T16:27:18.510000+02:00 Chandra_Bhushan https://community.sap.com/t5/user/viewprofilepage/user-id/123700 <P><SPAN>Dear SAP Community Members,</SPAN><BR /><BR /><SPAN>We are planning to run SAP Stammtisch Plus in Gurgaon - May 2024(H1). Details will be shared very soon.</SPAN><BR /><SPAN>Let us get together to participate, connect and benefit from our peer community members on latest insights from&nbsp;</SPAN><A href="https://www.linkedin.com/company/sap/" target="_blank" rel="noopener nofollow noreferrer">SAP</A><SPAN>&nbsp;on:</SPAN><BR /><A href="https://www.linkedin.com/feed/hashtag/?keywords=sapbusinessai&amp;highlightedUpdateUrns=urn%3Ali%3Aactivity%3A7188068071461339138" target="_blank" rel="noopener nofollow noreferrer">1. #SAPBusinessAI</A><SPAN>,</SPAN><BR /><A href="https://www.linkedin.com/feed/hashtag/?keywords=genai&amp;highlightedUpdateUrns=urn%3Ali%3Aactivity%3A7188068071461339138" target="_blank" rel="noopener nofollow noreferrer">2. #GenAI</A><SPAN>,</SPAN><BR /><A href="https://www.linkedin.com/feed/hashtag/?keywords=saphanacloud&amp;highlightedUpdateUrns=urn%3Ali%3Aactivity%3A7188068071461339138" target="_blank" rel="noopener nofollow noreferrer">3. #SAPHANACloud</A><SPAN>&nbsp;Vector Engine,</SPAN><BR /><SPAN>4. Retrieval Augmented Generation(</SPAN><A href="https://www.linkedin.com/feed/hashtag/?keywords=rag&amp;highlightedUpdateUrns=urn%3Ali%3Aactivity%3A7188068071461339138" target="_blank" rel="noopener nofollow noreferrer">#RAG</A><SPAN>),</SPAN><BR /><SPAN>5. Knowledge Graph,</SPAN><BR /><SPAN>6. Enterprise Automation and much more.</SPAN></P><P><SPAN>Thank you to all the community members from another SAP Community Member!</SPAN></P><P><SPAN>Chandra</SPAN></P><P><A href="https://www.linkedin.com/feed/hashtag/?keywords=sapcommunity&amp;highlightedUpdateUrns=urn%3Ali%3Aactivity%3A7188068071461339138" target="_blank" rel="noopener nofollow noreferrer">#SAPCommunity</A><SPAN>&nbsp;</SPAN><A href="https://www.linkedin.com/feed/hashtag/?keywords=sapstammtischggn&amp;highlightedUpdateUrns=urn%3Ali%3Aactivity%3A7188068071461339138" target="_blank" rel="noopener nofollow noreferrer">#SAPStammtischPlusGGN</A><SPAN>&nbsp;</SPAN><A href="https://www.linkedin.com/feed/hashtag/?keywords=sapchampion&amp;highlightedUpdateUrns=urn%3Ali%3Aactivity%3A7188068071461339138" target="_blank" rel="noopener nofollow noreferrer">#SAPChampion</A></P> 2024-04-22T16:27:18.510000+02:00 https://community.sap.com/t5/technology-blogs-by-members/vectorize-your-data-for-infuse-ai-in-to-business-using-hana-vector-and/ba-p/13684158 Vectorize your data for Infuse AI in to Business using Hana Vector and Generative AI 2024-04-27T05:08:45.073000+02:00 Julian_B https://community.sap.com/t5/user/viewprofilepage/user-id/157589 <P><FONT size="5">&nbsp; &nbsp; &nbsp; &nbsp; <STRONG><U>Vectorize your data for Infuse AI in to your Business&nbsp;</U></STRONG></FONT></P><P><FONT size="4">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<STRONG><U>using SAP HANA Vector Engine, RAG &amp; BTP Gen-AI</U></STRONG></FONT></P><P><STRONG><U>1. Introduction:</U></STRONG></P><P>SAP Generative AI HUB and SAP HANA Vector Engine enable businesses to harness the power of AI .</P><P>SAP HANA Vector Engine is a high-performance in-memory computing engine that leverages vectorized processing techniques to achieve lightning-fast data analysis. By vectorizing business data, the engine enables businesses to process vast amounts of information in parallel, significantly reducing query execution times.</P><P>This blog post aims to inform you on how we are enhancing SAP's partner foundation AI model for utilization towards our business cases. We will also discuss how we utilize tools from SAP Gen AI and SAP HANA Vector Engine, as well as RAG techniques, to incorporate AI into our business use case.</P><P>The blog offers a comprehensive, step-by-step guide for implementing the GenAI RAG feature into your business operations.</P><P><STRONG><U>2 Adapt GenAI in to Business </U></STRONG></P><P>To adapt GenAI in to business , we have started with task specific instructions like RAG and Zero shot prompting.</P><P>AI capabilities have already been embedded in most of the SAP business processes through a tool known as JOULE. This digital assistant aids users in text summarization, writing, question &amp; answering, and code generation.</P><P>Within the BTP AI Foundation, the SAP AI Launchpad serves as the gateway to access GenAI HUB, ML operations, and the prompt editor. From the GenAI Hub, users can easily access any partner-built or SAP-built foundation models.</P><P>Users can easily access to the prompt engineering has been configured with foundation models. From this tool you can easily leverage the Gen AI capabilities such as text summarization, writing, question &amp; answering, code generation, sentiment analysis, and auto-responses for customer service …etc. to your business.</P><P>Furthermore, it also effectively identifies potential risks and fraudulent activities through comprehensive data analysis, swiftly detecting any present anomalies. This unique solution significantly enhances customer satisfaction by adeptly responding to customer queries, ensuring a seamless and personalized experience.</P><P>Moreover, with its extraordinary ability to analyze extensive customer data, AI offers personalized recommendations and experiences tailored to each individual business's needs.</P><P><STRONG><U>3. Author</U></STRONG></P><P><STRONG><U>Julian Bellarmin</U></STRONG>&nbsp;working as a SAP certified cloud solution BTP architect in Tech Mahindra .</P><P><STRONG>Kedar Kulkarni</STRONG>&nbsp;Leading SAP BTP competency solutions.</P><P><STRONG>Saranya Sampath </STRONG>working as a BTP consultant.</P><P><STRONG><U>4.Vectorization , Retrieval &nbsp;and Generation:</U></STRONG></P><P><STRONG><U>&nbsp;4.1&nbsp;</U></STRONG><STRONG><U>Process Flow Diagram:</U></STRONG></P><P>&nbsp;</P><P><span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="S0022939779_0-1714184786747.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102558i83F6996C3283801A/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_0-1714184786747.png" alt="S0022939779_0-1714184786747.png" /></span></P><UL class="lia-list-style-type-disc"><LI><FONT size="1 2 3 4 5 6 7">New column Data type: REAL_VECTOR</FONT></LI><LI><FONT size="1 2 3 4 5 6 7">New vector Constructor :&nbsp; TO_REAL_VECTOR</FONT></LI><LI><FONT size="1 2 3 4 5 6 7">New similarity search distance function:L2DISTANCE(),COSINE_SIMILARITY()</FONT></LI></UL><P><STRONG><U>4.2 Process Steps :</U></STRONG></P><P><STRONG><U>Upload function:</U></STRONG></P><OL><LI>we are collecting the TEXT and PDF document from the directory .</LI><LI>Converting all the documents in to chunks.</LI><LI>Converting all the chunks in to text embeddings through Gen AI HUB Proxy-lang chain embedding libraries and text-embedding ada model 002.</LI><LI>Converting all the embeddings in to vectors by TO_REAL_VECTOR constructor.</LI><LI>Storing the embeddings as vectors into HANA cloud vector DB.</LI></OL><P><STRONG><U>Semantic Search function:</U></STRONG></P><OL><LI>Getting the user query.</LI><LI>Converting the query in embeddings.</LI><LI>Performing the cosine similarity search by passing the query vector.</LI><LI>Extracting the top ranked results.&nbsp;</LI></OL><P><STRONG><U>Text Generation through LLM:</U></STRONG></P><OL><LI>Refine the prompting context according to the specific business requirements.</LI><LI>Passing the context and search result to partner Build foundation Models - GPT-35-TURBO/ GPT4 LLM.</LI><LI>Capturing the LLM response and display to the user.</LI></OL><P><STRONG><U>5 Configuration of BTP AI services.</U></STRONG></P><P><STRONG><U>5.1 </U></STRONG><STRONG>Pre-Requisites:</STRONG></P><UL><LI>SAP BTP Enterprise Account.</LI><LI>SAP AI Core should be in your global account this has to be in extended service plan.</LI><LI>SAP AI Launchpad should be in standard service plan.</LI><LI>SAP HANA Instance – For configure the REAL VECTOR</LI><LI>If you are using trial version, then you can update this to extended / standard service plan.</LI></UL><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_2-1714185045166.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102559iF8F412EEAD0512C0/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_2-1714185045166.png" alt="S0022939779_2-1714185045166.png" /></span></P><P>&nbsp;</P><P><STRONG><U>5.2&nbsp;</U></STRONG><STRONG>Configuration in BTP Launchpad</STRONG></P><P><STRONG>5.2.1&nbsp;</STRONG><STRONG>Roles Assignment:</STRONG></P><P>You need to have the right roles and permission to access the GEN AI Hub , AI Launchpad , ML Operations, Work space&nbsp; and AI core admin.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_3-1714185126121.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102560i6EE1026B536A0CE1/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_3-1714185126121.png" alt="S0022939779_3-1714185126121.png" /></span></P><P>5.2.2&nbsp;<STRONG>Service Key Creation:</STRONG></P><P>Create the service Keys for AI CORE Instance. You can create your own service keys and get the credentials to make the connection between AI Core and python colab tool</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_4-1714185176596.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102561i5956638581C8EDF0/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_4-1714185176596.png" alt="S0022939779_4-1714185176596.png" /></span></P><P><STRONG>5.2.3 Connection and Resource Group Creation:</STRONG></P><P>You can create your ai-core connection and resource group. Here ‘default’ will be the resource group name.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_5-1714185210562.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102562iE2926365BDB44606/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_5-1714185210562.png" alt="S0022939779_5-1714185210562.png" /></span></P><P><STRONG>5.2.4 Validate your Foundation Model - AZURE-OPENAI:</STRONG></P><P><STRONG>&nbsp;</STRONG>Click on the AI launchpad Go to&nbsp;<STRONG>ML Operations</STRONG>&nbsp;-&gt;&nbsp;<STRONG>Scenarios</STRONG>.</P><P>Check whether the&nbsp;<STRONG>foundation-models</STRONG>&nbsp;scenario is present in your AI-Core workspace.</P><P>Click on the Azure-openai link to know your model supported in AI core by default.</P><P>Here we are using gpt-35-turbo , gpt-4 and text-embedding-ada-002</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_6-1714185253811.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102563iFDB567199F316940/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_6-1714185253811.png" alt="S0022939779_6-1714185253811.png" /></span></P><P>&nbsp;</P><P>You can see the list of supported model in AI core – as of APR 26-2024.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_7-1714185253821.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102564i22BE2CE709FDD9A4/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_7-1714185253821.png" alt="S0022939779_7-1714185253821.png" /></span></P><P><STRONG>5.3 Model Configuration:</STRONG></P><P>Go to&nbsp;ML Operations&nbsp;-&gt;&nbsp;Configurations. Click on the&nbsp;Create&nbsp;button to configure the models.</P><P>Enter the parameters and click on Next button.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_8-1714185314495.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102565i350CD66D6A684A0B/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_8-1714185314495.png" alt="S0022939779_8-1714185314495.png" /></span></P><P>Feed your required foundation model name and version.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_9-1714185314500.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102567i3B6B706BBBC44975/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_9-1714185314500.png" alt="S0022939779_9-1714185314500.png" /></span></P><P>&nbsp;</P><P>You can see your configured model , once it has been created.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_10-1714185314517.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102566i320D6EAD289371AB/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_10-1714185314517.png" alt="S0022939779_10-1714185314517.png" /></span></P><P>&nbsp;</P><P><STRONG>5.4 Creating your deployment model:</STRONG></P><P>Create your deployment which is supported&nbsp; by the foundation model.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_11-1714185314534.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102569i4D2D3F7ACB044181/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_11-1714185314534.png" alt="S0022939779_11-1714185314534.png" /></span></P><P>&nbsp;</P><P>Choose your executables from the below options.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_12-1714185314548.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102570i4AD86A5988477429/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_12-1714185314548.png" alt="S0022939779_12-1714185314548.png" /></span></P><P>Once you created the deployment model , wait for the current status to be set to RUNNING.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_13-1714185314552.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102568iBCC9F2D5664B9478/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_13-1714185314552.png" alt="S0022939779_13-1714185314552.png" /></span></P><P>&nbsp;</P><P>Note down your deployment model id , which will be used when you want to use the LLM context.</P><P><STRONG>5.5 Validate the prompts with the deployed model</STRONG></P><P>In the Generative AI Hub, you can manage your prompts in the Prompt Management page. Go to&nbsp;Generative AI Hub&nbsp;-&gt;&nbsp;Prompt Management. Here you can click on a prompt to go to its details page</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_14-1714185399337.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102572iF1DE84C225E8A732/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_14-1714185399337.png" alt="S0022939779_14-1714185399337.png" /></span></P><P>&nbsp;</P><P>Configure the parameters for the model response.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_15-1714185399339.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102571iBD56DBA1169B880D/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_15-1714185399339.png" alt="S0022939779_15-1714185399339.png" /></span></P><P>&nbsp;</P><P><U>Frequency Penalty:</U></P><P>Number can be between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model’s likelihood to repeat the same line verbatim.</P><P><U>Presence Penalty :</U></P><P>Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model’s likelihood to talk about new topics.</P><P><U>Max-Tokens :</U></P><P>The maximum number of tokens allowed for the generated answer.</P><P>You need to increase the response token size to get the larger result data.</P><P><U>Temperature :</U></P><P>What sampling temperature to use, between 0 and 2. Higher values will make the output more random, while lower values will make it more focused and deterministic.</P><P>You can validate your prompts with different contexts.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_16-1714185399350.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102573iFFF5614F5B1A0957/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_16-1714185399350.png" alt="S0022939779_16-1714185399350.png" /></span></P><P><STRONG><U>6. Create of HANA Cloud Vector Instance</U></STRONG></P><P>From APR 2024 onwards , SAP supports&nbsp; REAL_VECTOR column in Hana DB containers. Create your Hana cloud instance and note down your DBADMIN credentials , host name &amp; port number which will be used again to make the connection. Start the instance through click on hana cloud central. Once it’s started Open your Data Base explorer.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_17-1714185460252.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102574i9AD5E692BD686773/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_17-1714185460252.png" alt="S0022939779_17-1714185460252.png" /></span></P><P><STRONG><U>7 Vectorize your PDF and TEXT file:</U></STRONG></P><P><STRONG>7.1 Pre-requisites:</STRONG></P><P>Python3 installed in your system.[ You can use google colab]</P><P>Have generative-ai-hub-sdk&nbsp; installed in your system.</P><P>[With this SDK you can use all the generative&nbsp; Models available in SAP's gen AI hub.]</P><P><STRONG>7.2 Create the folder directory&nbsp; and upload the text / PDF files.</STRONG></P><P>&nbsp;</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_18-1714185533410.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102575i4CF0DAB257F7BAC1/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_18-1714185533410.png" alt="S0022939779_18-1714185533410.png" /></span></P><P>&nbsp;</P><P>7.3&nbsp;&nbsp;<STRONG>install the HANA ML and GenAI Hub SDK libraries</STRONG></P><P>With this SDK you can leverage the power of generative Models like chatGPT available in SAP's generative AI hub.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_19-1714185572276.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102576i4307A72339025953/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_19-1714185572276.png" alt="S0022939779_19-1714185572276.png" /></span></P><P>&nbsp;</P><P><STRONG>7.4 Set the environment variable.</STRONG></P><P>Update your AI core service key credentials and execute the below script to set the ENV variables.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_20-1714185594185.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102577iE7B0AE3361D16082/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_20-1714185594185.png" alt="S0022939779_20-1714185594185.png" /></span></P><P><STRONG>7.5 Make the &nbsp;Connection Context to the HANA Vector store</STRONG></P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_21-1714185594192.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102578i82F4AAFE80BA3940/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_21-1714185594192.png" alt="S0022939779_21-1714185594192.png" /></span></P><P>&nbsp;</P><P>Import the DBAPI libraries to invoke the connection.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_22-1714185594195.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102579iBC88330FA9810A4F/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_22-1714185594195.png" alt="S0022939779_22-1714185594195.png" /></span></P><P><STRONG>7.6 Converting all the documents in to chunks</STRONG></P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_23-1714185629957.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102582iA58A90D8F74499DF/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_23-1714185629957.png" alt="S0022939779_23-1714185629957.png" /></span></P><P>Use the below libraries for the PDF documents.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_24-1714185629958.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102580i19A72D2AB3A579C4/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_24-1714185629958.png" alt="S0022939779_24-1714185629958.png" /></span></P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_25-1714185629959.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102581i7A2983D93CB6B50A/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_25-1714185629959.png" alt="S0022939779_25-1714185629959.png" /></span></P><P>Use the below libraries for the text documents.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_26-1714185629960.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102584i7C55BD3DB601D557/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_26-1714185629960.png" alt="S0022939779_26-1714185629960.png" /></span></P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_27-1714185629962.png" style="width: 721px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102583i0A770BC0942A4EB2/image-dimensions/721x113?v=v2" width="721" height="113" role="button" title="S0022939779_27-1714185629962.png" alt="S0022939779_27-1714185629962.png" /></span></P><P>You can check the size of the chunks of your file by execute the len(text_chunks)script.</P><P>Based on the business data , you have to carefully set the chunk size and its overlap size.</P><P>&nbsp;</P><P><STRONG>7.7 Converting all the chunks in to embeddings and store it as vectors in HANA vector DB</STRONG></P><P>For converting my text /pdf file in to embeddings , we are using langchain init embedding libraries.</P><P>For that we are using text-embedding-ada-002 model.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_28-1714185703434.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102585i64E0168E977D7576/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_28-1714185703434.png" alt="S0022939779_28-1714185703434.png" /></span></P><P>Once you have executed the above script , you can see the “MyTest_VecTable” has been created in the Hana DB with REAL_VECTOR data type.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_29-1714185703443.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102586iD9977EB506462F59/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_29-1714185703443.png" alt="S0022939779_29-1714185703443.png" /></span></P><P>You can open the table data and see all your chunks will be converted vectors in the REAL_VECTOR column.</P><P><U>Note:</U> Don’t use the data upload option to load these vectors. That will give the error.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_30-1714185703457.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102587i48D228729522A1C5/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_30-1714185703457.png" alt="S0022939779_30-1714185703457.png" /></span></P><P>&nbsp;</P><P><STRONG><U>8 Extract query results from&nbsp; vector DB:</U></STRONG></P><P>Now its’s time to validate the vector Store and GEN AI Deployment Models by pass the user prompt query.</P><P><STRONG><U>8.1 Getting the user query and Convert the query in to embeddings.</U></STRONG></P><P>We are using text-embedding-ada-002 / text-embedding-ada-002-v2 model for convert the input query strings to Embedding Text.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_31-1714185814076.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102588iD117D88B52D22BC8/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_31-1714185814076.png" alt="S0022939779_31-1714185814076.png" /></span></P><P>&nbsp;</P><P><STRONG><U>8.2 Performing the cosine similarity search by pass the query vector.</U></STRONG></P><P>You need to Pass the ‘Embedding text query’&nbsp; in to ‘vector store’ by&nbsp; passing ‘select SQL query’ for fetch highly matching results. You can use L2DISTANCE&nbsp; or COSINE_SIMILARITY functions based on your need.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_32-1714185835681.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102590i86C7C306B565B7AA/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_32-1714185835681.png" alt="S0022939779_32-1714185835681.png" /></span></P><P>&nbsp;</P><P><STRONG><U>8.3 </U></STRONG><STRONG>Extracting the top ranked results.</STRONG></P><P>You can verify the TOP ranking chunk results which is returned from the hana vector store.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_33-1714185835683.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102589i8AB5FF02BB58C2CA/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_33-1714185835683.png" alt="S0022939779_33-1714185835683.png" /></span></P><P><STRONG><U>9. T</U></STRONG><STRONG><U>ext Generation through LLM:</U></STRONG></P><P><STRONG><U>9.1 </U></STRONG><STRONG>Configure the prompting context&nbsp; based on the business requirement.</STRONG></P><P>Prompt is guiding GenAI models to produce desired output.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_34-1714185877400.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102591i0B6082F6675F5B5C/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_34-1714185877400.png" alt="S0022939779_34-1714185877400.png" /></span></P><P>&nbsp;</P><P><STRONG>9.2 Pass and Fetch the response from &nbsp;GenAI Hub Deployed model.</STRONG></P><P>In this use case, we are fetching the results based on the RAG [Retrieval Augmented Generation] flag. Make sure that , you are using the right deployment model– which you configured in AI HUB.&nbsp;</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_35-1714185913717.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102592i1280CDF43503C2AA/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_35-1714185913717.png" alt="S0022939779_35-1714185913717.png" /></span></P><P><STRONG>9.3 Capture the&nbsp; LLM response from the model and display it.</STRONG></P><P>Here I have set my RAG Flag is True.</P><P>You can see the response which is generated by GPT-35-Turbo based on the context which is returned from vector store.</P><P>&nbsp;</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_36-1714186021367.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102593i6930EF2BC842652F/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_36-1714186021367.png" alt="S0022939779_36-1714186021367.png" /></span></P><P>Now modify the [ Retrieval Augmented Generation] RAG flag is false. Then see the response which is directly comes from LLM without referring to HANA vector results.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_37-1714186021374.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102594i1018A2E6CF5EA848/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_37-1714186021374.png" alt="S0022939779_37-1714186021374.png" /></span></P><P>Now your model is good to respond for any question based on the RAG flag.</P><P><STRONG><U>10.Create User Interactive to demo the RAG technique</U></STRONG></P><P>Here is the script to create the user interactive components. Put all your queries in to option array list.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_38-1714186168403.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102597i67397A8FE17344E3/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_38-1714186168403.png" alt="S0022939779_38-1714186168403.png" /></span></P><P>Make the RAG is False by un-select the check box and click ASK LLM button and see the response.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_39-1714186168408.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102599i0F90F6FFD1D0DDDA/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_39-1714186168408.png" alt="S0022939779_39-1714186168408.png" /></span></P><P>Make the RAG is True by select the check box and click ASK LLM button and see the response.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S0022939779_40-1714186168410.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/102598i11CA53477FFBAE12/image-size/large?v=v2&amp;px=999" role="button" title="S0022939779_40-1714186168410.png" alt="S0022939779_40-1714186168410.png" /></span></P><P>&nbsp;</P><P>11.&nbsp;<STRONG><U>Conclusion:</U></STRONG></P><P>&nbsp;Infusion of AI capabilities ultimately results in improved business outcomes, enhanced decision-making, and a competitive edge in the market. After this simple use case , &nbsp;understood that, we can do classification, Answering Questions, content generation , zero shot prompting (Task Automation) , Creative writing, language translation ,Personalized Interaction, sensitivity analysis ,summarization, Zero shot prompting , extract content….etc. to our business use case.</P><P>This blog provides a comprehensive understanding of the seamless data loading and extraction process using the powerful HANA VECTOR DB and GEN AI solution to achieve the RAG AI feature.</P><P>You can also see how accurately this multi-dimensional Hana vector engine fetching the results and your how your LLM deployment model is helping you for generate text based on the context provided for end users.</P><P>&nbsp;</P> 2024-04-27T05:08:45.073000+02:00 https://community.sap.com/t5/technology-blogs-by-members/be-a-cockroach-a-simple-guide-to-ai-and-sap-full-stack-development-part-i/ba-p/13696633 Be a Cockroach: A Simple Guide to AI and SAP Full-Stack Development - Part I 2024-05-09T19:14:30.935000+02:00 karthikarjun https://community.sap.com/t5/user/viewprofilepage/user-id/123682 <P><STRONG><U>Disclaimer</U></STRONG>: This blog delves into SAP full-stack development, incorporating SAP RAP for both front-end and back-end functionalities, Integration Suite for middleware tasks, TensorFlow for AI/ML modeling, and crafting a personalized system dashboard. Geared towards simplifying complex business systems through engaging stories, it's for those wanting to understand these concepts. If you're already well-versed, feel free to just stop here and explore other content.</P><P><STRONG><U>I) Introduction (Story):</U></STRONG></P><P>Most people came here to see what he has to say about cockroaches and their connection to SAP development. Some might be curious to learn about it. Few of you could feel grossed out and think cockroaches are yucky and ugly! <STRONG>But after reading this section, I hope you'll respect these special creatures called “COCKROACH”.</STRONG></P><P>The world is more than 200,000 years old. Lots of animals have lived and expired over time. One of them was dinosaurs—they were huge and strong. Due to changes in the tectonic plates and environment, the Dinosaurs couldn't survive and disappeared. Now, you can see it in movies using computer-generated effects. However, cockroaches have been around for over 1,00,000 years and you can still come across them in your kitchen, living room, bathroom, trash can, and everywhere else. Cockroaches have adjusted to changes in their surroundings, which is why they still exist on the planet.</P><P>Even though companies produce items like HIT and Baygon to kill them, cockroaches survive by figuring out how to deal with those products. A study found that certain products cause some cockroaches to behave as if they're intoxicated. Their bodies adapt to these substances. This ability to change is known as adaptation.</P><P>There aren't any charities or groups dedicated to protecting cockroaches like there are for elephants and dolphins. Everyone wants to kill cockroach, yet these humble cockroaches keep on living and undefeated by human, and their existence is inevitable. Now that you understand, I trust you hold a greater appreciation for the modest cockroach. <EM><U>Similarly, Consultants must also adjust to shifts in market trends.</U></EM></P><P>The IT market is going through changes like <STRONG><U>"Artificial Intelligence"</U></STRONG> and a higher demand for <STRONG><U>“SAP Full-Stack developers”</U></STRONG> and so on. In this blog we are go-through about SAP Full-Stack development.</P><P><EM>(The story about cockroaches was inspired by a book called "11 Rules for Life" written by Chetan Bhagat)</EM></P><P><STRONG><U>II) Agenda:</U></STRONG></P><OL><LI>Getting to Know SAP FullStack: Understanding the Full Stack</LI><LI>Background Insights: Delving into the Story Behind</LI><LI>System Design Visualization: Seeing the Technical Architecture</LI><LI>Practical Implementation: Learning the Practical Details Step-by-Step</LI><LI>Wrapping Up: Summarizing Key Points and Looking Ahead</LI><LI>Further Reading: Offering Links to More Research Materials</LI></OL><P><STRONG><U>III) Getting to Know SAP Full-Stack: Understanding the SAP Full-Stack development</U></STRONG></P><P>Many of our consultants believe that full stack development involves only front-end and back-end development. However, when it comes to SAP development, there's a third component: middleware.</P><P>In today's market, relying on just one system isn't enough. Data comes from various sources, and we need to consolidate it to generate reports. So, if you're interested in becoming an SAP full-stack developer, this blog will help you understand the basics of all three elements: front-end, middleware, and back-end, and explain them practically.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="karthikarjun_7-1715273481121.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/108136i9CE213319E0DD8FE/image-size/large?v=v2&amp;px=999" role="button" title="karthikarjun_7-1715273481121.png" alt="karthikarjun_7-1715273481121.png" /></span></P><P style=" text-align: center; ">Fig1: Basic diagram for Full-Stack development</P><P><STRONG><U>IV) Background Insights: Delving into the Story Behind</U></STRONG></P><P>Sundhara Pandian is a big part of Kotravai Coffee Group in Queenstown, New Zealand. He makes really good coffee. His trick? He gets top-notch coffee beans by following a careful process.</P><P>Instead of just buying beans whenever he wants, Sundhara Pandian sends a request called a Purchase Order (PO) to a big coffee supplier in Bremen, Germany. But it's not as simple as filling out a form. The PO has to go through a smart system with AI and automation. This system checks the beans in the supplier's stock and confirms the order.</P><P>But Sundhara Pandian's job doesn't stop there. The results from the system are put into SAP S/4HANA Cloud. This helps keep track of orders and how much coffee is left.</P><P>Basically, Sundhara Pandian does more than just make coffee. He's good at handling &nbsp;complicated systems to make sure Queenstown always has enough beans for coffee lovers.</P><P><EM>Let's dive into SAP full-stack development through Sundara Pandian's story as we build the SAP RAP App for PO cockpit, iFlows and AI/ML model.</EM></P><P><STRONG><U>V) Technical Architecture Diagram: Visualizing the System Design</U></STRONG></P><P>&nbsp;</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="karthikarjun_8-1715273481135.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/108138iCC4BA4B4D3B68E02/image-size/large?v=v2&amp;px=999" role="button" title="karthikarjun_8-1715273481135.png" alt="karthikarjun_8-1715273481135.png" /></span></P><P style=" text-align: center; ">Fig2: Architecture diagram for E2E – Full Stack development with SAP applications</P><P><STRONG><U>VI) Technical Implementation: Step-by-Step Integration Details</U></STRONG></P><P><STRONG><EM><U>AIM: (Custom Cockpit and Integrated Goods Receipts):</U></EM></STRONG></P><OL><LI><EM>We're making a simple app for custom Purchase Orders (PO) with basic fields.</EM></LI><LI><EM>Obtaining the GR information electronically, then utilizing a machine learning algorithm to automatically update the GR within our application system (GR automation).</EM></LI><LI><EM>We're getting details about Goods Receipts (GR) from GR automation system and showing them in the custom PO form.</EM></LI></OL><P><STRONG><EM><U>Target Audience:</U></EM></STRONG></P><OL><LI><EM>Individuals with 0 to 4 years of experience in SAP.</EM></LI><LI><EM>Enthusiastic learners eager to explore new concepts and expand their knowledge base.</EM></LI></OL><P><STRONG><EM><U>Before proceeding, please ensure the following prerequisites are met:</U></EM></STRONG></P><OL><LI><EM>Familiarity with basic concepts of SAP S/4HANA Cloud and SAP RAP.</EM></LI><LI><EM>Activation of the ADT-Eclipse, Postman, Integration Suite API plan in your SAP BTP entitlement.</EM></LI><LI><EM>Understanding of fundamental AI and Automation concepts.</EM></LI><LI><EM>Knowledge related to Python, Javascript, System landscape and UI</EM></LI></OL><P><U>Step 1</U>: Install the ADT package in the Eclipse. You can refer the below link to download the ADT package in the eclipse.</P><P>ADT Link: <A href="https://tools.hana.ondemand.com/#abap" target="_blank" rel="noopener nofollow noreferrer">https://tools.hana.ondemand.com/#abap</A></P><P><U>Step 2:</U></P><P>Step two has been divided into two sections, each detailed below:</P><OL><LI><EM>Section-A: Connect to the S/4 HANA Cloud system.</EM></LI><LI><EM>Section-B: Create the modelling with SAP RAP</EM></LI></OL><P><EM>Go to help-&gt; About Eclipse IDE -&gt; Double check the below highlighted icon from your system.</EM></P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="karthikarjun_9-1715273481145.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/108137i483B7FC72242E1C7/image-size/large?v=v2&amp;px=999" role="button" title="karthikarjun_9-1715273481145.png" alt="karthikarjun_9-1715273481145.png" /></span></P><P><STRONG><EM><U>Section-A: Connect to the S/4 HANA Cloud system</U></EM></STRONG></P><P>To connect the S/4 HANA Cloud system, please use the below steps.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="karthikarjun_10-1715273481153.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/108140i716A680E6765D0DC/image-size/large?v=v2&amp;px=999" role="button" title="karthikarjun_10-1715273481153.png" alt="karthikarjun_10-1715273481153.png" /></span></P><P>Type the S/4 HANA Cloud web address: https://&lt;Host&gt;.s4hana.cloud.sap. Remember, select client 80. This client is used for making changes to the system.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="karthikarjun_11-1715273481157.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/108141iF7626E6C217FCB12/image-size/large?v=v2&amp;px=999" role="button" title="karthikarjun_11-1715273481157.png" alt="karthikarjun_11-1715273481157.png" /></span></P><P>Click the "Copy Logon URL to Clipboard" button. Then, open your web browser and paste the URL there. Enter your login details and press enter. After successful login, you'll see the screen below.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="karthikarjun_12-1715273481162.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/108139i86458454809E8CF3/image-size/large?v=v2&amp;px=999" role="button" title="karthikarjun_12-1715273481162.png" alt="karthikarjun_12-1715273481162.png" /></span></P><P>Click "Finish" and create your own package name. I've used "ZDEMO" here.</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="karthikarjun_13-1715273481167.png" style="width: 999px;"><img src="https://community.sap.com/t5/image/serverpage/image-id/108142i37579E5BD041F39B/image-size/large?v=v2&amp;px=999" role="button" title="karthikarjun_13-1715273481167.png" alt="karthikarjun_13-1715273481167.png" /></span></P><P><STRONG><U>Part 1: Key Takeaway:</U></STRONG></P><OL><LI>Gaining foundational knowledge of systems and landscapes through story-based learning.</LI><LI>Grasping the fundamentals of full-stack development with diagrams</LI><LI>Setting up Eclipse for SAP ADT and establishing a connection to the S/4 HANA Public Cloud system.</LI></OL><P><EM><U><STRONG>Part 2</STRONG></U>: Coming soon - Keep an eye out for an exciting story-based learning journey as we delve into creating SAP RAP applications.</EM></P><P><EM><U><STRONG>Part 3:</STRONG></U> Coming soon - Embark on an exploration of AI and ML with our forthcoming model, create system with a dashboard for ( GR Automation )&nbsp;</EM></P><P><EM><U><STRONG>Part 4:</STRONG></U> Coming soon - Learn how to connect the circuit using Integration Suite in our upcoming installment.</EM></P><P><EM>Author:&nbsp;<SPAN>If you find this information helpful, please consider clicking the "Like" button on this blog and sharing your thoughts in the comments section below. You can also connect with the author on their LinkedIn profile:&nbsp;</SPAN><A title="Author's LinkedIn Profile" href="https://www.linkedin.com/in/karthik-arjun-a5b4a258/" target="_self" rel="nofollow noopener noreferrer">[Author's LinkedIn Profile]</A></EM></P> 2024-05-09T19:14:30.935000+02:00