Advanced Planning and Scheduling with Semantic Knowledge Graphs and LLMs
Nenad Petrovic, Milorad Tosic
University of Niš, Faculty of Electronic Engineering, Niš, Serbia
Objectives
Background: APS in Manufacturing
Background: AI application layers challenge
???
Background: AI application layers challenge
???
Approach
LLM
ontologies
APS
Proposed solution
Proposed solution
Implementation: Architecture
1,5-User input {story} 2a-RDF schema 2b-RDF knowledge graph 3a-Ontology chunks 3b-Knowledge graph excerpt chunks 4a-Context: ontology excerpt {context1} 4b-Context: knowledge graph template {context2} 6-Intermediary result 7-Triplets 8-Order definition 9-Generated work plan.
Implementation: Architecture
1,5-User input {story} 2a-RDF schema 2b-RDF knowledge graph 3a-Ontolgy chunks 3b-Knowledge graph excerpt chunks 4a-Context: ontology excerpt {context1} 4b-Context: knowledge graph template {context2} 6-Intermediary result 7-Triplets 8-Order definition 9-Generated work plan.
Implementation: Architecture
1,5-User input {story} 2a-RDF schema 2b-RDF knowledge graph 3a-Ontolgy chunks 3b-Knowledge graph excerpt chunks 4a-Context: ontology excerpt {context1} 4b-Context: knowledge graph template {context2} 6-Intermediary result 7-Triplets 8-Order definition 9-Generated work plan.
Retrieve and Re-Rank for In-Context Learning (RRR4ICL) – Workflow overview
RRR4ICL components - RecursiveSplitter
https://python.langchain.com/api_reference/text_splitters/character/langchain_text_splitters.character.RecursiveCharacterTextSplitter.html
maximum number of characters or tokens allowed in a single chunk
number of characters or tokens shared between consecutive chunks.
RRR4ICL components – SentenceTransformer
RRR4ICL components – CrossEncoder
RRR4ICL – Steps
Input: query, document Steps: |
|
Output 1: context - top m chunks combined
Output 2: answer – response generated by LLM |
RRR4ICL – Prompt templates used
Deployment overview
1-HTTP request containing user story; 2-Prompt to GPT-4o; 3-Response of GPT-4o; 4-Triplet insertion; 5-Planning output; 6-HTTP response (created triplets/plan).
Development environment
1-HTTP request containing user story; 2-Prompt to GPT-4o; 3-Response of GPT-4o; 4-Triplet insertion; 5-Planning output; 6-HTTP response (created triplets/plan).
API overview
Method | Arguments | Output | Description |
load_ontology | ontologyPath – Path where the textual file of ontology is stored. | - | Appends the content from given file containg RDF format ontology to the overall text which will be processed by Retrieval and Re-Rank method |
search | query – prompt that is used as input for Retrieval and Re-Rank process. It is constructed as combination of pre-defined template and direct input provided by user | Context that will be further used as input to LLM service | Constructs the context by combining the most relevant results (text chunks) returned as outcome of Retrieval and Re-Rank process against the set of planning-relevant ontologies |
handle_question | question – user-defined input | Textual response | Relies on search method to get context that will be leveraged for prompt that produces the final LLM-generated answer |
__init__ | Model – Desired LLM that will be used for response generation (recommended gemma2:9b and GPT-4o) | - | Constructor of the underlying class encapsulating RRR process. |
Experiments and evaluation
Experiment1: Text-based planner input
result - achieved accuracy, A1 - only relevant parts of ontology as context, A2 – with sample graph excerpts, A1’ - no RAG-extracted context, Y-yes, N-no, WS-wrong syntax, RAG - retrieval of context
Title | Text | Result | A1 | A2 | Execution time [s] | ||
Employee creation | Name of employee is Dusan Kostic. He has id 612. He is member of department project managers. He is member of production team and his position is mechanics designer. | Classes | 1/1 | 1/1 | A1: 6.77 | A2: 8.44 | RAG: A1: 100 A2: 146 |
Properties | 1/4 | 4/4 | |||||
Hallucinated | Y | N | |||||
Order creation | We have a new order for C1 company and the product we want to produce is P1. The activity starts from 2025-06-01 and ends 2025-07-31. | Classes | WS | 1/1 | A1: 8.31 | A2: 8.57 | RAG: A1: 110 A2: 130 |
Properties | 5/5 | ||||||
Hallucinated | N | ||||||
Machine creation | Add new CNC machine with inventory id: CNC_1. | Classes | 1/1 | - | A1: 6.61 | - | RAG: A1: 101 A2: 134 |
Properties | 1/1 | - | |||||
Hallucinated | N | - | |||||
Activity flow definition | The production flow contains the following activities: cutting, assembling and packing. | Classes | WS | 4/4 | A1: 7.72
| A2: 7.84 | RAG: A1: 108 A2: 131 |
Properties | 3/3 | ||||||
Hallucinated | N | ||||||
Employee update | Change the id of employee Dusan Kostic. | Correct update | A1’:Y | A2: Y | A1’: 3.1 | A2: 6.13 | RAG: A2: 101 |
Hallucinated | N | N | |||||
Flow extension | Add new activity: preparation before cutting to given flow. | Correct update | A1’: Y | A2: Y | A1’: 5.61 | A2: 7.88 | RAG: A2: 115 |
Hallucinated | N | N | |||||
Experiment1: Results’ accuracy estimation
Experiment1: Results discussion
Experiment2: Questions about ontologies
Experiment | Question | Result | Prompt execution [s] |
Attributes list retrieval | Which attributes are relevant for employee definition? | 4/4 in 90% cases | 1.8 |
Which elements are relevant for composite activity? | 1.9 | ||
Related concepts retrieval | Which concepts are related to order? | 3/3 in 80% cases | 2.7 |
Relations retrieval | How employee is related to order? | Correct answer in 70% cases | 1.8 |
Experiment2: Results discussion
Conclusions and discussion
Future work
Thank you!