Data service recommendation method fusing dual-scale contrast learning and multi-objective optimization
By adopting dual-scale comparative learning and multi-objective optimization methods in the Web API recommendation system, combined with a hybrid random walk and channel attention mechanism, the problem of insufficient coding in the existing technology is solved, and the accuracy and efficiency of Web API recommendations are significantly improved.
Patent Information
- Application Number
- CN202411681858.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-11-22
AI Technical Summary
The existing Web API recommendation methods have not yet fully encoded the collaborative signals in the Mashup-API call relationship, resulting in insufficient embeddings to capture the collaborative signals, affecting the recommendation effect.
Using a method of fusion of two-scale contrast learning and multi-objective optimization, the recommendation model is optimized to improve recommendation accuracy by extracting service hypergraphs and introducing convolutional weight matrix, combining a mixed random walk algorithm and channel attention mechanism.
By more accurately capturing the complex relationships between service data, reducing the impact of noise, and improving the accuracy and efficiency of the recommendation system, the accuracy of Web API recommendations is significantly improved.
Smart Images

Figure CN119760218A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a service recommendation scenario under Mashup development, and in particular to a Web API recommendation method based on a multi-channel hypergraph convolutional network. Background Art
[0002] Services have a wide range of applications, from performing simple arithmetic operations to handling complex program tasks in a distributed network. With the help of standardized description languages, such as Web Services Description Language (WSDL), services can expose their interfaces to the outside world, making it easier to discover and utilize services. In addition, services can be called through Simple Object Access Protocol (SOAP) or Representational State Transfer (REST) protocols, thereby enabling service reuse. Service-Oriented Architecture (SOA), as a new system architecture, provides organizations with greater flexibility and agility in dealing with challenges such as Internet applications. This structural style provides a framework at the technical level, in which the software structure is broken down into units provided by service providers (such as Web APIs), and each unit must meet specific conditions, such as independence, reusability, identifiability, and the ability to interact through independent messaging mechanisms. These services are collectively called Web services.
[0003] Faced with the rapid development of the information society and the emergence of a large number of additional requirements, the existing Web API functions are not enough to cope with increasingly complex business scenarios. To fill this gap, Mashup technology came into being. The core concept of Mashup is to use Web API as a reusable component to create new products or solutions. It integrates multiple services to match user customized needs, greatly reducing the development threshold, allowing even developers who lack programming skills to quickly create applications using ready-made APIs, and can also help developers shorten the development cycle. In addition, Mashup not only promotes the reuse of services, but also spawns multiple Mashup application platforms launched by Internet companies such as Microsoft and IBM.
[0004] With the increasing number of services, service recommendation technology has become the focus of many researchers. The existing research focuses mainly on the narrative documents or call relationship data of services. Through in-depth analysis of these data, the characteristic information of services is extracted and recommendations are made. In current research, many methods focus on analyzing service description documents and other information (Quality of Service (QoS) parameters, tags, historical information) to extract their characteristic information and then recommend matching services. For example, Ramathulasi et al. proposed the DAT-LDA model, which aims to obtain the topic probability distribution of Mashup service documents to achieve service clustering. Ren et al. constructed the service composition problem as a Markov decision process and incorporated the service carrying information. This method significantly improves the adaptability to the uncertain behavior of services in dynamic environments and solves the QoS constraint problem of users. However, the effectiveness of these methods depends largely on the accuracy and completeness of the information provided by the service. If the details of the information are insufficient, the recommendation effect will be directly affected. The functional interaction information between Mashup and Web API has also been an academic focus. Rahman et al. used two-layer topic modeling to process the interaction data between Mashups, thereby constructing a denser Mashup-Web API dataset, and applied regularized matrix decomposition technology to the embedding process of Mashups and Web APIs to generate an effective WebAPI recommendation list. Although these methods have made progress in improving the performance of recommendation systems, existing research has not yet fully encoded the collaborative signals in the Mashup-API call relationship into the embedding vector, resulting in the generated embedding being insufficient to capture the collaborative signals.
[0005] Driven by deep neural networks and theoretical analysis, machine learning has achieved leaps and bounds in many fields. Despite these remarkable achievements, these methods have also exposed some limitations due to their heavy reliance on labeled data. First, the cost of manually collecting and annotating labels is quite high, especially when large-scale datasets or domain-specific knowledge are involved. Second, standard supervised learning often fails to generalize well to new data due to overfitting, which is particularly prominent when training data is scarce. Third, supervised learning models are susceptible to adversarial attacks, which manipulate labels and make the models less robust.
[0006] Inspired by the recent progress of contrastive learning in computer vision and natural language processing, some research works have proposed methods to apply contrastive learning to service data. The design of contrastive learning for service data can be summarized into three main modules: Data augmentation, which transforms or expands the original data to increase the diversity and capacity of training data. Pretext tasks, which are auxiliary tasks used in the contrastive learning framework, aim to create informative contrast sample pairs. Contrastive objectives, a series of objective functions used to measure the consistency of sample pairs, are the core components of contrastive learning. Summary of the invention
[0007] In order to overcome the shortcomings of the prior art, the present invention proposes a data service recommendation method that integrates dual-scale contrastive learning and multi-objective optimization in view of the characteristics of sparse service data and complex business scenarios. First, the hypergraph structure is extracted from the service with the help of the motif to study the complex relationship between service data. In order to reduce the impact of noise, a convolution weight matrix is introduced in the hypergraph convolution process, and convolution operations are performed on the constructed hypergraph based on the weight matrix combined with hybrid random walks. Furthermore, the channel attention mechanism is used to merge the convolution results on different channels, and the dual-scale contrastive learning method is used to maximize the information obtained by the recommendation model. Finally, a multi-objective model is used to optimize the recommendation results and improve the Web API recommendation effect.
[0008] The present invention provides the following technical solutions:
[0009] A data service recommendation method integrating dual-scale contrastive learning and multi-objective optimization, the method comprising the following steps:
[0010] The first step is to extract the service hypergraph based on the service motif. The process is as follows:
[0011] Step (1.1) crawl Mashup service information from relevant API websites;
[0012] Step (1.2) analyzes the crawled Mashup service set and selects meta-information that is helpful to improve the accuracy of service recommendation and is rich in content;
[0013] Step (1.3) summarizes four types of motifs: co-correlation motifs, multiple strong correlation motifs, single relationship motifs, and complex relationship motifs;
[0014] Step (1.4) constructs a multi-channel hypergraph based on the motif proposed in step (1.3);
[0015] The second step is to calculate the convolution weight matrix C of the multi-channel hypergraph through the hybrid random walk algorithm. The process is as follows:
[0016] Step (2.1) proposes a hybrid random walk algorithm based on the combination of partial absorption random walk and biased random walk to calculate the convolution weight matrix C on the hypergraph;
[0017] Step (2.2) is further obtained according to the weight calculation formula: Λ(CI)+CD=(W⊙Q)C, where Λ is a regularized matrix with all values greater than 0, D represents the degree matrix of the hypergraph, which is a diagonal matrix whose diagonal elements represent the degrees of the corresponding vertices; W represents the weights between nodes determined by the degrees, and Q is a parameter matrix used to adjust the transition probability in the biased random walk;
[0018] Step (2.3) is further calculated to deduce the closed form of the convolution weight matrix C = (Λ + L) -1 Λ; where L = DW⊙Q;
[0019] Step 3: Perform convolution operations on the hypergraph and aggregate the convolution results on multiple channels to obtain the embedded expression of the Mashup;
[0020] Step 4: According to the channel error attention mechanism, combined with the output results of each channel, the process is as follows:
[0021] Step (4.1) uses the channel error attention mechanism to calculate the weight of each channel;
[0022] Step (4.2) aggregates the output of each channel according to the weight to obtain a complete representation of the hypergraph vertices;
[0023] Step 5: Convolve the Mashup-API call relationship graph to obtain the embedded expression of the API;
[0024] Step 6: Propose a dual-scale contrastive learning method to maximize the consistency between the same node and the difference between different nodes obtained by two different approaches, so as to enable the recommendation model to obtain more information;
[0025] Step 7: Optimize the model based on the model recommendation results.
[0026] Furthermore, in the step (1.2), the retained meta-information includes Mashup, API, the calling relationship between Mashup and API, and the tags carried by Mashup;
[0027] The Mashup set is defined as M = {m1,m2,…,m N}, where N is the total number of Mashups in the collection, Mashup m iThe API set called is A i ={a i,1 ,a i,2 ,a i,3 ,…,a i,k}, k is Mashup m i The total number of APIs called. The set of APIs called by all Mashups is Where ∪ means finding the union of all sets, and the Mashup-API call relationship is stored in a 0-1 matrix middle, represents the set of real numbers, represents a matrix of real numbers and of size N×|A|, where |A| represents the number of elements in the set A, and each pair of Mashup m and API a, t m,a =1 indicates that Mashup m has a calling relationship with API a, t m,a =0 means there is no calling relationship between Mashup m and API a;
[0028] The tag represents part of the function or attribute of the Mashup, and the tag information contains the collaborative information between the Mashup and the API. Therefore, the feature mining process of API and Mashup not only uses the call information but also the tag information. To represent the relationship between labels and Mashup. m,ta =1 means that Mashup m and tag ta have a carrying relationship, R m,ta =0 means that there is no carrying relationship between Mashup m and tag ta.
[0029] Furthermore, in step (1.3), motifs represent connection patterns that appear repeatedly in the network and are significantly higher in number than other complex networks. Such connection patterns often contain key information about the network. A large number of studies have proven that motifs have a substantial ability to bridge the gap between microscopic and macroscopic structural information.
[0030] The descriptions of the four models are as follows:
[0031] Co-associated motifs: In the Mashup call scenario, there are two Mashups that carry the same label, which is called the same label relationship in this invention. In the service data, there are Mashups that have the same label relationship between each other and form a ternary closure structure, which is called the co-associated motif;
[0032] The ternary closure is a concept in social network theory, which refers to a property of a triple consisting of three nodes A, B, and C, that is, there is a strong connection between A and B, A and C, and B and C.
[0033] Multiple strong correlation motifs: Labels themselves are diverse and artificially defined labels cause uncertainty in the labels carried by Mashups. The present invention defines the relationship between a pair of Mashups carrying two or more identical labels as a strong correlation relationship, and defines the structure in which multiple Mashups are strongly correlated with each other to form a closed loop as a multiple strong correlation motif;
[0034] Single relationship motif: The calling relationship between Mashup and API presents the functional characteristics of Mashup. Two Mashups that call the same API have functional similarities. The present invention defines the motif of two Mashups calling the same API as a single relationship motif.
[0035] Composite relationship motif: Mashups call the same API and carry the same label. In order to use this feature to explore the relationship between mashups, the present invention defines mashups that call the same API and have the same label relationship as composite relationship motifs.
[0036] Furthermore, the process of step (1.4) is:
[0037] Step (1.4.1) constructs the hypergraph G1 based on the “co-correlation motifs” as follows:
[0038] Step (1.4.1.1) Calculate the relationship matrix R based on the Mashup-label relationship matrix Perform step (1.4.1.2);
[0039] in, Indicates the number of identical labels between Mashups. " indicates the transposition of the matrix;
[0040] Step (1.4.1.2) construct the upper triangular matrix R * , used to indicate whether the mashups carry the same tags, and proceed to step (1.4.1.3);
[0041] Among them, R * By matrix Take the upper right corner of the diagonal and set all numbers greater than 0 to 1;
[0042] Step (1.4.1.3) calculates the adjacency matrix of the hypergraph G1;
[0043] The adjacency matrix is a matrix that represents the adjacent relationship between vertices in the hypergraph. The calculation formula of the adjacency matrix S1 of the hypergraph G1 is S1 = (R * R * )⊙R * , where ⊙ represents the Hadamard product of the left and right matrices;
[0044] Step (1.4.2) constructs the hypergraph G2 based on the “multiple strongly correlated motifs” as follows:
[0045] Step (1.4.2.1) Construct the matrix R ′ , used to indicate whether the mashups carry two or more identical tags, and then proceed to step (1.4.2.2);
[0046] Among them, the matrix R′ is obtained by taking the matrix The upper right diagonal is constructed by setting all numbers greater than 2 to 1 and the rest to 0;
[0047] Step (1.4.2.2) calculates the adjacency matrix of the hypergraph G2;
[0048] Step (1.4.3) constructs the hypergraph G3 based on the “single relation motif” as follows:
[0049] Step (1.4.3.1) is calculated based on the Mashup-API call relationship matrix T Perform step (1.4.3.2);
[0050] in, Indicates the number of calls to the same API between Mashups;
[0051] Step (1.4.3.2) is based on the matrix Calculate the matrix T * , proceed to step (1.4.3.3);
[0052] Among them, the matrix T * By taking the matrix The upper right corner of the diagonal line is constructed by setting all numbers greater than 0 to 1, indicating whether the same API is called between mashups;
[0053] Step (1.4.3.3) calculates the adjacency matrix of the hypergraph G3;
[0054] The calculation formula of the adjacency matrix S3 of the hypergraph G3 is S3 = T * T *" ;
[0055] Step (1.4.4) Based on the “composite relational motif”, the adjacency matrix calculation result of the hypergraph G4 is compared with the upper triangular matrix R* Find the Hadamard product, calculate the adjacency matrix of the hypergraph G4 and construct the hypergraph G4;
[0056] The calculation formula of the adjacency matrix S4 of the hypergraph G4 is S4=(T * T * ")⊙R * , which means filtering out mashup pairs that do not carry the same label;
[0057] Preferably, the processing process of step (1.4.2.2) is:
[0058] Step (1.4.2.2.1) defines the adjacency matrix S2 to represent the adjacency matrix of the hypergraph G2;
[0059] Step (1.4.2.2.2) traverses the Mashup set M, and initializes the value i to 1 to record the number of the Mashup, and performs steps (1.4.2.2.2.1-1.4.2.2.2.3) to calculate all values of the i-th row in S2;
[0060] Step (1.4.2.2.2.1) traverses the Mashup set M and initializes the value j to 1 to record the Mashup number, and performs steps (1.4.2.2.2.1.1-1.4.2.2.2.1.3) to calculate S2 in S2 i,j The value of
[0061] Among them, S2 i,j represents the value of the i-th row and j-th column in the adjacency matrix S2;
[0062] Step (1.4.2.2.2.1.1) queries the matrix R to confirm whether the number of identical tags carried by Mashup i and Mashup j is greater than 1. If so, replace S2 i,j Set to 1, otherwise set to 0 and proceed to step (1.4.2.2.2.1.2);
[0063] In step (1.4.2.2.2.1.2), take j=j+1 and proceed to step (1.4.2.2.2.1.3);
[0064] Step (1.4.2.2.2.1.3) determines whether j is less than or equal to N. If so, return to step (1.4.2.2.2.1.1), otherwise exit the loop;
[0065] In step (1.4.2.2.2.2), let i=i+1 and proceed to step (1.4.2.2.2.3);
[0066] Step (1.4.2.2.2.3) determines whether i is less than or equal to N. If so, return to step (1.4.2.2.2.1), otherwise exit the loop.
[0067] In step (2.1), the convolution weight matrix c i,j represents the value of the i-th row and j-th column in matrix C, represents a matrix of size N×N composed of real numbers, ∈ represents the belonging relationship between elements and sets; the process is as follows:
[0068] In order to avoid the random walk from converging to a stationary distribution determined only by the degree of each node, we refer to the partial absorption random walk and assume that the random process X = {X t :t≥0} is the transition probability matrix
[0069]
[0070] Among them, the partially absorbing random walk is a second-order Markov chain. In each state, there is a certain probability of staying in the current state or transitioning to the next state, which is determined by the transition probability p i,j Decide;
[0071] in, Among them, d i represents the degree of vertex i, which represents the number of edges connected to the vertex in the graph, S i,j represents the value of the i-th row and j-th column in the adjacency matrix S, λ i ∈Λ,Λ=diag(λ1,λ2,…,λ N ) is a regularized matrix with all values greater than 0, where diag() indicates that the elements in the brackets form a diagonal matrix. The calculation formula of Λ is Λ=δI, where I represents the unit matrix and δ represents the weight coefficient. By adjusting δ, the absorption probability between nodes can be adjusted.
[0072] Step (2.1.2) combines the parameter matrix Q with P to obtain the convolution weight calculation formula on the hypergraph
[0073]
[0074] Among them, Q is the parameter matrix used to adjust the transition probability in the biased random walk. The biased random walk combines the breadth-first and depth-first sampling strategies to adjust the transition probability, so as to achieve the purpose of balancing homogeneity and structural equivalence, and can flexibly search for complex network structures. The element q in the i-th row and j-th column of the matrix Q is i,j The calculation formula is
[0075] Among them, breadth-first and depth-first are two common search strategies. The breadth-first strategy traverses the graph or tree structure layer by layer in a hierarchical manner, first visiting all adjacent nodes, and then visiting the nodes in the next layer in turn. It is suitable for finding the shortest path; the depth-first strategy explores down along a branch to the end, and then traces back to the previous branch. It is suitable for finding all possible solutions. Among them, d i,j represents the shortest distance between nodes i and j, p and q are parameters for adjusting the walking strategy; among them, homogeneity means that two nodes belonging to the same cluster are more similar, and structural equivalence means that two nodes with the same structural role are more similar.
[0076] The process of the third step is as follows:
[0077] Step (3.1) combines the convolution weight matrix with the traditional hypergraph convolutional network. Based on LightGCN, the feature transformation and activation function are discarded, the convolution operation is simplified, and the convolution operation is defined as X (l+1) =D (-1) SX (l) ;
[0078] Among them, LightGCN is a recommendation algorithm based on graph neural network. It improves efficiency and performance by simplifying the model structure. It is easy to understand and explain and is widely used. Feature transformation refers to the method of obtaining new features through certain rules or mappings of the original features. The activation function refers to the functional relationship between the output of the upper node and the input of the lower node in the multi-layer neural network. (l) and X (l+1) Represents the input and output of a single convolution, S represents the adjacency matrix, D (-1) represents the inversion of matrix D;
[0079] Step (3.2) introduces the convolution weight matrix C and performs the hypergraph convolution operation;
[0080] Among them, the single-layer convolution formula is X (l+1) =CX (l) , the convolution formula of the hypergraph convolutional network with L layers of convolution is y (L) =C…(CX (0) );
[0081] in, represents the input matrix composed of the embedding matrices of the hypergraph vertices. Since the present invention adopts a multi-channel hypergraph convolutional network, C in the formula can be replaced by the convolution weight matrices C1, C2, C3 and C4 of the hypergraphs G1, G2, G3 and G4 to obtain the output result y1 (L) ,y2 (L) ,y3 (L) 、y4 (L) ;
[0082] Where s represents the embedding length.
[0083] Step (3.3) averages the output of each convolution to obtain the final output of each channel;
[0084] Among them, y n The calculation formula is
[0085] The process of step (4.1) is:
[0086] Step (4.1.1) directly uses the output results of different channels for loss calculation to obtain the error between the estimated value and the true value of the channel.
[0087] The error calculation formula is:
[0088] The smaller the error value, the stronger the identification feature extracted by the channel, and the larger the weight should be. Φ represents the model parameter, Represents Mashup m i with API a j The scoring function is Represents Mashup m i with API a k The scoring function of .
[0089] Step (4.1.2) introduces the error of step (4.1.1) into the channel attention mechanism to obtain a new channel error attention formula, which is:
[0090]
[0091] Among them, the channel attention mechanism is a technology used to enhance the performance of neural networks, mainly used in computer vision and natural language processing. Its core idea is to highlight important features and suppress irrelevant features by assigning different weights to different channels of the feature map.
[0092] in, and All are learnable weight matrices, exp(·) represents an exponential function with the natural number e as the base;
[0093] In the step (4.2), the calculation formula for the hypergraph vertex representation is:
[0094] The process of the fifth step is as follows:
[0095] Step (5.1) aggregates the information of the API connected to the Mashup into the Mashup and proceeds to step (5.2);
[0096] The aggregation formula is Among them, y a (l) represents the embedding of the lth convolution layer of the API on the Mashup-API call relationship graph, Represents the embedding of the lth convolution layer of Mashup on the Mashup-API call relationship graph;
[0097] Step (5.2) aggregates the information of the Mashup connected to the API to the API. If l = L1, execute step (5.3), otherwise l is incremented by 1 and returns to step (5.1);
[0098] Among them, L1 represents the total number of convolution layers, and the aggregation formula is
[0099]
[0100] Among them, y m (l) is the combined output of the multi-channel hypergraph convolutional network and graph convolution results, is the input matrix composed of the embedding matrix of Mashup, D i and D ii denote the degree matrices of T and T" respectively;
[0101] Step (5.3) combines the interaction information between Mashups and the interaction information between Mashup and API to obtain the embedded expression of Mashup and API. The embedding calculation formula is:
[0102] The process of the sixth step is as follows:
[0103] Step (6.1) calculates the similarity between the embedding representations of Mashup m based on the interaction information between Mashups and the interaction information between Mashup-APIs through the inner product
[0104] Among them, P m It represents the embedded representation of Mashup m based on the interaction information between Mashups. represents the embedding representation obtained by Mashupm based on the interaction information between Mashup-APIs, f out (·,·) represents the similarity score function between two vectors, which is defined as the inner product of the two vectors.
[0105] Step (6.2) follows the form of SimCLR, uses InfoNCE as the target of contrastive learning, and defines the contrastive learning loss calculation formula as
[0106] Here, γ is an adjustable temperature parameter.
[0107] Through contrastive learning, the mutual information between the two representations is maximized to improve the performance of the model. Among them, SimCLR is a self-supervised learning framework that aims to learn visual representations through contrastive learning. InfoNCE is the loss function of SimCLR. Its core idea is to learn effective representations by comparing the similarities between positive and negative samples.
[0108] The process of the seventh step is as follows:
[0109] Step (7.1) scores the matching degree between the embedded expression of the Mashup and the embedded expression of the API, and obtains the top K matching APIs;
[0110] Among them, Mashup m i with API a j Match score between By calculating Y g and Y a The inner product between them is obtained;
[0111] Step (7.2) calculates the loss of the model and adjusts the parameters of the model;
[0112] The loss of the recommendation model is represented by BPR loss, which is a loss function used to learn user personalized preferences in recommendation systems, which can make positive samples rank higher than negative samples. Positive samples represent API samples actually called by the current Mashup, and negative samples represent API samples not actually called by the current Mashup. The loss function is calculated as follows:
[0113]
[0114] in, Represents Mashup m i with API a j Matching score, Represents Mashup m i with API a k The matching score between them, log represents the logarithmic function, σ represents a learnable weight matrix, Φ represents the model parameters, Indicates the non-belonging relationship between an element and a collection;
[0115] Step (7.3) combines dual-scale contrastive learning to expand the recommendation task into a multi-objective optimization recommendation task. Taking the Bayesian personalized ranking loss as the main goal and the contrastive learning loss as the secondary goal, the final goal is Among them, ρ is a manually set hyperparameter, that is, the weight of the secondary objective.
[0116] The beneficial effect of the present invention is that by introducing a multi-channel hypergraph convolutional network and utilizing four motif structures such as co-correlation motifs, the model can more accurately capture the complex relationship between service data and improve the accuracy of recommendations. The hybrid random walk algorithm optimizes the convolution weight matrix and reduces the impact of noise, thereby further improving the recommendation effect. At the same time, the convolution operation is simplified, and the computational efficiency and model generalization ability are enhanced. The dual-scale contrast learning method improves the robustness of the model and ensures stability and reliability when processing complex data. The present invention provides an effective solution for the Web API recommendation system, which significantly improves the accuracy and efficiency of the Web API recommendation system. BRIEF DESCRIPTION OF THE DRAWINGS
[0117] Figure 1 The overall architecture of the present invention is shown. DETAILED DESCRIPTION
[0118] The present invention will be further described below in conjunction with the accompanying drawings.
[0119] Reference Figure 1 , a data service recommendation method integrating dual-scale contrastive learning and multi-objective optimization, comprising the following steps:
[0120] The first step is to extract the service hypergraph based on the service motif. The process is as follows:
[0121] Step (1.1) crawl Mashup service information from relevant API websites;
[0122] Step (1.2) analyzes the crawled Mashup service set and selects meta-information that is helpful to improve the accuracy of service recommendation and is rich in content;
[0123] The retained meta information includes Mashup, API, the calling relationship between Mashup and API, and the tags carried by Mashup;
[0124] The Mashup set is defined as M = {m1,m2,…,m N}, where N is the total number of Mashups in the collection, Mashup m i The API set called is A i ={a i,1 ,a i,2 ,a i,3 ,…,a i,k}, k is Mashup m i The total number of APIs called. The set of APIs called by all Mashups is Where ∪ means finding the union of all sets, and the Mashup-API call relationship is stored in a 0-1 matrix middle, represents the set of real numbers, represents a matrix of real numbers and of size N×|A|, where |A| represents the number of elements in the set A, and each pair of Mashup m and API a, t m,a =1 indicates that Mashup m has a calling relationship with API a, t m,a =0 means there is no calling relationship between Mashup m and API a;
[0125] The tag represents part of the function or attribute of the Mashup, and the tag information contains the collaborative information between the Mashup and the API. Therefore, the feature mining process of API and Mashup not only uses the call information but also the tag information. To represent the relationship between labels and Mashup. m,ta =1 means that Mashup m and tag ta have a carrying relationship, R m,ta =0 means that there is no carrying relationship between Mashup m and tag ta;
[0126] Step (1.3) summarizes four types of motifs: co-correlation motifs, multiple strong correlation motifs, single relationship motifs, and complex relationship motifs;
[0127] Among them, motifs represent connection patterns that appear repeatedly in the network and are significantly higher in number than other complex networks. This connection pattern often holds key information about the network. A large number of studies have proven that motifs have a substantial ability to bridge the gap between micro- and macro-structural information.
[0128] The descriptions of the four models are as follows:
[0129] Co-associated motifs: In the Mashup call scenario, there are two Mashups that carry the same label, which is called the same label relationship in this invention. In the service data, there are Mashups that have the same label relationship between each other and form a ternary closure structure, which is called the co-associated motif;
[0130] The ternary closure is a concept in social network theory, which refers to a property of a triple consisting of three nodes A, B, and C, that is, there is a strong connection between A and B, A and C, and B and C.
[0131] Multiple strong correlation motifs: Labels themselves are diverse and artificially defined labels cause uncertainty in the labels carried by Mashups. The present invention defines the relationship between a pair of Mashups carrying two or more identical labels as a strong correlation relationship, and defines the structure in which multiple Mashups are strongly correlated with each other to form a closed loop as a multiple strong correlation motif;
[0132] Single relationship motif: The calling relationship between Mashup and API presents the functional characteristics of Mashup. Two Mashups that call the same API have functional similarities. The present invention defines the motif of two Mashups calling the same API as a single relationship motif.
[0133] Composite relationship motif: Mashups call the same API and carry the same label. In order to use this feature to explore the relationship between mashups, the present invention defines mashups that call the same API and have the same label relationship as composite relationship motifs;
[0134] Step (1.4) performs steps (1.4.1-1.4.4) to construct a multi-channel hypergraph based on the motif proposed in step (1.3);
[0135] Among them, the hypergraph is a generalization of the traditional pairwise relationship graph. In traditional graph theory, the graph consists of nodes (vertices) and edges, while the hypergraph introduces the concept of hyperedges. A hyperedge is a set of nodes connected, not just two nodes. This enables the hypergraph to better describe complex relationships and high-order associations. The present invention uses motifs to construct a multi-channel hypergraph, where each motif constitutes a hyperedge;
[0136] The process of step (1.4) is:
[0137] Step (1.4.1) constructs the hypergraph G1 based on the “co-correlation motifs”;
[0138] Step (1.4.1.1) Calculate the relationship matrix R based on the Mashup-label relationship matrix Perform step (1.4.1.2);
[0139] in, Indicates the number of identical labels between Mashups. " indicates the transposition of the matrix;
[0140] Step (1.4.1.2) construct the upper triangular matrix R * , used to indicate whether the mashups carry the same tags, and proceed to step (1.4.1.3);
[0141] Among them, R * By matrix Take the upper right corner of the diagonal and set all numbers greater than 0 to 1;
[0142] Step (1.4.1.3) calculates the adjacency matrix of the hypergraph G1;
[0143] The adjacency matrix is a matrix that represents the adjacent relationship between vertices in the hypergraph. The calculation formula of the adjacency matrix S1 of the hypergraph G1 is S1 = (R * R * )⊙R * . Among them, ⊙ represents the Hadamard product of the left and right matrices;
[0144] Step (1.4.2) constructs the hypergraph G2 based on the “multiple strongly correlated motifs”;
[0145] Step (1.4.2.1) constructs a matrix R′ to represent whether the mashups carry two or more identical tags, and proceeds to step (1.4.2.2);
[0146] Among them, the matrix R′ is obtained by taking the matrix The upper right diagonal is constructed by setting all numbers greater than 2 to 1 and the rest to 0;
[0147] Step (1.4.2.2) performs steps (1.4.2.2.1-1.4.2.2.2) to calculate the adjacency matrix of the hypergraph G2;
[0148] Step (1.4.2.2.1) defines the adjacency matrix S2 to represent the adjacency matrix of the hypergraph G2;
[0149] Step (1.4.2.2.2) traverses the Mashup set M, and initializes the value i to 1 to record the number of the Mashup, and performs steps (1.4.2.2.2.1-1.4.2.2.2.3) to calculate all values of the i-th row in S2;
[0150] Step (1.4.2.2.2.1) traverses the Mashup set M and initializes the value j to 1 to record the Mashup number, and performs steps (1.4.2.2.2.1.1-1.4.2.2.2.1.3) to calculate S2 in S2 i,j The value of
[0151] Among them, S2 i,j represents the value of the i-th row and j-th column in the adjacency matrix S2;
[0152] Step (1.4.2.2.2.1.1) queries the matrix R to confirm whether the number of identical tags carried by Mashup i and Mashup j is greater than 1. If so, replace S2 i,j Set to 1, otherwise set to 0 and proceed to step (1.4.2.2.2.1.2);
[0153] In step (1.4.2.2.2.1.2), take j=j+1 and proceed to step (1.4.2.2.2.1.3);
[0154] Step (1.4.2.2.2.1.3) determines whether j is less than or equal to N. If so, return to step (1.4.2.2.2.1.1), otherwise exit the loop;
[0155] In step (1.4.2.2.2.2), let i=i+1 and proceed to step (1.4.2.2.2.3);
[0156] Step (1.4.2.2.2.3) determines whether i is less than or equal to N. If so, return to step (1.4.2.2.2.1), otherwise exit the loop;
[0157] Step (1.4.3) constructs the hypergraph G3 based on the “single relation motif”;
[0158] Step (1.4.3.1) is calculated based on the Mashup-API call relationship matrix T Perform step (1.4.3.2);
[0159] in, Indicates the number of calls to the same API between Mashups;
[0160] Step (1.4.3.2) is based on the matrix Calculate the matrix T * , proceed to step (1.4.3.3);
[0161] Among them, the matrix T * By taking the matrix The upper right corner of the diagonal line is constructed by setting all numbers greater than 0 to 1, indicating whether the same API is called between mashups;
[0162] Step (1.4.3.3) calculates the adjacency matrix of the hypergraph G3;
[0163] The calculation formula of the adjacency matrix S3 of the hypergraph G3 is S3 = T * T *" ;
[0164] Step (1.4.4) Based on the “composite relational motif”, the adjacency matrix calculation result of the hypergraph G4 is compared with the upper triangular matrix R * Find the Hadamard product, calculate the adjacency matrix of the hypergraph G4 and construct the hypergraph G4;
[0165] The calculation formula of the adjacency matrix S4 of the hypergraph G4 is S4=(T * T*" )⊙R * , which means filtering out mashup pairs that do not carry the same label;
[0166] The second step is to calculate the convolution weight matrix C of the multi-channel hypergraph through the hybrid random walk algorithm;
[0167] Among them, random walk is a mathematical statistical model, which consists of a series of trajectories and is a random process. In a random walk, each step is based on random factors rather than predetermined rules. After the hypergraph extraction based on the motif structure, the current neighborhood division is relatively rough. Directly convolving the hypergraph is prone to introduce noise. A hypergraph convolution weight matrix can be calculated through random walk to optimize the hypergraph convolution;
[0168] The process of the second step is as follows:
[0169] Step (2.1) proposes a hybrid random walk algorithm based on the combination of partial absorption random walk and biased random walk, and executes steps (2.1.1-2.1.2) to calculate the convolution weight matrix C on the hypergraph;
[0170] Among them, the convolution weight matrix in, represents the set of real numbers, c i,j represents the value of the i-th row and j-th column in matrix C, represents a matrix of size N×N composed of real numbers, ∈ represents the belonging relationship between elements and sets;
[0171] In order to avoid the random walk from converging to a stationary distribution determined only by the degree of each node, we refer to the partial absorption random walk and assume that the random process X = {X t :t≥0} is the transition probability matrix
[0172]
[0173] Among them, the partially absorbing random walk is a second-order Markov chain, which is characterized by a certain probability of staying in the current state or transitioning to the next state in each state, which is determined by the transition probability p i,j The global semantic structure of the topology is captured by the decision. Once the walk stops at a certain state, it will stay in that state forever, that is, it will be absorbed in the current state.
[0174] in, Among them, d i represents the degree of vertex i, which represents the number of edges connected to the vertex in the graph, S i,j represents the value of the i-th row and j-th column in the adjacency matrix S, λ i∈Λ,Λ=diag(λ1,λ2,...,λ N ) is a regularized matrix with all values greater than 0, where diag() indicates that the elements in the brackets form a diagonal matrix, and the calculation formula of Λ is Λ=δI. Where I represents the unit matrix, δ represents the weight coefficient, and the absorption probability between nodes can be adjusted by adjusting δ; Step (2.1.2) combines the parameter matrix Q with P to obtain the convolution weight calculation formula on the hypergraph
[0175]
[0176] Among them, Q is the parameter matrix used to adjust the transition probability in the biased random walk. The biased random walk combines the breadth-first and depth-first sampling strategies to adjust the transition probability, so as to achieve the purpose of balancing homogeneity and structural equivalence, and can flexibly search for complex network structures. The element q in the i-th row and j-th column of the matrix Q is i,j The calculation formula is
[0177] Among them, breadth-first and depth-first are two common search strategies. The breadth-first strategy traverses the graph or tree structure layer by layer in a hierarchical manner, first visiting all adjacent nodes, and then visiting the nodes in the next layer in turn. It is suitable for finding the shortest path. The depth-first strategy explores down along a branch to the end, and then traces back to the previous branch. It is suitable for finding all possible solutions. i,j represents the shortest distance between nodes i and j, and p and q are parameters for adjusting the walking strategy. Among them, homogeneity means that two nodes belonging to the same cluster are more similar, and structural equivalence means that two nodes with the same structural role are more similar;
[0178] Step (2.2) According to the weight calculation formula, we can further obtain Λ(CI)+CD=(W⊙Q)C, where D represents the degree matrix of the hypergraph. The degree matrix is a diagonal matrix, and its diagonal elements represent the degrees of the corresponding vertices.
[0179] Among them, W represents the weight between nodes determined by the degree, and the element in the i-th row and j-th column of the matrix can be expressed as
[0180]
[0181] Step (2.2.3) is further calculated to deduce the closed form of the convolution weight matrix C = (Λ + L) -1 Λ;
[0182] Where, L = DW⊙Q;
[0183] The third step is to perform convolution operations on the hypergraph and aggregate the convolution results on multiple channels to obtain the embedded expression of the Mashup. The process is as follows:
[0184] Step (3.1) combines the convolution weight matrix with the traditional hypergraph convolutional network. Based on LightGCN, the feature transformation and activation function are discarded, the convolution operation is simplified, and the convolution operation is defined as X (l+1) =D (-1) SX (l) ;
[0185] Among them, LightGCN is a recommendation algorithm based on graph neural network. It improves efficiency and performance by simplifying the model structure. It is easy to understand and explain and is widely used. Feature transformation refers to the method of obtaining new features through certain rules or mappings of the original features. The activation function refers to the functional relationship between the output of the upper node and the input of the lower node in the multi-layer neural network. (l) and X (l+1) Represents the input and output of a single convolution, S represents the adjacency matrix, D (-1) represents the inversion of matrix D;
[0186] Step (3.2) introduces the convolution weight matrix C and performs the hypergraph convolution operation;
[0187] Among them, the single-layer convolution formula is X (l+1) =CX (l) , the convolution formula of the hypergraph convolutional network with L layers of convolution is y (L) =C…(CX (0) );
[0188] in, represents the input matrix composed of the embedding matrices of the hypergraph vertices. Since the present invention adopts a multi-channel hypergraph convolutional network, C in the formula can be replaced by the convolution weight matrices C1, C2, C3 and C4 of the hypergraphs G1, G2, G3 and G4 to obtain the output result y1 (L) ,y2 (L) ,y3 (L) ,y4 (L) ;
[0189] Where s represents the embedding length.
[0190] Step (3.3) averages the output of each convolution to obtain the final output of each channel;
[0191] Among them, y n The calculation formula is
[0192] Step 4: According to the channel error attention mechanism, combined with the output results of each channel, the process is as follows:
[0193] Step (4.1) uses the channel error attention mechanism to calculate the weight of each channel
[0194] Step (4.1.1) directly uses the output results of different channels for loss calculation to obtain the error between the estimated value and the true value of the channel.
[0195] The error calculation formula is:
[0196] The smaller the error value, the stronger the identification feature extracted by the channel, and the larger the weight should be. Φ represents the model parameter, Represents Mashup m i with API a j The scoring function is Represents Mashup m i with API a k The scoring function of .
[0197] Step (4.1.2) introduces the error of step (4.1.1) into the channel attention mechanism to obtain a new channel error attention formula, which is:
[0198]
[0199] Among them, the channel attention mechanism is a technology used to enhance the performance of neural networks, mainly used in computer vision and natural language processing. Its core idea is to highlight important features and suppress irrelevant features by assigning different weights to different channels of the feature map.
[0200] in, and are all learnable weight matrices, and exp(·) represents an exponential function with the natural number e as the base.
[0201] Step (4.2) aggregates the output of each channel according to the weight to obtain a complete representation of the hypergraph vertex; the calculation formula for the hypergraph vertex representation is:
[0202] Step 5: Convolve the Mashup-API call relationship graph to obtain the embedded expression of the API. The process is as follows:
[0203] Step (5.1) aggregates the information of the API connected to the Mashup into the Mashup and proceeds to step (5.2);
[0204] The aggregation formula is Among them, y a (l) represents the embedding of the lth convolution layer of the API on the Mashup-API call relationship graph, Represents the embedding of the lth convolution layer of Mashup on the Mashup-API call relationship graph;
[0205] Step (5.2) aggregates the information of the Mashup connected to the API to the API. If l = L1, execute step (5.3), otherwise l is incremented by 1 and returns to step (5.1);
[0206] Among them, L1 represents the total number of convolution layers, and the aggregation formula is
[0207]
[0208] Among them, y m (l) is the combined output of the multi-channel hypergraph convolutional network and graph convolution results, is the input matrix composed of the embedding matrix of Mashup, D i and D ii denote the degree matrices of T and T" respectively;
[0209] Step (5.3) combines the interaction information between Mashups and the interaction information between Mashup and API to obtain the embedded expression of Mashup and API. The embedding calculation formula is:
[0210] Step 6: Propose a dual-scale contrastive learning method to maximize the consistency between the same node and the difference between different nodes obtained by two different approaches, so as to enable the recommendation model to obtain more information;
[0211] Among them, consistency and difference are reflected in the degree of similarity.
[0212] The process of the sixth step is as follows:
[0213] Step (6.1) calculates the similarity between the embedding representations of Mashup m based on the interaction information between Mashups and the interaction information between Mashup-APIs through the inner product
[0214] Among them, P m It represents the embedded representation of Mashup m based on the interaction information between Mashups. represents the embedding representation obtained by Mashupm based on the interaction information between Mashup-APIs, f out (·,·) represents the similarity score function between two vectors, which is defined as the inner product of the two vectors.
[0215] Step (6.2) follows the form of SimCLR, uses InfoNCE as the target of contrastive learning, and defines the contrastive learning loss calculation formula as
[0216] Here, γ is an adjustable temperature parameter.
[0217] Through contrastive learning, the mutual information between the two representations is maximized to improve the performance of the model. Among them, SimCLR is a self-supervised learning framework that aims to learn visual representations through contrastive learning. InfoNCE is the loss function of SimCLR. Its core idea is to learn effective representations by comparing the similarities between positive and negative samples.
[0218] Step 7: Optimize the model based on the model recommendation results. The process is as follows:
[0219] Step (7.1) scores the matching degree between the embedded expression of the Mashup and the embedded expression of the API, and obtains the top K matching APIs;
[0220] Among them, Mashup m i with API a j Match score between By calculating Y g and Y a The inner product between them is obtained;
[0221] Step (7.2) calculates the loss of the model and adjusts the parameters of the model;
[0222] The loss of the recommendation model is represented by BPR loss, which is a loss function used to learn user personalized preferences in recommendation systems, which can make positive samples rank higher than negative samples. Positive samples represent API samples actually called by the current Mashup, and negative samples represent API samples not actually called by the current Mashup. The loss function is calculated as follows:
[0223]
[0224] in, Represents Mashup m i with API a j Matching score, Represents Mashup m i with API a k The matching score between , log represents the logarithmic function, σ represents a learnable weight matrix, and Φ represents the model parameters;
[0225] Step (7.3) combines dual-scale contrastive learning to expand the recommendation task into a multi-objective optimization recommendation task. Taking the Bayesian personalized ranking loss as the main goal and the contrastive learning loss as the secondary goal, the final goal is Among them, ρ is a manually set hyperparameter, that is, the weight of the secondary objective.
[0226] The embodiment of the present invention is
[0227] Step 1: Select a benchmark method
[0228] The recommendation method of the present invention is compared with a variety of very typical or advanced recommendation methods, wherein these recommendation methods can be divided into three categories: collaborative filtering methods, neural network methods and graph neural network methods:
[0229] 1) Collaborative filtering method:
[0230] PRCUM: Mashup is modeled by mining the description text to find its nearest neighbor mashup set, and the nearest neighbor set is used to enrich the user model and find the recommended API.
[0231] NHSM: A novel similarity model is used to utilize the local information of Mashup and API similarity and the global information of Mashup and API call relationship for similarity calculation to improve recommendation performance.
[0232] 2) Neural Network Method:
[0233] NCF: Combines neural networks and traditional collaborative filtering techniques to model Mashup-API interactions, solves collaborative filtering based on implicit feedback, and uses multi-layer perceptrons to learn Mashup-API interaction functions.
[0234] LRML: Based on the simple metric learning method, an enhanced memory module is introduced to learn a relationship vector specific to each Mashup-API pair, and the relationship vector is used to model the relationship between Mashup and API in the metric space.
[0235] 3) Graph Neural Network Method:
[0236] DGCF: Models the calling relationship of Mashup-API and effectively extracts information related to the intent of each Mashup through disentangled representation, making the recommendation model explainable.
[0237] NGCF: This is a graph-based collaborative filtering method that fuses the information relationship between neighbor nodes and the current node during the propagation process through element-wise product.
[0238] LightGCN: It is an efficient graph convolution recommendation model that obtains the embedding matrix of Mashup and API through graph convolution, and matches API and Mashup based on distance.
[0239] NIA-GCN: This is a GCN-based neural network model that combines an attention mechanism to capture the complex interaction patterns between nodes in graph data, thereby achieving more accurate prediction and reasoning.
[0240] S 2 -MHCN: Use social network motifs to build a multi-channel hypergraph for the mashup set, use the attention mechanism to combine the information in different hypergraphs, and use self-supervised learning to adjust the representation of the mashup to reduce the error caused by splicing.
[0241] Step 2: Crawling Mashup service data from the ProgrammableWeb platform and conducting experiments. Since a key goal of service recommendation is to alleviate the data sparsity problem, in order to verify the ability of the model of the present invention to process sparse data, the service data is processed and a dense data set is divided to compare with the original sparse data set.
[0242] Among them, only Mashups with the number of API calls greater than or equal to 5 are retained in the dense data set.
[0243] Step 3: Select a normalized discounted cumulative gain (NDCG) that is related to the ranking order and a hit rate (HR) that is independent of the ranking order as evaluation indicators for the model recommendation results.
[0244] Among them, the NDCG indicator is a normalized representation of the discounted cumulative gain (DCG). This indicator takes into account the order of recommendation. The normalized discounted cumulative gain of the top-ranked recommended items is higher. It is specifically expressed as: Among them, K represents the number of recommended APIs, n represents the ranking of the service in the recommendation list, and IDCG represents the DCG under ideal conditions. HR is a commonly used Top-N evaluation indicator, especially in cases where the recommendation order is irrelevant. The higher the HR value, the better the recommendation effect. It is calculated as follows: Among them, hit(i) indicates whether API i is hit in the recommendation list of Mashup, and N indicates the actual number of API calls of Mashup.
[0245] Step 4: Compare through experiments.
[0246] The performance comparison experiment of the proposed method and other baseline methods covers dense data sets and sparse data sets. The comparison results are shown in the following table. Among them, the best result of each indicator is bolded and the suboptimal result is underlined. By analyzing the data in the table, the following results can be obtained:
[0247] Table 1
[0248]
[0249] The collaborative filtering methods PRCUM and NHSM performed poorly in all indicators, especially in the order-related indicator NDCG@K. The PRCUM method mines the relationship between Mashup and API through description text. Since the description texts of API and Mashup are both short texts, the recommendation results are not ideal. The NHSM method additionally introduces the calling relationship between Mashup and API as the basis of the relationship between the two, which improves the recommendation performance. However, since the calling relationship is relatively sparse, it also affects the recommendation effect.
[0250] The neural network method introduces neural network technology to model the relationship between Mashup and API, paying more attention to the underlying connection between Mashup and API. By learning the nonlinear characteristics of services and considering the representation and generalization capabilities of feature vectors, it can better learn the relationship characteristics between services and improve the recommendation effect. It performs better than the collaborative filtering method in all indicators.
[0251] The graph neural network type methods performed the best among all types of methods. Among them, DGCF and NGCF integrated collaborative filtering with graph neural networks, better combined the calling relationship between Mashup and API into the embedded representation, and were more suitable for the recommendation task of the present invention than ordinary neural network methods. LightGCN reduced the over-smoothing problem and improved the recommendation effect by abandoning the feature changes and nonlinear activation functions in conventional graph convolutions. NIA-GCN proposed a variety of different information aggregation mechanisms based on the structural characteristics of the graph, which more effectively aggregated node information and further improved the recommendation effect. S 2 -MHCN builds a motif and uses it to construct multiple hypergraphs, solving the sparsity problem commonly seen in graph convolutions. However, due to S 2 -The motifs in the MHCN method are based on social scenarios and cannot fully consider the relationship between Mashup and tags, API and tags, and the extended relationships in the service recommendation scenario. It is not applicable to the recommendation scenario based on service data, which affects the recommendation results.
[0252] The proposed method outperforms all baseline methods in all indicators, and in sparse and dense datasets, NDCG@5 and HR@5 are improved by 6.52%, 5.52%, 3.85% and 2.69% respectively compared with the suboptimal results. Compared with other common graph neural network methods, the superior performance of the present invention proves the effectiveness of establishing motifs based on the relationship structure between common Mashups, APIs and additional information such as labels, and extracting hypergraphs through motifs. The hybrid random walk also correctly adjusts the connection relationship and weight size between each node, and the hypergraph structure can effectively utilize the high-order information between Mashups and APIs and between Mashups to improve the model recommendation performance.
[0253] The contents described in the embodiments of this specification are merely enumerations of implementation forms of the inventive concept and are for illustrative purposes only. The protection scope of the present invention should not be considered to be limited to the specific forms described in this embodiment, and the protection scope of the present invention also extends to equivalent technical means that can be thought of by ordinary technicians in this field based on the inventive concept.
Claims
1. A data service recommendation method integrating dual-scale contrastive learning and multi-objective optimization, characterized in that: The method comprises the following steps: The first step is to extract the service hypergraph based on the service motif. The process is as follows: Step (1.1) crawl Mashup service information from relevant API websites; Step (1.2) analyzes the crawled Mashup service set and selects meta-information that is helpful to improve the accuracy of service recommendation and is rich in content; Step (1.3) summarizes four types of motifs: co-correlation motifs, multiple strong correlation motifs, single relationship motifs, and complex relationship motifs; Step (1.4) constructs a multi-channel hypergraph based on the motif proposed in step (1.3); The second step is to calculate the convolution weight matrix C of the multi-channel hypergraph through the hybrid random walk algorithm. The process is as follows: Step (2.1) proposes a hybrid random walk algorithm based on the combination of partial absorption random walk and biased random walk to calculate the convolution weight matrix C on the hypergraph; Step (2.2) is further obtained according to the weight calculation formula: Λ(CI)+CD=(W⊙Q)C, where Λ is a regularized matrix with all values greater than 0, D represents the degree matrix of the hypergraph, which is a diagonal matrix whose diagonal elements represent the degrees of the corresponding vertices; W represents the weights between nodes determined by the degrees, and Q is a parameter matrix used to adjust the transition probability in the biased random walk; Step (2.3) is further calculated to deduce the closed form of the convolution weight matrix C = (Λ + L) -1 Λ; where L = DW⊙Q; Step 3: Perform convolution operations on the hypergraph and aggregate the convolution results on multiple channels to obtain the embedded expression of the Mashup; The fourth step is to combine the output results of each channel according to the channel error attention mechanism. The process is as follows: Step (4.1) uses the channel error attention mechanism to calculate the weight of each channel; Step (4.2) aggregates the output of each channel according to the weight to obtain a complete representation of the hypergraph vertices; Step 5: Convolve the Mashup-API call relationship graph to obtain the embedded expression of the API; Step 6: Propose a dual-scale contrastive learning method to maximize the consistency between the same node and the difference between different nodes obtained by two different approaches, so as to enable the recommendation model to obtain more information; Step 7: Optimize the model based on the model recommendation results.
2. The data service recommendation method integrating dual-scale contrastive learning and multi-objective optimization as claimed in claim 1, characterized in that: In the step (1.2), the retained meta-information includes Mashup, API, the calling relationship between Mashup and API, and the tags carried by Mashup; The Mashup set is defined as M = {m1,m2,…,m N }, where N is the total number of Mashups in the set, Mashupm i The API set called is A i ={a i,1 ,a i,2 ,a i,3 ,…,a i,k }, k is Mashup m i The total number of APIs called. The set of APIs called by all Mashups is Where ∪ means finding the union of all sets, and the Mashup-API call relationship is stored in a 0-1 matrix middle, represents the set of real numbers, represents a matrix of real numbers and of size N×|A|, where |A| represents the number of elements in the set A, and each pair of Mashup m and API a, t m,a =1 indicates that Mashup m has a calling relationship with API a, t m,a =0 means there is no calling relationship between Mashup m and API a; Among them, the label represents part of the function or attribute of the Mashup. The label information contains the collaborative information between the Mashup and the API. Therefore, the feature mining process of the API and Mashup not only uses the call information but also the label information. To represent the relationship between labels and Mashup, each pair of Mashup m and label ta involved, R m,ta =1 means that Mashup m and tag ta have a carrying relationship, R m,ta =0 means that there is no carrying relationship between Mashup m and tag ta.
3. The data service recommendation method integrating dual-scale contrastive learning and multi-objective optimization according to claim 1 or 2, characterized in that: In the step (1.3), the motif represents a connection pattern that appears repeatedly in the network and is significantly higher in number than other complex networks. This connection pattern often holds key information about the network. A large number of studies have proven that motifs have a substantial ability to bridge the gap between micro- and macro-structural information. The descriptions of the four motifs are as follows: Co-associated motif: In the Mashup call scenario, there are two Mashups that carry the same label, which is called the same label relationship in the present invention. In the service data, there are Mashups that have the same label relationship between each other and form a ternary closure structure, which is called the co-associated motif. The ternary closure is a concept in social network theory, which refers to a property of a triple consisting of three nodes A, B, and C, that is, there is a strong connection between A and B, A and C, and B and C. Multiple strong correlation motifs: Labels are diverse and artificially defined, which causes uncertainty in the labels carried by Mashups. A pair of Mashups carrying two or more identical labels is defined as a strong correlation, and a closed-loop structure with strong correlations between multiple Mashups is defined as a multiple strong correlation motif. Single relationship motif: The calling relationship between Mashup and API presents the functional characteristics of Mashup. Two Mashups that call the same API have functional similarities. The motif of two Mashups calling the same API is defined as a single relationship motif. Composite relationship motif: Mashups call the same API and carry the same label. In order to use this feature to explore the relationship between mashups, mashups that call the same API and have the same label relationship are defined as composite relationship motifs.
4. The data service recommendation method integrating dual-scale contrastive learning and multi-objective optimization according to claim 1 or 2, characterized in that: The process of step (1.4) is: Step (1.4.1) constructs the hypergraph G1 based on the "co-correlation motifs" as follows: Step (1.4.1.1) Calculate the relationship matrix R based on the Mashup-label relationship matrix Perform step (1.4.1.2); in, Indicates the number of identical labels between Mashups, where " indicates the transpose of the matrix; Step (1.4.1.2) construct the upper triangular matrix R * , used to indicate whether the mashups carry the same tags, and proceed to step (1.4.1.3); Among them, R * By matrix Take the upper right corner of the diagonal and set all numbers greater than 0 to 1; Step (1.4.1.3) calculates the adjacency matrix of the hypergraph G1; The adjacency matrix is a matrix that represents the adjacent relationship between vertices in the hypergraph. The calculation formula of the adjacency matrix S1 of the hypergraph G1 is S1=(R * R * )⊙R * , where ⊙ represents the Hadamard product of the left and right matrices; Step (1.4.2) constructs the hypergraph G2 based on the "multiple strongly associated motifs", as follows: Step (1.4.2.1) constructs a matrix R′ to represent whether the mashups carry two or more identical tags, and proceeds to step (1.4.2.2); Among them, the matrix R′ is obtained by taking the matrix The upper right diagonal is constructed by setting all numbers greater than 2 to 1 and the rest to 0; Step (1.4.2.2) calculates the adjacency matrix of the hypergraph G2; Step (1.4.3) constructs the hypergraph G3 based on the "single relation motif" as follows: Step (1.4.3.1) is calculated based on the Mashup-API call relationship matrix T Perform step (1.4.3.2); in, Indicates the number of calls to the same API between Mashups; Step (1.4.3.2) is based on the matrix Calculate the matrix T * , proceed to step (1.4.3.3); Among them, the matrix T * By taking the matrix The upper right corner of the diagonal line is constructed by setting all numbers greater than 0 to 1, indicating whether the same API is called between mashups; Step (1.4.3.3) calculates the adjacency matrix of the hypergraph G3; The calculation formula of the adjacency matrix S3 of the hypergraph G3 is S3 = T * T *" ; Step (1.4.4) Based on the "composite relational motif", the adjacency matrix calculation result of the hypergraph G4 is compared with the upper triangular matrix R * Find the Hadamard product, calculate the adjacency matrix of the hypergraph G4 and construct the hypergraph G4; The calculation formula of the adjacency matrix S4 of the hypergraph G4 is S4=(T * T *" )⊙R * , which means filtering out mashup pairs that do not carry the same label; The processing process of the step (1.4.2.2) is: Step (1.4.2.2.1) defines the adjacency matrix S2 to represent the adjacency matrix of the hypergraph G2; Step (1.4.2.2.2) traverses the Mashup set M, and initializes the value i to 1 to record the number of the Mashup, and performs steps (1.4.2.2.2.1-1.4.2.2.2.3) to calculate all values of the i-th row in S2; Step (1.4.2.2.2.1) traverses the Mashup set M and initializes the value j to 1 to record the Mashup number, and performs steps (1.4.2.2.2.1.1-1.4.2.2.2.1.3) to calculate S2 in S2 i,j The value of Among them, S2 i,j represents the value of the i-th row and j-th column in the adjacency matrix S2; Step (1.4.2.2.2.1.1) queries the matrix R to confirm whether the number of identical tags carried by Mashup i and Mashup j is greater than 1. If so, replace S2 i,j Set to 1, otherwise set to 0 and proceed to step (1.4.2.2.2.1.2); In step (1.4.2.2.2.1.2), take j=j+1 and proceed to step (1.4.2.2.2.1.3); Step (1.4.2.2.2.1.3) determines whether j is less than or equal to N. If so, return to step (1.4.2.2.2.1.1), otherwise exit the loop; In step (1.4.2.2.2.2), let i=i+1 and proceed to step (1.4.2.2.2.3); Step (1.4.2.2.2.3) determines whether i is less than or equal to N. If so, return to step (1.4.2.2.2.1), otherwise exit the loop.
5. The data service recommendation method integrating dual-scale contrastive learning and multi-objective optimization according to claim 1 or 2, characterized in that: In step (2.1), the convolution weight matrix c i,j represents the value of the i-th row and j-th column in matrix C, represents a matrix of size N×N composed of real numbers, ∈ represents the belonging relationship between elements and sets; the process is as follows: In order to avoid the random walk from converging to a stationary distribution determined only by the degree of each node, we refer to the partial absorption random walk and assume that the random process X = {X t :t≥0} is the transition probability matrix Among them, the partially absorbing random walk is a second-order Markov chain. In each state, there is a certain probability of staying in the current state or transitioning to the next state, which is determined by the transition probability p i,j Decide; in, Among them, d i represents the degree of vertex i, which represents the number of edges connected to the vertex in the graph, S i,j represents the value of the i-th row and j-th column in the adjacency matrix S, λ i ∈Λ,Λ=diag(λ1,λ2,…,λ N ) is a regularized matrix with all values greater than 0, where diag() indicates that the elements in the brackets form a diagonal matrix. The calculation formula of Λ is Λ=δI, where I represents the unit matrix and δ represents the weight coefficient. By adjusting δ, the absorption probability between nodes can be adjusted. Step (2.1.2) combines the parameter matrix Q with P to obtain the convolution weight calculation formula on the hypergraph Among them, Q is the parameter matrix used to adjust the transition probability in the biased random walk. The biased random walk combines the breadth-first and depth-first sampling strategies to adjust the transition probability, so as to achieve the purpose of balancing homogeneity and structural equivalence, and can flexibly search for complex network structures. The element q in the i-th row and j-th column of the matrix Q is i,j The calculation formula is Among them, breadth-first and depth-first are two common search strategies. The breadth-first strategy traverses the graph or tree structure layer by layer in a hierarchical manner, first visiting all adjacent nodes, and then visiting the nodes in the next layer in turn. It is suitable for finding the shortest path; the depth-first strategy explores down along a branch to the end, and then traces back to the previous branch. It is suitable for finding all possible solutions. Among them, d i,j represents the shortest distance between nodes i and j, p and q are parameters for adjusting the walking strategy; among them, homogeneity means that two nodes belonging to the same cluster are more similar, and structural equivalence means that two nodes with the same structural role are more similar.
6. The data service recommendation method integrating dual-scale contrastive learning and multi-objective optimization according to claim 1 or 2, characterized in that: The process of the third step is as follows: Step (3.1) combines the convolution weight matrix with the traditional hypergraph convolutional network. Based on LightGCN, the feature transformation and activation function are discarded, the convolution operation is simplified, and the convolution operation is defined as X (l+1) =D (-1) SX (l) ; Among them, LightGCN is a recommendation algorithm based on graph neural network. Feature transformation refers to the method of obtaining new features through certain rules or mappings of an original feature. The activation function refers to a functional relationship between the output of the upper node and the input of the lower node in the multi-layer neural network. (l) and X (l+1) Represents the input and output of a single convolution, S represents the adjacency matrix, D (-1) represents the inversion of matrix D; Step (3.2) introduces the convolution weight matrix C and performs the hypergraph convolution operation; Among them, the single-layer convolution formula is X (l+1) =CX (l) , the convolution formula of the hypergraph convolutional network with L layers of convolution is y (L) =C…(CX (0) ); in, Represents the input matrix composed of the embedding matrices of the hypergraph vertices. A multi-channel hypergraph convolutional network is used, so C in the formula can be replaced by the convolution weight matrices C1, C2, C3 and C4 of the hypergraphs G1, G2, G3 and G4 to obtain the output result y1 (L) ,y2 (L) ,y3 (L) ,y4 (L) ; Where s represents the embedding length; Step (3.3) averages the output of each convolution to obtain the final output of each channel; Among them, y n The calculation formula is 7. The data service recommendation method integrating dual-scale contrastive learning and multi-objective optimization according to claim 1 or 2, characterized in that: The process of step (4.1) is: Step (4.1.1) directly uses the output results of different channels for loss calculation to obtain the error between the estimated value and the true value of the channel; The error calculation formula is: Among them, the smaller the error value, the stronger the identification feature extracted by the channel, and the larger the weight should be. Φ represents the model parameter. Represents Mashup m i with API a j The scoring function is Represents Mashup m i with API a k The scoring function of Step (4.1.2) introduces the error of step (4.1.1) into the channel attention mechanism to obtain a new channel error attention formula, which is in, and All are learnable weight matrices, exp(·) represents an exponential function with the natural number e as the base; In the step (4.2), the calculation formula for the hypergraph vertex representation is:
8. The data service recommendation method integrating dual-scale contrastive learning and multi-objective optimization according to claim 1 or 2, characterized in that: The process of the fifth step is as follows: Step (5.1) aggregates the information of the API connected to the Mashup into the Mashup and proceeds to step (5.2); The aggregation formula is , where y a (l) represents the embedding of the lth convolution layer of the API on the Mashup-API call relationship graph, Represents the embedding of the lth convolution layer of Mashup on the Mashup-API call relationship graph; Step (5.2) aggregates the information of the Mashup connected to the API to the API. If l = L1, execute step (5.3), otherwise l is incremented by 1 and returns to step (5.1); Among them, L1 represents the total number of convolution layers, and the aggregation formula is y a (l+1) =D ii -1 T"y m (l) , Among them, y m (l) is the combined output of the multi-channel hypergraph convolutional network and graph convolution results, is the input matrix composed of the embedding matrix of Mashup, D i and D ii denote the degree matrices of T and T" respectively; Step (5.3) combines the interaction information between Mashups and the interaction information between Mashup and API to obtain the embedded expression of Mashup and API, where the embedding calculation formula is 9. The data service recommendation method integrating dual-scale contrastive learning and multi-objective optimization according to claim 1 or 2, characterized in that: The process of the sixth step is as follows: Step (6.1) calculates the similarity between the embedding representations of Mashup m based on the interaction information between Mashups and the interaction information between Mashup-APIs through the inner product Among them, P m It represents the embedded representation of Mashup m based on the interaction information between Mashups. represents the embedded representation of Mashup m based on the interaction information between Mashup-APIs, and f out (·,·) represents the similarity scoring function between two vectors, which is defined as the inner product of the two vectors; Step (6.2) follows the form of SimCLR, uses InfoNCE as the target of contrastive learning, and defines the contrastive learning loss calculation formula as Among them, γ is an adjustable temperature parameter; Through contrastive learning, the mutual information between the two representations is maximized to improve the performance of the model. SimCLR is a self-supervised learning framework that aims to learn visual representations through contrastive learning. InfoNCE is the loss function of SimCLR. Its core idea is to learn effective representations by comparing the similarities between positive and negative samples.
10. The data service recommendation method integrating dual-scale contrastive learning and multi-objective optimization according to claim 1 or 2, characterized in that: The process of the seventh step is as follows: Step (7.1) scores the matching degree between the embedded expression of the Mashup and the embedded expression of the API, and obtains the top K matching APIs; Among them, Mashup m i with API a j Match score between By calculating Y g and Y a The inner product between them is obtained; Step (7.2) calculates the loss of the model and adjusts the parameters of the model; The loss of the recommendation model is represented by BPR loss. Positive samples represent API samples actually called by the current Mashup, and negative samples represent API samples not actually called by the current Mashup. The loss function is calculated as follows: in, Represents Mashup m i with API a j Matching score, Represents Mashup m i with API a k The matching score between them, log represents the logarithmic function, σ represents a learnable weight matrix, Φ represents the model parameters, Indicates the non-belonging relationship between an element and a collection; Step (7.3) combines dual-scale contrastive learning to expand the recommendation task into a multi-objective optimization recommendation task, taking the Bayesian personalized ranking loss as the main goal and the contrastive learning loss as the secondary goal, and the final goal is Among them, ρ is a manually set hyperparameter, that is, the weight of the secondary objective.
Citation Information
Patent Citations
Dialogue recommendation algorithm based on dual-channel hypergraph interest modeling
CN115408505A
SaaS-oriented Web Api diversity recommendation method fused with restart random walk algorithm
CN115599980A
Contrast learning news recommendation method based on hypergraph enhancement
CN117033763A
Hypergraph-based collaborative filtering recommendations
US20230385607A1