Sequence-aware service recommendation method based on dual-tower model
By adopting a sequence-aware service recommendation method based on the dual-tower model, constructing a service network graph and designing a self-attention mechanism, we solved the problem that existing technologies fail to effectively capture the complex signal differences between users and API services, and improved the accuracy and personalization of service recommendations.
Patent Information
- Application Number
- CN202510063199.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-15
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2045-01-15
AI Technical Summary
Existing technologies fail to effectively capture the complex signal differences in the interaction between users and API services in service recommendations, lack consideration of the needs of personalized service recommendations, and the application of dual-tower models and graph convolutional neural networks in the field of service computing is insufficient.
A sequence-aware service recommendation method based on the dual-tower model is adopted. By constructing a service network graph, a query-aware self-attention mechanism is designed, and a graph convolutional network is used to extract service features. Graph pooling and multi-head self-attention mechanisms are used to capture dynamic focus services and predict the interaction probability between users and target services.
It realizes the correlation mining of massive API service data, improves the accuracy and personalized recommendation capabilities of service recommendations, effectively captures user behavior patterns and dynamic changes, and improves the accuracy of service recommendations.
Smart Images

Figure CN119917742B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of service computing, and in particular relates to a sequence-aware service recommendation method based on a double-tower model. Background Art
[0002] Service-oriented computing (SOC), the current mainstream paradigm for web applications, enables agile application development through internet-based service invocations, aiming to build flexible applications that can quickly respond to business needs. Web APIs are reusable and programmable application programming interfaces (APIs). They serve as the fundamental building blocks for developers to quickly build applications and are increasingly becoming the driving force behind the development of service-oriented computing.
[0003] Service recommendation technology can effectively help developers find suitable API services, attracting a large number of researchers in the field of service computing. For example, Ren et al. proposed a collaborative filtering service recommendation method based on SVM. They obtained a separating hyperplane from historical rating data and then used the distance between the points representing the service and the separating hyperplane to measure the user's preference for a particular service to make service recommendations. Wang et al. designed a structural interaction component to encode the potential structural relationship between mashups and APIs in heterogeneous networks and capture the topological structure signals between different mashups and APIs. They then generated text embedding vectors for mashups and APIs to meet multi-level semantic requirements, and finally fused the output vectors to obtain a service recommendation list.
[0004] The twin-tower model is a machine learning framework that constructs two independent neural network branches to process different data features, respectively, and uses an interoperability layer to effectively fuse or compare these features. It has garnered widespread attention in fields such as search engines, recommendation systems, and social networks. For example, Su et al. introduced an all-to-all interaction module to enhance the interaction between queries and items. They also designed a model based on discrete codes and a sparse inverted index that balances efficient retrieval with accurate candidate item matching, providing new insights for modeling complex data relationships. Lee et al. proposed a flexible twin-tower recommendation model to improve the accuracy of cold-start recommendations. Although the twin-tower model has been widely used in recommendation systems, researchers in the service computing field have yet to apply it to service recommendations.
[0005] Sequential recommendation technology predicts a user's next behavioral preference based on modeling the user's historical behavior sequence. Compared with traditional recommendation methods, sequential recommendation focuses on user behavior patterns and contextual information, thereby better capturing user preference changes and behavior patterns. For example, Du et al. applied sliding window technology to long user sequences in bidirectional Transformers to capture user behavior patterns in a more fine-grained manner, and combined cloze masks and discard masks to generate high-quality positive samples. Li et al. considered sequential patterns and high-order heterogeneous collaborative signals to improve recommendation performance. Zhang et al. proposed a framework that integrates user sequences and dynamic collaborative signals, connects different user sequences to construct a dynamic graph, and designs a dynamic graph recommendation network to capture user behavior preferences. However, in service recommendation, no researchers have paid attention to the dynamic changes in developer behavior, and lack consideration of the needs of personalized service recommendations.
[0006] Graph convolutional neural networks (GCNNs) were proposed by Thomas Kipf and Max Welling in 2016. As an extension of convolutional neural networks, GCNNs are capable of processing non-Euclidean data. Their core concept is to iteratively aggregate feature information of nodes and their neighbors in a graph, effectively capturing the complex relationships within graph data. They have been widely used in recommendation systems, transportation networks, and knowledge graphs. Zhang et al. proposed a semantic variational graph autoencoder based on GCNNs to form a recommendation model. Wang et al. utilized a knowledge-graph-aware deep GCNN with initial residual connections to reuse initial item feature information, while also utilizing a knowledge-graph-aware deep GCNN with dense connections to reuse item feature information at each layer, improving the ability to recommend high-level items. While these methods improve recommendation accuracy to some extent, they ignore the diverse nature of complex signals in user interactions with API services. By treating all signals equally, they fail to accurately capture the role of different signals in API service mining. Summary of the Invention
[0007] To overcome the shortcomings of existing technologies, the present invention proposes a sequence-aware service recommendation method based on a dual-tower model. First, the method uses the dual-tower model to mine the similarity of service features and construct a service network graph, from which the focus services are differentiated. Secondly, during the graph convolution process, a query-aware self-attention mechanism is proposed to aggregate service information. Then, a graph pooling method with a coarsening strategy as the core is adopted to further extract service information, and the focus service is dynamically captured and read out at the graph level. Finally, the probability of the target service interacting with the user at the next moment is predicted.
[0008] The technical solution adopted by the present invention to solve its technical problem is:
[0009] A sequence-aware service recommendation method based on a twin-tower model, the method comprising the following steps:
[0010] Step 1: Create a service dataset, obtain service interaction data, and use the two-tower model to build a service network diagram;
[0011] Step 2: Based on the graph structure in the service network graph, a query-aware self-attention mechanism is designed to aggregate service embedding vectors and use a graph convolutional network to extract service features. The process is as follows:
[0012] Step (2.1) designs a query-aware self-attention mechanism in the graph convolutional network;
[0013] Step (2.2) adjusts the weight of the service embedding vector in information aggregation according to the user query and updates the embedding representation through graph convolution operation;
[0014] Step 3: Use graph pooling with graph coarsening as the core to further extract important service information;
[0015] Step 4: Capture the dynamically changing focus service and perform graph-level representation readout. Obtain the final output embedding based on the focus service representation and graph-level representation readout, and then obtain the probability of interaction between the target service and the user. The process is as follows:
[0016] Step (4.1) The focal service is a densely connected service in the service network diagram, representing the main needs of users;
[0017] Step (4.2) captures the user’s dynamically changing focus service under the multi-head self-attention mechanism;
[0018] Step (4.3) uses the average function to calculate the average node embedding of all service nodes after the forward calculation of the propagation layer, generates the graph-level representation of the service network graph G before coarsening, and assigns the result to The process uses the formula Indicates that the symbol Mean represents the average function;
[0019] Step (4.4) predicts the probability of the user interacting with the target service and makes recommendations.
[0020] Further, the process of step 1 is as follows:
[0021] Step (1.1) The dual-tower model is a deep learning framework whose basic idea is to learn two different data features from two towers respectively, and then measure the similarity between the two input data;
[0022] Step (1.2) creates a service dataset, crawls user information and API services from relevant websites, analyzes and organizes the collected results, and obtains a service dataset;
[0023] Step (1.3) sorts the interaction sequences in chronological order to form an interaction sequence set;
[0024] Step (1.4) constructs a service network diagram and converts the interaction sequence set into a service network diagram through the two-tower model.
[0025] Preferably, in step (1.2), the service data set includes the following information:
[0026] Step (1.2.1) User: The developer who calls the API service, using the symbol u i express;
[0027] Step (1.2.2) API service: an interface that allows communication and data exchange between different software applications. It is the recommended object in the service recommendation and is represented by the symbol a. i express;
[0028] Step (1.2.3) Interaction sequence: The API service called by the user at a timestamp constitutes an interaction sequence, which is represented by the symbol seq.
[0029] More preferably, the process of step (1.3) is:
[0030] Step (1.3.1) constructs the interaction sequence set, which is represented by symbol S;
[0031] In step (1.3.2), all interaction sequences are arranged in chronological order to obtain the interaction sequence set. Indicates that the symbol m * Represents the total number of interaction sequences.
[0032] More preferably, in step (1.4), the process of constructing the service network graph is:
[0033] Step (1.4.1) defines the service network graph, denoted by symbol G, the node set of G denoted by symbol V, the edge set of G denoted by E, and the adjacency matrix denoted by A;
[0034] Step (1.4.2) replaces a in step (1.2.2) i Convert to node v i ;
[0035] Step (1.4.3) inputs the API service nodes into the dual-tower model to calculate the similarity between services and construct a service network graph.
[0036] The process of step (1.4.3) is:
[0037] Step (1.4.3.1) uses one-hot encoding to convert any two API service nodes into an embedding vector h i and h j , the one-hot encoding is an encoding method that converts categorical variables into numerical format;
[0038] Step (1.4.3.2) encodes the description document and label information of the API service in the interaction sequence;
[0039] Step (1.4.3.3) fuses the API service embedding vector and the semantic vector to obtain a service vector containing semantic information The process uses the formula Indicates, symbols Represents the fusion function, which combines two features into a single representation using a weighted sum method, symbol θ i and the symbol ω i All are fusion function parameters;
[0040] Step (1.4.3.4) uses weighted cosine similarity to measure the similarity between two embedding vectors and assigns the result to sim i,j , the process uses the formula The symbol cos(·) represents the cosine similarity measurement method, the symbol w represents a learnable weight vector, and the symbol ⊙ represents the Hadamard product. Weighted cosine similarity is a method for measuring the similarity between two vectors. It adds the concept of weight on the basis of cosine similarity to better reflect the importance of different features.
[0041] Step (1.4.3.5) will be any two API service nodes v with similarity i and v j Connect an edge between them, using the symbol (v i ,e i,j ,v j ) indicates that a service network diagram is constructed based on this;
[0042] The process described (1.4.3.2) is:
[0043] Step (1.4.3.2.1) The description document of the API service is used to record the functions, features and interface information of the service;
[0044] Step (1.4.3.2.2) The service label is a short text used to identify the service function type;
[0045] Step (1.4.3.2.3) segment the description documents and tag information of any two API services and remove stop words;
[0046] Step (1.4.3.2.4) uses the BERT (Bidirectional Encoder Representations from Transformers) model to encode the description documents and label information of the two processed API services to obtain the semantic vector s iand s j ,BERT model is a natural language processing model;
[0047] Furthermore, the process of the query-aware self-attention mechanism in step (2.1) is as follows:
[0048] Step (2.1.1) The API service embedding vector of user i's query is represented by Indicates that the superscript Indicates that the current service vector is the user's query vector;
[0049] Step (2.1.2) User query service embedded in time order is represented by symbol Indicates that t * Represents the length of time;
[0050] Step (2.1.3) calculates the attention score of Q at different times and assigns the result to θ j , the process uses the formula Indicates that the symbol W q and W k is a trainable time parameter, Representatives will Transpose, the symbol d' represents the query representation dimension, For square root operation, Attention is a two-layer feedforward neural network with LeakyReLU (Leaky Rectified Linear Unit) as the activation function;
[0051] Step (2.1.4) calculates the attention weights in the API service node aggregation in a non-destructive way and assigns the result to β j , the process uses the formula Indicates, symbols W k ' and W v 'represents the learnable weight matrix, is the proportional factor to avoid the result of the inner product being too large, represents the source node, Represents the target node, softmax is an activation function, and the non-destructive method is to use it only as and The influence coefficient will not affect More efficient modeling is achieved by controlling the information source of the self-attention component.
[0052] The process of step (2.2) is:
[0053] Step (2.2.1) embeds the API service node into the matrix Input the l+1th layer, the symbol n represents the number of node embeddings, ∈ is a mathematical symbol that represents the relationship of belonging, represents a set of d-dimensional real vectors, where d is the embedding size of the node;
[0054] Step (2.2.2) calculates the service embedding representation of the l+1th layer and assigns the result to The process uses the formula Indicates, symbols Representative node v i The set of neighbor nodes, ∑ is a summation symbol, v k Represents v i A neighbor node of .
[0055] Furthermore, the process of step 3 is as follows:
[0056] Step (3.1) uses the global graph content attribute extraction technology 2GCont (Global Graph Content) and the cross-attention mechanism CAMe (Cross-Attention Mechanism) to perform graph coarsening. Graph coarsening is a technique used to reduce the size of a graph while preserving its overall structure.
[0057] Step (3.2) uses the service node embedding matrix before coarsening Generate the service cluster embedding of the coarsened graph and assign the result to This process is described by the formula Indicates that the symbol L represents the number of layers of the final graph convolution, the symbol m represents the number of service cluster embeddings, and the symbol M T Represents the transpose of the cross-attention mechanism M in step (3.1.2);
[0058] Step (3.3) uses the service node scores {γ1,γ2,...,γ n Generate the service clustering score of the coarsened graph and assign the result to The process uses the formula Indicates that the symbol M T Represents the transpose of the cross attention mechanism M in step (3.1.2), symbol γ i is the θ in step (2.1.3) i The service node v obtained by applying softmax i Importance score.
[0059] Preferably, in step (3.1), the graph coarsening process is as follows:
[0060] Step (3.1.1) calculates the global graph content matrix and assigns the result to C. This process is expressed as X represents the parameterized weight matrix;
[0061] Step (3.1.2) calculates the cross attention mechanism and assigns the result to M. The process is expressed as Indicates, symbols represents the trainable shared attention parameter, symbol represents the service node embedding of dimension N before coarsening, represents the service cluster embedding with dimension N' after coarsening, and [·||·] represents the concatenation operation;
[0062] Step (3.1.3) for M ij Normalize and assign the result to M. The process is expressed as Indicates that the symbol exp is the natural exponential operation, and the symbol M ig Represents all elements in the i-th row, and the symbol N' represents the number of columns in the i-th row of M;
[0063] The process of step (4.2) is:
[0064] Step (4.2.1) The multi-head self-attention mechanism is a variant of the self-attention mechanism, which can extract information from different subspaces at different positions;
[0065] Step (4.2.2) represents the cluster embedding matrix obtained in step (3.2) with the symbol H, that is, symbol Represents the i * Service cluster embedding;
[0066] Step (4.2.3) captures the dynamically changing focus service and assigns the result to The process uses the formula Indicates that the symbol h * Represents the total number of heads, the symbol || represents the splicing operation, and the symbol Represents from the i ** The embedding representation learned in each head is expressed in the formula Indicates that the symbol W O 、 and All of them are learnable parameters, and the attention mechanism ATTENTION(·) is implemented by scaling the dot product and the softmax function.
[0067] The process of step (4.4) is as follows:
[0068] Step (4.4.1) will and Splice and learn the embedding combination through the fully connected layer to get the final output embedding, and assign the result to The process uses the formula Indicates that the symbol Readout represents the readout function;
[0069] Step (4.4.2) will Perform a dot product operation with the target service embedding to obtain the probability of the user interacting with the API service, and assign the result to The process uses the formula express,
[0070] Step (4.4.3) constructs the cross entropy loss function training model, and assigns the loss function result to The process uses the formula Indicates that the symbol |V| represents the service dataset, and the symbol r n',t Represents the true label, when r n',t =1 means the user has interacted with the service, r n',t =0 means that the user has not interacted with the service. The symbol log represents the logarithmic operation. The cross entropy loss function is a commonly used loss function in classification problems, which is used to measure the difference between the model output and the true label.
[0071] The beneficial effects of the present invention are mainly manifested in:
[0072] 1. For massive API service data, the dual-tower model is used to learn service embedding expressions, fully explore the correlation between services, and build a service network graph;
[0073] 2. Design a query-aware self-attention mechanism in the graph convolutional network to avoid interference from useless information and effectively aggregate service embedding;
[0074] 3. Utilizing graph pooling operations centered on graph coarsening, we further capture high-level relationships between services. A multi-head self-attention mechanism captures dynamic changes in the focus service and performs a weighted readout of the pre-coarsening service network graph, effectively constraining the importance of each service node and improving the accuracy of service recommendations. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] Figure 1 A diagram illustrating the process of building a service network diagram based on the two-tower model.
[0076] Figure 2 This is an illustration of the hyperparameter experimental results obtained by the present invention on the experimental dataset. DETAILED DESCRIPTION
[0077] The present invention will be further described below with reference to the accompanying drawings.
[0078] Reference Figure 1 and Figure 2 ,A sequence-aware service recommendation method based on a dual-tower model, comprising the following steps:
[0079] Step 1: Create a service dataset, obtain service interaction data, and use the two-tower model to build a service network diagram. Figure 1 The preprocessing in _preprocessing refers to the removal of segmentation and stop words; the process is as follows:
[0080] Step (1.1) The dual-tower model is a deep learning framework whose basic idea is to learn two different data features from two towers respectively, and then measure the similarity between the two input data;
[0081] Step (1.2) creates a service dataset by crawling user information and API services from relevant online websites such as ProgrammableWeb and FastAPi, and analyzing and organizing the collected results to obtain a service dataset;
[0082] In step (1.2), the service data set includes the following information:
[0083] Step (1.2.1) User: The developer who calls the API service, using the symbol u i express;
[0084] Step (1.2.2) API service: an interface that allows communication and data exchange between different software applications. It is the recommended object in the service recommendation and is represented by the symbol a. i express.
[0085] Step (1.2.3) Interaction sequence: The API service called by the user at a timestamp constitutes an interaction sequence, represented by the symbol seq;
[0086] Step (1.3) sorts the interaction sequences in chronological order to form an interaction sequence set. The process is as follows:
[0087] Step (1.3.1) constructs the interaction sequence set, which is represented by symbol S;
[0088] In step (1.3.2), all interaction sequences are arranged in chronological order to obtain the interaction sequence set. Indicates that the symbol m * represents the total number of interaction sequences;
[0089] Step (1.4) constructs a service network diagram and converts the interaction sequence set into a service network diagram through the two-tower model;
[0090] In step (1.4), the process of constructing the service network diagram is as follows:
[0091] Step (1.4.1) defines the service network graph, denoted by symbol G, the node set of G denoted by symbol V, the edge set of G denoted by E, and the adjacency matrix denoted by A;
[0092] Step (1.4.2) replaces a in step (1.2.2) i Convert to node v i ;
[0093] Step (1.4.3) inputs the API service nodes into the dual-tower model to calculate the similarity between services and construct a service network diagram. The process is as follows:
[0094] Step (1.4.3.1) uses one-hot encoding to convert any two API service nodes into an embedding vector h i and h j , the one-hot encoding is an encoding method that converts categorical variables into numerical format;
[0095] Step (1.4.3.2) encodes the description document and tag information of the API service in the interaction sequence. The process is as follows:
[0096] Step (1.4.3.2.1) The description document of the API service is used to record the functions, features and interface information of the service;
[0097] Step (1.4.3.2.2) The service label is a short text used to identify the service function type;
[0098] Step (1.4.3.2.3) segment the description documents and tag information of any two API services and remove stop words;
[0099] Step (1.4.3.2.4) uses the BERT (Bidirectional Encoder Representations from Transformers) model to encode the description documents and label information of the two processed API services to obtain the semantic vector s i and s j ,BERT model is a natural language processing model;
[0100] Step (1.4.3.3) fuses the API service embedding vector and the semantic vector to obtain a service vector containing semantic information The process uses the formula Indicates, symbols Represents the fusion function, which combines two features into a single representation using a weighted sum method, symbol θ i and the symbol ω i All are fusion function parameters;
[0101] Step (1.4.3.4) uses weighted cosine similarity to measure the similarity between two embedding vectors and assigns the result to sim i,j, the process uses the formula The symbol cos(·) represents the cosine similarity measurement method, the symbol w represents a learnable weight vector, and the symbol ⊙ represents the Hadamard product. Weighted cosine similarity is a method for measuring the similarity between two vectors. It adds the concept of weight on the basis of cosine similarity to better reflect the importance of different features.
[0102] Step (1.4.3.5) will be any two API service nodes v with similarity i and v j Connect an edge between them, using the symbol (v i ,e i,j ,v j ) indicates that a service network diagram is constructed based on this;
[0103] Step 2: Based on the graph structure in the service network graph, a query-aware self-attention mechanism is designed to aggregate service embedding vectors and a graph convolutional network is used to extract service features. The process is as follows:
[0104] Step (2.1) designs a query-aware self-attention mechanism in the graph convolutional network. The process is as follows:
[0105] Step (2.1.1) The API service embedding vector of user i's query is represented by Indicates that the superscript q′ i′ Indicates that the current service vector is the user's query vector;
[0106] Step (2.1.2) User query service embedded in time order is represented by symbol Indicates that t * Represents the length of time;
[0107] Step (2.1.3) calculates the attention score of Q at different times and assigns the result to θ j , the process uses the formula Indicates that the symbol W q and W k is a trainable time parameter, Representatives will Transpose, the symbol d' represents the query representation dimension, For square root operation, Attention is a two-layer feedforward neural network with LeakyReLU (Leaky Rectified Linear Unit) as the activation function;
[0108] Step (2.1.4) calculates the attention weights in the API service node aggregation in a non-destructive way and assigns the result to β j , the process uses the formula Indicates, symbols W k ' and W v 'represents the learnable weight matrix, is the proportional factor to avoid the result of the inner product being too large, represents the source node, Represents the target node, softmax is an activation function, and the non-destructive method is to use it only as and The influence coefficient will not affect More efficient modeling is achieved by controlling the information source of the self-attention component;
[0109] Step (2.2) adjusts the weight of the service embedding vector in information aggregation according to the user query, and updates the embedding representation through graph convolution operation. The process is:
[0110] Step (2.2.1) embeds the API service node into the matrix Input the l+1th layer, the symbol n represents the number of node embeddings, ∈ is a mathematical symbol that represents the relationship of belonging, represents a set of d-dimensional real vectors, where d is the embedding size of the node;
[0111] Step (2.2.2) calculates the service embedding representation of the l+1th layer and assigns the result to The process uses the formula Indicates, symbols
[0112] Representative node v i The set of neighbor nodes, ∑ is a summation symbol, v k Represents v i A neighbor node of
[0113] Step 3: Use graph pooling with graph coarsening as the core to further extract important service information. The process is as follows:
[0114] Step (3.1) uses the global graph content attribute extraction technology 2GCont (Global Graph Content) and the cross-attention mechanism CAMe (Cross-Attention Mechanism) to perform graph coarsening. Graph coarsening is a technique used to reduce the size of a graph while preserving its overall structure. The process is as follows:
[0115] Step (3.1.1) calculates the global graph content matrix and assigns the result to C. This process is expressed as Indicates that the symbol X represents the parameterized weight matrix;
[0116] Step (3.1.2) calculates the cross attention mechanism and assigns the result to M. The process is expressed as Indicates that the symbol a T represents the trainable shared attention parameter, symbol represents the service node embedding of dimension N before coarsening, represents the service cluster embedding with dimension N' after coarsening, and [·||·] represents the concatenation operation;
[0117] Step (3.1.3) for M ij Normalize and assign the result to M. The process is expressed as Indicates that the symbol exp is the natural exponential operation, and the symbol M ig Represents all elements in the i-th row, and the symbol N' represents the number of columns in the i-th row of M;
[0118] Step (3.2) uses the service node embedding matrix before coarsening Generate the service cluster embedding of the coarsened graph and assign the result to This process is described by the formula Indicates that the symbol L represents the number of layers of the final graph convolution, the symbol m represents the number of service cluster embeddings, and the symbol M T Represents the transpose of the cross-attention mechanism M in step (3.1.2);
[0119] Step (3.3) uses the service node scores {γ1,γ2,...,γ n Generate the service clustering score of the coarsened graph and assign the result to The process uses the formula Indicates that the symbol M T Represents the transpose of the cross attention mechanism M in step (3.1.2), symbol γ i is the θ in step (2.1.3) i The service node v obtained by applying softmax i Importance score;
[0120] Step 4: Capture the dynamically changing focus service and perform graph-level representation readout. Obtain the final output embedding based on the focus service representation and graph-level representation readout, and then obtain the probability of the target service interacting with the user. The process is as follows:
[0121] Step (4.1) The focal service is a densely connected service in the service network diagram, representing the main needs of users;
[0122] Step (4.2) captures the user's dynamically changing focus service under the multi-head self-attention mechanism. The process is as follows:
[0123] Step (4.2.1) The multi-head self-attention mechanism is a variant of the self-attention mechanism, which can extract information from different subspaces at different positions;
[0124] Step (4.2.2) represents the cluster embedding matrix obtained in step (3.2) with the symbol H, that is, symbol Represents the i * Service cluster embedding;
[0125] Step (4.2.3) captures the dynamically changing focus service and assigns the result to The process uses the formula Indicates that the symbol h * Represents the total number of heads, the symbol || represents the splicing operation, and the symbol Represents from the i ** The embedding representation learned in each head is expressed in the formula Indicates that the symbol W O 、 and All of them are learnable parameters, and the attention mechanism ATTENTION(·) is implemented by scaling the dot product and the softmax function.
[0126] Step (4.3) uses the average function to calculate the average node embedding of all service nodes after the forward calculation of the propagation layer, generates the graph-level representation of the service network graph G before coarsening, and assigns the result to The process uses the formula Indicates that the symbol Mean represents the average function;
[0127] Step (4.4) predicts the probability of the user interacting with the target service and makes recommendations. The process is as follows:
[0128] Step (4.4.1) will and Splice and learn the embedding combination through the fully connected layer to get the final output embedding, and assign the result to The process uses the formula Indicates that the symbol Readout represents the readout function;
[0129] Step (4.4.2) will Perform a dot product operation with the target service embedding to obtain the probability of the user interacting with the API service, and assign the result to The process uses the formula express,
[0130] Step (4.4.3) constructs the cross entropy loss function training model, and assigns the loss function result to The process uses the formula Indicates that the symbol |V| represents the service dataset, and the symbol r n',t Represents the true label, when r n',t =1 means the user has interacted with the service, rn',t =0 means that the user has not interacted with the service. The symbol log represents the logarithmic operation. The cross entropy loss function is a commonly used loss function in classification problems, which is used to measure the difference between the model output and the true label.
[0131] This embodiment analyzes the actual effect of the invention based on specific service data, and the implementation plan is as follows:
[0132] Step 1: Data from the Programmable Web website from 2019 to 2020 is selected as the experimental dataset. The specific information is shown in Table 1. This dataset contains 3102 users, 11930 API service data, and 6206 interaction sequences.
[0133]
[0134] Table 1
[0135] Step 2: Test the service recommendation performance of the API service node under different embedding dimensions.
[0136] Step 3: Use HR indicators to evaluate the accuracy of service recommendation results. The calculation method is as follows:
[0137]
[0138] Among them, HR represents the accuracy of the recommendation result, hit(v i ) represents the service recommendation result, and N represents the actual interaction data between users and API services. The larger the HR metric value, the higher the recommendation accuracy. When the service recommendation list length is 10, the HR metric can be recorded as HR@10.
[0139] Step 4: Use the NDCG indicator to evaluate the relevance of the service recommendation results. The calculation method is as follows:
[0140]
[0141] Where NDCG represents the relevance of the recommendation results, DCG represents the weighted sum of the relevance scores in the recommendation results, B represents the length of the recommendation list, r(b) represents the relevance score of the bth API service, and IDCG represents the ideal DCG. A larger NDCG value indicates higher-quality ranking results and greater relevance to user development needs. When the service recommendation list length is 10, the NDCG metric can be recorded as NDCG@10.
[0142] Step 5: Use 70% of the experimental data in the dataset as the training set and the remaining 30% as the test set. Figure 2 shown.
[0143] according to Figure 2 The results show that the recommendation performance of the present invention improves with the increase of embedding dimension. When the embedding dimension is 64, the performance reaches the best, and the HR@10 index and NDCG@10 index reach 0.5027 and 0.4821 respectively. After that, the recommendation performance gradually decreases as the embedding dimension increases. Analyzing the reasons, a lower embedding dimension may lead to information loss, and a higher embedding dimension can capture more information and make the model have better expressive ability, but too high an embedding dimension may cause the model to have overfitting problems. In summary, it can be considered that the present invention has better recommendation accuracy and relevance when the embedding dimension is 64.
[0144] The embodiments of this specification are merely examples of implementations of the invention and are provided for illustrative purposes only. The scope of protection of the present invention should not be considered limited to the specific embodiments described in these embodiments. The scope of protection of the present invention also extends to equivalent technical means that can be conceived by a person of ordinary skill in the art based on the invention.
Claims
1. A sequence-aware service recommendation method based on a twin-tower model, characterized in that: The method comprises the following steps: Step 1: Create a service dataset, obtain service interaction data, and use the two-tower model to build a service network diagram; Step 2: Based on the graph structure in the service network graph, a query-aware self-attention mechanism is designed to aggregate service embedding vectors and use a graph convolutional network to extract service features. The process is as follows: Step (2.1) Design a query-aware self-attention mechanism in the graph convolutional network; Step (2.2) adjusts the weight of the service embedding vector in information aggregation according to the user query and updates the embedding representation through graph convolution operations; Step 3: Use graph pooling with graph coarsening as the core to further extract important service information. The process is as follows: Step (3.1) uses the global graph content attribute extraction technology 2GCont and the cross attention mechanism CAMe to perform graph coarsening. The graph coarsening process is as follows: Step (3.1.1) calculates the global graph content matrix and assigns the result to , the process uses the formula Indicates, symbols represents the parameterized weight matrix; Step (3.1.2) calculates the cross attention mechanism and assigns the result to , the process uses the formula Indicates, symbols represents the trainable shared attention parameter, symbol Represents the dimension before coarsening The service node is embedded, Represents the dimension after coarsening Service clustering embedding, Represents a splicing operation; Step (3.1.3) Normalize and assign the result to , the process uses the formula Indicates, symbols is the natural exponential operation, the symbol Representative All elements of the row, symbols represent No. The number of columns in the row; Step (3.2) uses the service node embedding matrix before coarsening Generate the service cluster embedding of the coarsened graph and assign the result to , the process is given by the formula Indicates, symbols Represents the number of layers of the final graph convolution, symbol represents the number of service cluster embeddings, symbol Cross-attention mechanism in the representative step (3.1.2) The transpose of Step (3.3) uses the service node score before coarsening Generate the service clustering score of the coarsened graph and assign the result to , the process uses the formula Indicates, symbols Cross-attention mechanism in the representative step (3.1.2) The transpose of is application The service node obtained The importance score of Compute embedding representations for time-ordered user query services Attention scores at different times; Step 4: Capture the dynamically changing focus service and perform graph-level representation readout. Obtain the final output embedding based on the focus service representation and graph-level representation readout, and then obtain the probability of interaction between the target service and the user. The process is as follows: Step (4.1) The focal service is a densely connected service in the service network diagram, representing the main needs of users; Step (4.2) captures the user’s dynamically changing focus services under the multi-head self-attention mechanism; Step (4.3) uses the average function to calculate the average node embedding of all service nodes after the forward calculation of the propagation layer to generate the service network graph before coarsening. The graph level representation of ; Step (4.4) predicts the probability of the user interacting with the target service and makes recommendations.
2. The sequence-aware service recommendation method based on the dual-tower model according to claim 1, characterized in that: The process of step 1 is as follows: Step (1.1) The dual-tower model is a deep learning framework whose basic idea is to learn two different data features from two towers respectively, and then measure the similarity between the two input data; Step (1.2) creates a service dataset, crawls user information and API services from relevant websites, analyzes and organizes the collected results, and obtains a service dataset; Step (1.3) sorts the interaction sequences in chronological order to form an interaction sequence set; Step (1.4) constructs a service network diagram and converts the interaction sequence set into a service network diagram through the two-tower model.
3. The sequence-aware service recommendation method based on the dual-tower model according to claim 2, characterized in that: In step (1.2), the service dataset includes the following information: Step (1.2.1) User: Developer who calls API service, using symbol express; Step (1.2.2) API service: An interface that allows communication and data exchange between different software applications, a recommended object in service recommendation, symbolized by express; Step (1.2.3) Interaction sequence: The API service called by the user at a timestamp constitutes an interaction sequence, which is symbolized by express.
4. The sequence-aware service recommendation method based on the dual-tower model according to claim 2, characterized in that: The process of step (1.3) is: Step (1.3.1) constructs the set of interaction sequences, using the symbol express; In step (1.3.2), all interaction sequences are arranged in chronological order to obtain the interaction sequence set. Indicates, symbols represents the total number of interaction sequences; In step (1.4), the process of constructing the service network diagram is as follows: Step (1.4.1) defines the service network diagram, using the symbol express, The node set of express, The edge set of The adjacency matrix is represented by express; Step (1.4.2) replaces the step (1.2.2) Convert to Node ; Step (1.4.3) inputs the API service nodes into the dual-tower model to calculate the similarity between services and construct a service network graph.
5. The sequence-aware service recommendation method based on the dual-tower model according to claim 4, characterized in that: The process of step (1.4.3) is: Step (1.4.3.1) uses one-hot encoding to convert any two API service nodes into embedding vectors and , the one-hot encoding is an encoding method that converts categorical variables into numerical format; Step (1.4.3.2) encodes the description document and label information of the API service in the interaction sequence; Step (1.4.3.3) fuses the API service embedding vector and the semantic vector to obtain a service vector containing semantic information. , the process uses the formula Indicates, symbols Represents the fusion function, which combines two features into a single representation using a weighted sum method, symbol and symbol All are fusion function parameters; Step (1.4.3.4) uses weighted cosine similarity to measure the similarity between two embedding vectors and assigns the result to , the process uses the formula Indicates, symbols Represents the use of cosine similarity measurement method, symbol Represents a learnable weight vector, symbol stands for Hadamard product. Weighted cosine similarity is a method to measure the similarity between two vectors. It adds the concept of weight on the basis of cosine similarity to better reflect the importance of different features. Step (1.4.3.5) will have any two API service nodes with similarity and Connect an edge between them, using the symbol Representation, which is used to build a service network diagram.
6. The sequence-aware service recommendation method based on the dual-tower model according to claim 5, characterized in that: The process described (1.4.3.2) is: Step (1.4.3.2.1) The description document of the API service is used to record the functions, features and interface information of the service; Step (1.4.3.2.2) The service label is a short text that identifies the service function type; Step (1.4.3.2.3) segment the description documents and tag information of any two API services and remove stop words; Step (1.4.3.2.4) uses the BERT model to encode the description documents and label information of the two processed API services to obtain semantic vectors and , the BERT model is a natural language processing model.
7. The sequence-aware service recommendation method based on the dual-tower model according to any one of claims 1 to 6, characterized in that: The process of the query-aware self-attention mechanism in step (2.1) is as follows: Step (2.1.1) User The API service embedding vector of the query is symbolized Indicates that the superscript Indicates that the current service vector is the user's query vector; Step (2.1.2) User query service embedding representation by time order is represented by symbol express, Represents the length of time; Step (2.1.3) Calculation Attention scores at different times, assign the results to , the process uses the formula Indicates, symbols and is a trainable time parameter, Representatives will Transpose, symbol Represents the query representation dimension, is the square root operation, It is a A two-layer feedforward neural network with activation function; Step (2.1.4) calculates the attention weights in the API service node aggregation in a non-destructive way and assigns the results to , the process uses the formula Indicates, symbols 、 and represents the learnable weight matrix, is the proportional factor to avoid the result of the inner product being too large, represents the source node, represents the target node, Is an activation function, non-destructive means only as and The influence coefficient will not affect , more efficient modeling is achieved by controlling the information source of the self-attention component; The process of step (2.2) is: Step (2.2.1) embeds the API service node into the matrix Enter +1 layer, symbol represents the number of node embeddings, is a mathematical symbol that indicates a relationship of belonging, Representatives include The set of dimensional real vectors, is the embedding size of the node; Step (2.2.2) calculates The service embedding representation of the layer is assigned to , the process uses the formula Indicates, symbols Representative Node The set of neighbor nodes, ∑ is a summation symbol, represent A neighbor node of .
8. The sequence-aware service recommendation method based on the dual-tower model according to any one of claims 2 to 6, characterized in that: The process of step (4.2) is: Step (4.2.1) The multi-head self-attention mechanism is a variant of the self-attention mechanism, which can extract information from different subspaces at different positions; Step (4.2.2) embeds the clustering matrix obtained in step (3.2) with the symbol Indicates that ,symbol Representative Service cluster embedding; Step (4.2.3) captures the dynamically changing focus service and assigns the result to , the process uses the formula Indicates, symbols Represents the total number of long positions, symbol Represents the splicing operation, symbol Representatives from The embedding representation learned in each head is expressed in the formula Indicates, symbols 、 、 and All are learnable parameters, attention mechanism By scaling the dot product and Function implementation; The process of step (4.4) is as follows: Step (4.4.1) will and Splice and learn the embedding combination through the fully connected layer to get the final output embedding, and assign the result to , the process uses the formula Indicates, symbols represents the readout function; Step (4.4.2) will Perform dot product operation with the target service embedding to obtain the probability of the user interacting with the API service, and assign the result to , the process uses the formula express; Step (4.4.3) constructs the cross entropy loss function training model and assigns the loss function result to , the process uses the formula Indicates, symbols Represents the service dataset, symbol Represents the true label, when Indicates that the user has interacted with the service. It indicates that the user has not interacted with the service, and the symbol log represents logarithm operation.
Citation Information
Patent Citations
Online group recommendation method and system based on multi-scale contrast learning double-tower model
CN118964748A
Cloud-native application programming interface (API) recommendation method fusing data augmentation and contrastive learning
US20250013514A1