<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Datalog with External Machine Learning Functions for Automated Cloud Resource Configuration</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Zhuoxun Zheng</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Ognjen Savkovic</string-name>
          <xref ref-type="aff" rid="aff3">3</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Nikolay Nikolov</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Luu Huu Phuc</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Ahmet Soylu</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Evgeny Kharlamov</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Baifan Zhou</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Bosch Center for AI</institution>
          ,
          <country country="DE">Germany</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Department of Computer Science, Oslo Metropolitan University</institution>
          ,
          <country country="NO">Norway</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Department of Informatics, University of Oslo</institution>
          ,
          <country country="NO">Norway</country>
        </aff>
        <aff id="aff3">
          <label>3</label>
          <institution>Free University of Bozen-Bolzano</institution>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2023</year>
      </pub-date>
      <fpage>6</fpage>
      <lpage>10</lpage>
      <abstract>
        <p>Industry 4.0 and Internet of Things (IoT) technologies unlock unprecedented amount of data from factory production, posing big data challenges. In that context, distributed computing solutions such as cloud systems are leveraged to parallelise the data processing and reduce computation time. As the cloud systems become increasingly popular, there is increased demand that more users that were originally not cloud experts (such as data scientists, domain experts) deploy their solutions on the cloud systems. To this end, we propose SemCloud, a semantics-enhanced cloud system, for tackling the challenges of data volume and more users. The system has been evaluated in industrial use case with millions of data, thousands of repeated runs, and domain users, showing promising results. This poster paper accompanies our full paper and focuses on Datalog rules with external machine learning functions for automated resource configuration, and provides additional discussion on formalism and implementation techniques.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Datalog</kwd>
        <kwd>knowledge graph</kwd>
        <kwd>cloud configuration</kwd>
        <kwd>machine learning</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>Background and Challenges. Industry 4.0 focuses on smart factories that rely on IoT
technology for automation. This produces massive amounts of production data, increasing the
demand for data-driven solutions and cloud technology. Yet, users of these solutions and cloud
technology are often not cloud experts, such as domain experts and data scientists. In a standard
setting of a data science project, the team requires extensive assistance from cloud experts,
whenever they want to deploy solutions or make small changes to their solutions deployed on
the cloud. To facilitate the adoption of cloud systems for more projects and users, one can equip
all projects with some cloud experts, or launch training programs about cloud technology. Both
require careful planing to balance time, cost, and benefits.</p>
      <p>
        Our Approach. We notice that the existing work on this topic addressed the cloud deployment
