Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
sabatale
Contributor

AI Text Generation


Large Language Models (LLM) have gained great momentum in 2023, particularly in the Text generation field. In a few months, summarizing and translating large volumes of content with AI models became somewhat common - no matter your industry or size. They perform especially well when the task is straightforward, a clear example of the expected result is given, and the context does not need to be fully understood.

This blog post describes an experiment with a more obscure type of text content - Process diagrams. In essence, diagrams are indeed sentences put together in a drawing: "Step 1" (goes to) "Step2" (goes to/or to) "...". No context is really needed, besides the sequencing that needs to be followed. It is also easy to provide a model with the general BPMN specifications (XML elements everyone follows), and accurate examples (SAP provides BPMN files for every single S/4 business process in Signavio Process Explorer - free of charge).

On one hand, SAP quickly released AI Foundation, the all-in-one AI toolbox where you can freely choose a model and datacenter and start building your apps and services directly in SAP BTP. The obvious advantage is the integration with your SAP systems, as well as BTP itself. However, the product is still very new and this blog will use direct APIs instead, but you can technically leverage AI Foundation to achieve the same result.

On the other hand, SAP Cloud ALM is a project toolbox with numerous implementation capabilities: task management, transport execution, automated testing and.. process modeling. The latter is extremely useful during Fit workshops, where the business analyst can simply modify the relevant S/4 process diagram live, add requirements or notes, assign individuals, and more.

Now, let's say you don't use of Cloud ALM during the workshop, need to start a process from scratch or simply want to retroactively document your changes. Could LLMs build a process diagram for you? Or create a requirement in the tool directly from your handwritten piece of paper?

Disclaimer: These are almost thought experiments, not productive solutions or even prototypes.

Use Case 1 - From Text to Diagram


You are a business analyst documenting a process for your company. The objective is easy: explain how to order a pizza (no pineapple variant). First, you navigate to Cloud ALM, create a new requirement and describe the steps in the Description section:


Notice the ###CREATE BPMN###? That's because your company is AI-powered, and this command will generate a business diagram automatically for you.

The workflow is as follow:

  1. Setup the Cloud ALM webhook. This will send a request whenever a task is created. See this post (and the others) from xavier.dupeyrat to learn more.

  2. Create a requirement in SAP Cloud ALM with your AI trigger. The ###*### command is just an example. You could use any field from the requirement to act as filters instead.

  3. Prompt the LLM. There are many ways to do so. For example, you can point the Tasks webhook to an integration in SAP CPI to do the heavy lifting: map the request body, add your prompt to the request, send it to the LLM API and reply back with its answer.

    • First, choose your LLM provider. OpenAI and LLama are major contenders, but I like using Cohere because it's currently free for development, can access the web and is a genuinely good (Canadian 🍁) alternative. The API documentation to create a chat is here: Chat (Beta) (cohere.com).

    • Wait for a task request matching your command, and map the id and description (e.g., regex looking for "Start, Check pizza price, Order pizza Quattro formaggi, Wait for delivery, Tip driver, Eat pizza 🍕."):
      // GET /api/calm-tasks/v1/tasks/123
      {
      "id": "123",
      "projectId": "456",
      "title": "Establishing the pizza process",
      "type": "CALMREQU",
      "status": "CIPREQUOPEN",
      "description": "Notes from 20240501 meeting.</p>\n<p>##CREATE BPMN##</p>\n<p>Start, Check pizza price, Order pizza Quattro formaggi, Wait for delivery, Tip driver, Eat pizza .",
      ...
      }​

       

    • Send your prompt to the LLM (below is not the actual body):
      // POST https://api.cohere.ai/v1/chat
      {
      "message": "### Context\nYou are an expert at writing BPMN files with XML. I will give you a list of steps and you will return the BPMN to me. Here is an example with the steps ***(insert example step)*** and Withdraw ***(insert example step 2)***: ***(insert BPMN XML sample)***.\n\n###My Request\nReturn a BPMN for the following steps: ***(insert mapped description)***"
      }​


    • Of course, the result of this query will greatly vary based on the provider, embeddings and the prompt itself. However, with minimal model optimization, the results were perfectly fine for our pizza process.



  4. Take the returned XML code (= BPMN), and send it back to Cloud ALM. If you want to create a a process object, you would need to convert it into SVG first. In this example, we will simply generate a URL for the diagram and reference it in the requirement.

  5. A free tool for BPMN hosting is Cawemo, the collaborative platform for modelling, versioning and sharing processes with anyone. Again, send a request with the BPMN to upload the process and generate a public link such as this one: Pizza process (cawemo.com).

  6. Attach the link as a Reference to your initial Cloud ALM requirement through API:
    // POST /api/calm-tasks/v1/tasks/123/references
    {
    "name": "LLM - Pizza process BPMN",
    "url": "https://cawemo.com/share/7d764acf-99d0-4b6a-914e-45000a0977df"
    }​


  7. You now have a BPMN diagram the Project team can access and share within minutes:


Use Case 2 - From Image to Requirement


Still here, I see? Let's change persona. You are now an old-school note-taker, paper and pencil, with a questionable hand-writing. This is the end of your day, after a quick meeting about what needs to be changed in the current S/4 solution, and you have a few requirements to enter in Cloud ALM.

Optical Recognition (OCR) solutions are not new, but you will mostly find SAP examples talking about Invoices. Why? Because it's very useful and you probably have a lot of them, which is a great use case for automation. However there are also plenty of consumer apps converting whatever you write on paper into digital documents, and that's the topic of our second example.

SAP AI Core is not the only SAP tool using LLMs. Another example is BTP's Document Information Extraction. With DCE, you can extract information from documents and scenes (e.g., a car plate number) at scale directly in SAP BTP, and send the result to other SAP products for further processing. According to SAP, the extraction relies on OCR and LLM, but it is not clear how things work in the background.

Our workflow goes as follow:

  1. Setup your DCE instance (e.g., BTP Free Trial + booster).

  2. Create a new schema configuration. It contains the fields you want to extract as structured data. The head is generally the top section of a document, while line items would belong to a a a table.

  3. Take a picture of your paper notes and send them to the Document Information Extraction API: Document API | SAP Help Portal.

  4. The document will be automatically analyzed. The quality of the results tend to increase over time but there is definitely room for experimentation. I tried my worse, and it came back okay.

    Before proceeding with the requirement creation, you can first provide the result to another LLM, similarly to Use Case 1, by asking "###Instructions\nThis is a JSON view of my notes from today. Summarize the information and format your reply with bullet points.\n###JSON\n***(insert result)***".

  5. Take the JSON output (also available as CSV), and create a new requirement in Cloud ALM through API.
    // POST /api/calm-tasks/v1/tasks/
    {
    "projectId": "456",
    "title": "Note-taking - Requirements from ABC",
    "type": "CALMST",
    "externalId": "789",
    "dueDate": "",
    "priorityId": 30,
    "assigneeId": "abc",
    "description": "***(insert result here)***"
    }



And we are done! If you're looking for more, search for the tag "ai" here on SAP blogs, or check out the posts from mario.defelipe4 for RAG specifically!
2 Comments
Labels in this area