issues only to a limited extent [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], whereby they either only focus on the formal description of
cloud, or on the limited adaptability of cloud systems. To address scalability challenges in data
volume and democratising cloud systems for more users, we propose SemCloud, a
semanticsenhanced cloud system, that scales semantic ETL pipeline on the cloud, and allows non-cloud
experts to deploy their solutions. A rough description of workflow of SemCloud is as follows:
(0) non-cloud experts create knowledge graphs (KG) that represent ETL-Pipelines on a cloud
system, where attributes of cloud resource configuration is under-specified; then Datalog rules
execute in three steps: (i) graph extraction rules write populate rule predicates by extracting
information from the ETL-pipeline KGs; (ii) resource estimation rules estimate the resource
consumption for the given pipeline assuming that there is only one computing node (assuming
infinite large node); (iii) resource configuration rules that find the optimal resource allocation
in distributed computing given the pipeline. This poster paper accompanies our full In-Use
paper [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. The paper is inspired by a industrial use case of manufacturing quality monitoring.
The paper provides additional insights and more details regarding the implementation.
      </p>
    </sec>
    <sec id="sec-2">
      <title>2. Approach</title>
      <p>Use Case: Distributed Semantic ETL. In our welding use case, large amount of data collected
from diferent factories, customers, software versions are integrated and analysed in parallel
to optimise the following welding production. To enable distributed ETL, we need to find a
strategy that makes the ETL parallelisable. SemCloud achieves this by breaking down the ETL
into pipelines of four steps: retrieve, slice, prepare, and store (Fig. 1), where data is first retrieved
from databases or online streams, and then split into subsets (e.g. each belong to one welding
machine) by slice to achieve parallel processing and storage in the following two steps. Here
the cloud configuration play an important role.</p>
      <p>
        KG Construction for ETL Pipelines. SemCloud provides the users GUI to construct semantic
ETL pipelines and encode them into knowledge graphs, based on a SemCloud ontology
(Figure 1a). The ontology SemCloud [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] is written in OWL 2, and consists of 20 classes and 165
axioms. It has three main classes: DataEntity, Task, Requirement. DataEntity refers to any dataset to
be processed; Task has sub-classes that represents the four types of tasks in the data preparation:
retrieve, slice, prepare, and store; and Requirement that describes the requirements for computing,
storage and networking resources. We illustrate the generation of ETL pipelines in KGs with
the example in Figure 1b. For these data, the users construct an ETL pipeline p1 with four layers
(via GUI). Firstly, data are “retrieved” from the welding factories. Thus, the layer l1 is of type
RetrieveLayer, and has the task t1 of type Retrieve. The task t1 has an IO handler io, which has
an output d1 of type DataEntity. Then the data are read in by a task t2 of type Slice, and “sliced”
into smaller pieces d2, d3. These slices are input to diferent computing nodes to do tasks t3
and t4 of type Prepare. Finally, all prepared data entities are stored by t5 of type Store.
Datalog ML Rules. Obtaining an optimised cloud configuration is not a trivial task. Cloud
experts typically try diferent configurations by testing the system with various settings and use
heuristics to manually decide on the configurations. To this end, SemCloud uses adaptive rules
in Datalog with aggregation and calls to external predicates learned by ML (they are adaptive
because the function parameters are learned). In particular, we consider non-recursive rules of
the form  ← 1, . . . , , where  is a head of rule (the consequence of the rule application)
and 1, . . . ,  are either predicates that apply join, aggregate function that filters out the
results or the expression of the form Var = @FUNCT(Vars). For the theory of Datalog we refer
to [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. We have six set of independent Datalog rules that are divided into three steps.
Graph Extraction Rules. These rules populate the predicates so that these predicates will be used
for the resource estimation and configuration. The rule0 exemplifies populating the predicate
subgraph1 that is related to the ETL pipeline p. Similarly, rule1 creates subgraph2(p,n,v,ms,mp
,ts,tp,nc,ns,mrs,mrp,mode).
subgraph1(p,n,v,ms,mp,ssl,spr,sst) ← ETLPipeline(p),
hasInputData(p,d), hasVolume(d,v), hasNoRecords(d,n)
hasEstSliceMemory(p,ms), hasEstPrepareMemory(p,mp)
hasEstSliceStorage(p,ssl), hasEstPrepareStorage(p,spr)
hasEstStoreStorage(p,sst)
Resource Estimation Rules. These rules are used to estimated required resource assuming one
computing node. For example, rule2 estimates the required slice memory (ms), prepare memory
(mp), slice storage (ssl), prepare storage (spr), and the store storage (sst). It then stores these
estimation in the predicate estimated_resource.
(0)
(2)
where @func_ms, @func_ssl, @func_sst, etc. are parameterised ML functions whose parameters
are learnt in the rule parameter learning. In the implementation, those are defined as external
functions that are called in the grounding phase of the program and are replaced by concrete
values [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. We also have other estimation rules for other resources, such as CPU consumption.
Resource Configuration Rules. These rules find the optimal cloud configurations based on the
estimated cloud resource. 3 is an example for deciding the slicing strategy and the storage
strategy, and finding the optimal resource configuration such as the chuck size ( nc), slice size
(ns), memory reservation for slice (mrs) and for prepare (mrp). In essence, 3 stipulates that if
the maximum of estimated slice memory (ms) and prepare memory (mp) is greater than a given
threshold (c1*nm), and the maximum of estimated slice storage (ssl), prepare storage (spr),
and store storage (sst) is smaller than (or equal to) another threshold (c2*ns), then the chosen
strategy for the given pipeline is slicing (thus nc and ns are computed), and fast storage (fs),
where the thresholds are calculated from cloud attributes.
configured_resource(p,nc,ns,fs,mrs,mrp) ←
subgraph2(p,n,v,ms,mp,ts,tp,nc,ns,mrs,mrp,mode),
estimated_resource(p,ms,mp,ssl,spr,sst),
CloudAttributes(c,c1,c2,c3,nm,ns,fs,cs),
#max{ms,mp} &gt; (c1 * nm), #max{ssl,spr,sst} &lt;= (c2 * ns),
nc = @func_fs_1(n,v,ts,tp), ns = @func_fs_2(n,v,ts,tp),
mrs = #min{ms, #max{@func_ss(n,v,nc,ns), c3*ms}},
mrp = #min{mp, #max{@func_pn(n,v,nc,ns), c3*mp}}
(3)
Rule Parameter Learning with ML. The functions in the adaptive rules are in the form of ML
models. The resource estimation rules are selected from the best model resulting from training
three ML methods and the pilot running statistics. These three ML methods are Polynomial
Regression (PolyR), Multilayer Percetron (MLP), and K-Nearest Neighbours (KNN). We selected these
three methods because they are representative classic ML methods suitable for the scale of the
pilot running statistics. The resource configuration rules are trained with the three ML methods
and with optimisation techniques, such as Bayesian optimisation or grid search. For example,
the functions @func_fs_1 and @func_fs_2 that find the optimal chuck size ( nc) and slice size (ns)
are trained by finding the arguments of ( nc,ns) for the minimal total computing time (total):
nc, ns = arg min total = arg min  (v, n, nc, ns, slice, prepare)
      </p>
      <p>nc,ns nc,ns</p>
    </sec>
    <sec id="sec-3">
      <title>3. Implementation and Evaluation</title>
      <p>
        Implementation. We implement the Datalog rules with DLV and external functions as Python
plugins [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. In particular, we first write and compile the external functions written in Python,
then we define the interface for the functions in the Datalog program, and then link the Datalog
program with the compiled Python code when running the DLV. For some complicated rules
with reusable part, we introduce a auxiliary predicate that stands for the reusable to improve
eficiency. A rule in the form of  ← 1, ...,  becomes two parts: (PartI):  ← 1, ..., ,
(PartII):  ← , +1, ..., , where PartI is reused also in other rules. For instance,
3 applies for one of the four cases of #max{ms,mp}&gt;(c1*nm), #max{ssl,spr,sst}&lt;=(c2*ns
), while there exist other three cases for the comparison (&lt;=,&lt;=), (&lt;=,&gt;), (&gt;,&gt;). We introduce
the auxiliary predicate configured_resource_aux to replace the first three lines ( subgraph2 to
CloudAttributes), which will be reused in the inference of the three other cases.
Evaluation and Discussion. To verify the time eficiency and accuracy of the rule parameter
learning and inference, we run SemCloud repeatedly 3562 times and gather pilot running
statistics. These statistics are split to 80% for training and 20% for testing and inference. Three
ML models are trained and tested. After a grid search, the selected hyper-parameters are,
PolyR: 4 degree; MLP: 2 hidden layers with neurons 10 and 9; KNN : 2 neighbours. We use these
performance metrics: normalised mean absolute error (nmae), minimal training data amount
(Min. || for yielding satisfactory results, optimisation time (Opt. time), learning time (for
ML training) and inference time (including the inference time of ML and Datalog). The results
(Table 1) show that PolyR has the best prediction accuracy, requires the least training data,
and consumes the least time. Therefore, PolyR generates the best results and is selected for the
use case. We presume the reason is that PolyR works better with small amounts of and not very
complex data (3562 repeated running statistics). The results show that our approach exhibit
promising inference accuracy and time eficiency for automated cloud resource configurations.
      </p>
    </sec>
    <sec id="sec-4">
      <title>4. Conclusion and Outlook</title>
      <p>
        This poster paper accompanies our full paper [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]
with a focus on Datalog rules with external ma- Metric PolyR MLP KNN
chine learning functions and provides additional nmae 0.0671 0.0947 0.0818
discussions on formalism and implementation Min. || 7.42% 50.97% 10.00%
techniques. The research is under the under the LOepatr.ntiinmgetime 201..8122mss 112704.3.312mss 277..5225mss
umbrella of Neuro-Symbolic AI for Industry 4.0 at Inference time &lt;1ms &lt;1ms &lt;5ms
Bosch. We aim at enhancing manufacturing
technology with both symbolic AI [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] for improving transparency [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], and ML for prediction power.
We will further improve the performance of the KG embedding method and develop other
complementary technologies, such as ontologies [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ], ontology-based data access, etc.
Acknowledgements. The work was partially supported by the European Commission funded
projects DataCloud (101016835), enRichMyData (101070284), Graph-Massivizer (101093202),
Dome 4.0 (953163), OntoCommons (958371), and the Norwegian Research Council funded
projects (237898, 323325, 309691, 309834, and 308817).
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>L.</given-names>
            <surname>Yousef</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Butrico</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D. Da</given-names>
            <surname>Silva</surname>
          </string-name>
          ,
          <article-title>Toward a unified ontology of cloud computing</article-title>
          ,
          <source>in: 2008 Grid Computing Environments Workshop</source>
          , IEEE,
          <year>2008</year>
          , pp.
          <fpage>1</fpage>
          -
          <lpage>10</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>B.</given-names>
            <surname>Zhou</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Nikolov</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Zheng</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Luo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>O.</given-names>
            <surname>Savkovic</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Roman</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Soylu</surname>
          </string-name>
          , , E. Kharlamov,
          <article-title>Scaling data science solutions with semantics and ML</article-title>
          , in: ISWC,
          <year>2023</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>The</given-names>
            <surname>SemCloud Ontology</surname>
          </string-name>
          ,
          <year>2023</year>
          . Open source under: https://github.com/nsai-uio/SemCloud.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>S.</given-names>
            <surname>Paramonov</surname>
          </string-name>
          , et al.,
          <article-title>An asp approach to query completeness reasoning</article-title>
          ,
          <source>TPLP</source>
          <volume>13</volume>
          (
          <year>2013</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>N.</given-names>
            <surname>Leone</surname>
          </string-name>
          , et al.,
          <article-title>The dlv system</article-title>
          ,
          <source>in: JELIA</source>
          , Springer,
          <year>2002</year>
          , pp.
          <fpage>537</fpage>
          -
          <lpage>540</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          <article-title>[6] Dlvhex python plugin manual</article-title>
          , http://www.kr.tuwien.ac.at/research/systems/dlvhex/doc2x/ group__pythonpluginframework.html,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>D.</given-names>
            <surname>Rincon-Yanez</surname>
          </string-name>
          , et al.,
          <article-title>Addressing the scalability bottleneck of semantic technologies at bosch</article-title>
          ,
          <source>ESWC Industry</source>
          (
          <year>2023</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>Z.</given-names>
            <surname>Zheng</surname>
          </string-name>
          , et al.,
          <article-title>Executable knowledge graph for transparent machine learning in welding monitoring at bosch</article-title>
          , in: CIKM,
          <year>2022</year>
          , pp.
          <fpage>5102</fpage>
          -
          <lpage>5103</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>B.</given-names>
            <surname>Zhou</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Zheng</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Zhou</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Tan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>O.</given-names>
            <surname>Savković</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Yang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Zhang</surname>
          </string-name>
          , E. Kharlamov,
          <article-title>Knowledge graph-based semantic system for visual analytics in automatic manufacturing</article-title>
          ,
          <source>ISWC</source>
          ,
          <year>2022</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>