Knowledge-driven explainability service recommendation method based on large language model
By constructing a collaborative knowledge graph and utilizing a large language model and a multi-head cross-attention module to generate personalized recommendation explanations, the problems of insufficient deep semantic capture and interpretability in existing technologies are solved, achieving high accuracy and improved interpretability of service recommendations.
Patent Information
- Application Number
- CN202611552446.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-09
- Publication Date
- 2026-11-06
AI Technical Summary
Existing knowledge graph-based service recommendation methods are insufficient in capturing deep semantic fine-grained relationships and fine-grained key semantic information in user interactions, and the recommendation results lack interpretability, leading to insufficient user trust.
We construct a collaborative knowledge graph for service recommendation scenarios, transform structured triples into natural language descriptions through a large language model and prompt templates, and generate personalized recommendation explanations by combining a multi-head cross-attention module and a Transformer decoder, thereby capturing deep semantics of services and generating interpretable recommendation decisions.
It improves recommendation accuracy and explanation quality, provides personalized explanations that are highly consistent with recommendation decisions, and makes up for the shortcomings of traditional methods in fine-grained semantic logic modeling and interpretability.
Smart Images

Figure CN123048860A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of service computing and intelligent recommendation technology, and in particular relates to a knowledge-driven interpretable service recommendation method based on a large language model. Background Technology
[0002] The rapid development of service-oriented computing has driven Web APIs to become a core building block of modern application development in a standardized and reusable form. Hybrid technologies, by integrating multiple complementary Web APIs, can quickly match customized business needs, significantly reducing the barriers to application development and shortening the development cycle. Faced with a massive number of diverse Web API services, service recommendation technology has become a core supporting technology to help developers quickly select suitable APIs and improve development efficiency.
[0003] In recent years, knowledge graphs, with their ability to structurally model service entities, attributes, and relationships, have been widely applied in the field of service recommendation, effectively alleviating the problem of sparsity in service interaction data. For example, Chinese invention patent application publication number CN121166190A discloses an API intelligent recommendation method and system based on semantic knowledge graphs. This method combines semantic similarity understanding functional requirements with user behavior analysis to improve recommendation accuracy. Simultaneously, it introduces a service popularity adjustment mechanism to reduce development complexity and improve service reusability and development efficiency. However, existing knowledge graph-based service recommendation methods still have two major limitations: First, traditional knowledge embedding methods have inherent shortcomings in capturing different fine-grained semantic relationships and modeling complex semantic logic, easily losing fine-grained key semantic information in service-user interactions, thus limiting the model's ability to reason and generalize based on deep semantics. Second, from the user's perspective, the recommendation results of existing methods lack intuitive semantic representations corresponding to the decision-making logic, making it difficult to effectively trace and understand the reasoning chain behind the recommendation decisions, resulting in insufficient interpretability and user trust in the recommendation system. For example, Chinese invention patent application publication number CN119474540A discloses a knowledge-guided trusted API recommendation method based on a large language model.
[0004] Large language models, leveraging their powerful semantic understanding, logical reasoning, and natural language generation capabilities acquired through pre-training on massive corpora, can deeply analyze textual information and relational semantics within knowledge graphs. This enriches the representation of service attribute information, transforms unstructured semantic content into high-quality vector embeddings, and accurately captures complex semantic relationships between services, compensating for the semantic information lost in traditional ID-based representation methods. Simultaneously, based on structured knowledge and prompt templates, they can generate fluent, coherent, and information-rich personalized natural language explanations, fundamentally enhancing the interpretability and transparency of recommendation systems. For example, Chinese invention patent application publication number CN120873294A discloses a personalized intelligent recommendation method and system based on large language models. While this method improves interpretability and enhances the accuracy and transparency of recommendations, it does not incorporate service knowledge graphs for structured semantic modeling. It only achieves multi-source information fusion through simple vector concatenation, failing to bridge the semantic gap between ID / graph structure embedding and text embedding. Furthermore, the recommendation and explanation generation tasks are completely separate, making it difficult to achieve synergistic improvement between the two. Summary of the Invention
[0005] To overcome the shortcomings of existing technologies, this invention proposes a knowledge-driven interpretable service recommendation method based on a large language model, which fully captures the deep semantics of services and generates interpretable recommendation decisions, balancing recommendation accuracy and interpretation quality.
[0006] The technical solution adopted by this invention to solve its technical problem is: A knowledge-driven, interpretable service recommendation method based on a large language model is proposed. First, a collaborative knowledge graph of the service recommendation scenario is constructed, and service-centric and user-centric subgraphs are extracted. Using a large language model and prompt templates, structured triples are transformed into interpretable natural language descriptions, which are then mapped to service relationship embeddings and interpretable text embeddings through a pre-trained text embedding model. Next, the service description semantics enhanced by the large language model are used as the initial embedding for graph encoding. Collaborative encoding and relationship-aware encoding are implemented on the user-service interaction graph and service knowledge graph, respectively, learning user and service representations that consider both collaborative signals and knowledge semantics, and predicting interaction probabilities. Then, multi-source heterogeneous embeddings are fed into a multi-head cross-attention module to complete cross-feature space interaction, and concatenated to construct a complete prompt sequence for interpretation generation. Finally, a pre-trained Transformer decoder is used to generate initial recommendation explanations word-by-word, which are then optimized a second time by the large language model to obtain personalized recommendation explanations that match the recommendation decision.
[0007] Furthermore, the method includes the following steps: The first step is to enhance the semantic understanding and embedding generation of the knowledge graph based on the big language model: the service knowledge graph triples constructed in the service recommendation scenario and the user's historical interaction service data are input into the big language model. After semantic parsing and encoder mapping guided by customized prompt templates, the service relationship embedding, user preference embedding and interpretable text embedding that integrate the deep semantic association of services and the user's personalized preferences are extracted. The second step is graph structure encoding based on semantic enhancement of the large language model: the service description and service relationship are embedded with semantic enhancement of the large language model, and processed by user-service interaction graph collaboration encoding and service knowledge graph relationship perception encoding to obtain the final user representation and the final service representation that integrates interaction collaboration signals and global semantic association. The third step is text domain cross-aware processing based on multi-head cross-attention: inputting multi-source heterogeneous ID embedding, graph structure embedding and interpretable text embedding into the multi-head cross-attention module, completing deep fusion through semantic interaction across feature spaces, and concatenating the full feature vectors to obtain a complete prompt sequence for interpretation generation; The fourth step is personalized recommendation explanation generation and optimization: the generated prompt sequence is subjected to autoregressive generation and semantic optimization of personalized recommendation explanation, and the optimal recommendation explanation is obtained by generating a large language model through the explanation.
[0008] Furthermore, the process of the first step is as follows: Step (1.1) Construct the knowledge graph and core subgraph for the service recommendation scenario; We construct a service knowledge graph for the service recommendation domain. The knowledge graph uses semantic relationship triples, which consist of three elements: head entity, semantic relationship, and tail entity, as the basic unit. Among them, the service entity is the Web API service to be recommended in the service recommendation scenario and is the core entity object of the knowledge graph. The attribute entity is the feature description entity of the service entity's inherent attributes such as functional characteristics, technical parameters, belonging subject, category label, applicable scenario, calling constraints, version information, and dependency relationship. The association entity is the auxiliary entity that is attached to the attribute entity and is used to expand the deeper semantics of the service. The semantic relationship is the general term for the logical relationship between all entities and the relation part of the knowledge graph triple, which includes two types of sub-relationships: attribute relationship and association relationship. A user-service interaction graph is constructed, with user entities and service entities as two independent types of nodes. When a user and service have historical interactions, connecting edges are established between the corresponding nodes. The user entity represents a real user or a group of users. The user-service interaction graph is then integrated with a service knowledge graph to obtain a unified collaborative knowledge graph representing users, services, attribute entities, and various relationships. For each service, a two-hop local subgraph, namely the service central subgraph, is extracted from the collaborative knowledge graph. This subgraph centers on the service and contains service entities, attribute entities, and related entities derived from the attribute entities. It includes first-order attribute triples and randomly sampled second-order relation triples. In the first-order attribute triples, the head entity is the service entity, the semantic association is the attribute relation, and the tail entity is the attribute entity. In the second-order relation triples, the head entity is the attribute entity, the semantic association is the association relation, and the tail entity is the related entity.
[0009] The first step also includes: Step (1.2) concatenates the first-order attribute triples obtained in step (1.1) into the base text. Using a predefined fixed sentence mapping template, the second-order relation triples are transformed into coherent natural language statements. Combined with prompts that enhance the semantics of service relationships, a complete prompt sequence is formed. This sequence is then input into a pre-trained large language model to parse the deep semantic associations of the services, outputting a semantic description of the service relationships. This description is then mapped into service relationship embeddings by the large language model encoder. ; Step (1.3) in the collaborative knowledge graph This approach focuses on the target user, extracting all services that generated their historical interactions to form a user interaction service set. For each service, a set of first-order attribute triples from the knowledge graph is extracted. The user interaction service set and the corresponding first-order attribute triples for each service constitute a user-centric subgraph. The first-order attribute triples are concatenated into basic text, and the names of all historical interaction services are linked with their corresponding texts to obtain a user subgraph information description. This is combined with prompts that enhance the semantics of user preferences, input into a large language model, and latent preferences are inferred based on the user's historical interactions to generate interpretable user preference description text. The large language model encoder then decomposes the user preference description text into a semantic sub-word token sequence and maps it to a token embedding matrix. Max pooling is performed on this matrix to extract the global maximum feature, forming a fixed-dimensional interpretable text embedding. .
[0010] Furthermore, the second step is as follows: Step (2.1) enhances the semantics of the original service description document by driving the large language model with prompts that enhance the semantics of service relationships, resulting in a semantically enhanced service description document. This document is then mapped to a service semantic embedding by the large language model encoder, and projected onto the same dimensional space as the service ID embedding through a linear transformation layer, resulting in a dimensionally aligned service description embedding. The linear transformation layer adopts a parameter-sharing design and simultaneously serves the dimension alignment of the service relationship embedding in step (2.3) to unify the semantic space; Preferably, the second step further includes: Step (2.2) embeds the user ID For initial user embedding, service description embedding is aligned to dimensions. For the initial service embedding, for each user, the embeddings of all neighboring services at the previous layer are symmetrically normalized and weighted to obtain the embedding of the user at the current propagation layer. For each service, the embeddings of all neighboring users at the previous layer are symmetrically normalized and weighted to obtain the embedding of the service at the current propagation layer. This propagation operation is repeated up to layer L. The embeddings of each layer are summed and averaged to form the final user representation that takes into account both interaction and cooperation signals and service semantic information. With service representation ; Step (2.3) embeds the service relationship obtained in step (1.2). Perform the parameter-sharing linear transformation described in step (2.1) to obtain the dimension-aligned relation embedding. Through a relation-based attention mechanism, a query vector is constructed from the head entity embedding. The relation embedding and tail entity embedding are then multiplied element-wise to obtain a fusion vector, which is used to construct a key vector. The original attention score of the head entity for each neighborhood triplet is calculated. The attention weights are obtained by normalizing the scores of all neighborhood triplets for the same head entity. Dimensionally aligned relation embeddings are then used. The fused semantic vector is obtained by element-wise multiplying the embedding of the tail entity with the embedding of the previous layer. The fused semantic vector of each neighborhood triple is then weighted and summed according to the attention weight, and then normalized by the total number of neighborhood triples to obtain the updated embedding of the head entity. The above aggregation process is repeated layer by layer up to layer g. The embeddings of the service entities in the knowledge graph encoding from layer 0 to layer g are summed element-wise to obtain the service knowledge graph representation. This representation is then concatenated with the service representation obtained in step (2.2) to obtain the final service representation. and through end-user representation With the final representation of the service The inner product predicts the probability of user-service interaction.
[0011] The process of the third step is as follows: Step (3.1) transforms the end-user representation obtained in step (2.2) into a single representation. The final service representation obtained in step (2.3) Embedded along with user ID Embedded with Service ID The interpretable text obtained in step (1.3) is embedded as query embeddings. Simultaneously serving as both key and value embeddings, multi-head cross-attention computation is performed. Each attention head performs a linear transformation on the query, key, and value embeddings using a head-specific weight matrix. The similarity matrix between the query and key is normalized to attention weights after being scaled by the square root of the vector dimension. The value embeddings are then weighted and summed using these attention weights to obtain the head's output. The outputs of all attention heads are concatenated along the vector dimension and linearly projected to obtain the user ID embedding, service ID embedding, final user representation, and final service representation, which are then compared with interpretable text embeddings. Four cross vectors for cross-fusion; Step (3.2) embeds the user ID Service ID embedding and its cross-vectors with interpretable text embeddings, end-user representation Service final representation and its cross vector with interpretable text embedding, along with interpretable text embedding By concatenating them in sequence, a complete prompt sequence for the input interpretation generation module is formed. .
[0012] The process of the fourth step is as follows: Step (4.1) involves using the prompt sequence obtained in step (3.2). Positional encoding is added, and the input is given to a pre-trained Transformer decoder to obtain an output encoded sequence. An autoregressive approach is used to generate explanatory text word by word. At each step, the generation probability of each candidate word is calculated based on the encoded sequence and all previously generated words. The word with the highest probability is selected as the generation result for the current position. The process stops when a text terminator is generated or the preset maximum text length is reached, thus obtaining the initial recommended explanation. ; Step (4.2) uses an interpretable recommendation-specific prompt template to interpret the initial recommendation obtained in step (4.1). Integrating user preference information and service feature information into an optimized prompt sequence, the input explanation generates a large language model. The initial explanation is then semantically optimized, logically completed, and personalized enhanced to obtain the final personalized recommendation explanation. .
[0013] The beneficial effects of this invention are mainly reflected in: 1. Through semantic parsing of a large language model guided by prompt templates, the structured triples in the service-centric subgraph and the user-centric subgraph are transformed into interpretable natural language descriptions. This not only uncovers the deep semantic relationships between services but also characterizes users' personalized preferences, making up for the shortcomings of traditional knowledge embedding methods in modeling fine-grained semantic logic and providing a unified semantic foundation for recommendation and explanation. 2. By using service description embeddings enhanced and aligned by a large language model as the initial embedding for graph encoding, interactive collaboration signals and knowledge semantic associations are captured simultaneously during message propagation, alleviating the semantic loss problem of ID-based representation methods and improving the semantic richness of node representations and recommendation accuracy. 3. Introducing a multi-head cross-attention mechanism allows ID embedding, graph structure embedding, and interpretable text embedding to interact deeply in the feature space, bridging the semantic gap between multi-source heterogeneous embeddings, and enabling interpretation generation to be based on both collaborative signals and deep semantics, resulting in a high degree of matching between the interpretation text and recommendation decisions. 4. The generation method adopts a cascaded approach of autoregressive generation using a Transformer decoder and secondary optimization using a large language model. This ensures the smooth and coherent flow of the explanatory text, corrects semantic biases in the initial explanation, and completes the reasoning logic, thereby achieving a synergistic improvement in recommendation accuracy and interpretability. Attached Figure Description
[0014] Figure 1 This is an overall framework diagram of the large language model LLM-KDESR method in this invention.
[0015] Figure 2 These are the ablation experimental results of the LLM-KDESR method in this invention, wherein (a) shows the experimental results of the interpretability evaluation indicators FMR, FCR and DIV, (b) shows the experimental results of the text quality evaluation indicators USR, BLEU-4 and BLEU-1, (c) shows the experimental results of ROUGE-1 precision, recall and F1 value, and (d) shows the experimental results of ROUGE-2 precision, recall and F1 value.
[0016] Figure 3 The hyperparameters in this invention The experimental results are shown in (a) for FMR, FCR, USR, BLEU-1, ROUGE-1 precision and ROUGE-1 recall under different numbers of convolutional layers, and (b) for the recommended performance metrics HR@10 and NDCG@10 under different numbers of convolutional layers. Detailed Implementation
[0017] The present invention will now be further described with reference to the accompanying drawings.
[0018] Reference Figure 1The overall architecture of the proposed method (a knowledge-driven interpretability service recommendation method based on a large language model, LLM-KDESR) comprises four core components: an LLM-enhanced knowledge graph understanding module, an LLM-enhanced semantic graph encoding module, a text domain cross-sensing module, and a personalized interpretation generation module. The complete implementation process of this invention is as follows: First, a service knowledge graph and a collaboration knowledge graph are constructed, and service-centric subgraphs and user-centric subgraphs are extracted respectively. These are then input into a large language model to generate semantic descriptions of service relationships and user preferences. After mapping by an encoder, service relationship embeddings, user preference embeddings, and interpretable text embeddings are obtained. Next, the semantic representation of the original service description is enhanced and dimension alignment is completed using a large language model. The user-service interaction graph and the service knowledge graph are input respectively for dual-graph encoding to generate the final user representation and the final service representation that integrates interaction collaboration signals and global semantic associations. The recommendation prediction score is then calculated. Subsequently, the multi-source heterogeneous ID embeddings, graph structure embeddings, and interpretable text embeddings are input into a multi-head cross-attention module to complete deep semantic interaction across feature spaces and splice them to generate a complete prompt sequence for interpretation generation. Finally, the prompt sequence is input into a pre-trained Transformer decoder to generate an initial interpretation, which is then optimized a second time by the large language model to obtain the final personalized recommendation interpretation.
[0019] The knowledge-driven interpretability service recommendation method based on a large language model in this embodiment includes the following steps: Step 1: Knowledge graph semantic understanding and embedding generation based on large language model enhancement: The service knowledge graph triples constructed in the service recommendation scenario and the user's historical interaction service data are input into the large language model. After semantic parsing and encoder mapping processing guided by customized prompt templates, the service relationship embedding, user preference embedding and interpretable text embedding that integrate deep semantic association of services and user personalized preferences are extracted. The first step of this embodiment is as follows: Step (1.1) Construct the knowledge graph and core subgraph for the service recommendation scenario, as follows: Step (1.1.1) first constructs a service knowledge graph for the service recommendation domain, which includes service entities, attribute entities, and semantic relationship triples between service entities and attribute entities, and between attribute entities themselves. It consists of three elements: head entity, semantic relationship, and tail entity. Then, a user-service interaction graph is constructed. This graph uses user entities and service entities as two independent types of nodes, and establishes connecting edges between corresponding nodes when a user and a service have historical interactions. Finally, the user-service interaction graph is integrated with the service knowledge graph to obtain a collaborative knowledge graph. It is a global knowledge structure that uniformly represents users, services, attribute entities, and various relationships.
[0020] Among them, the user entity is a node representing a real user or user group. The service entity is the Web API service subject to be recommended; the attribute entity is a descriptive entity of the service's inherent attributes such as functional characteristics, technical parameters, owner, category tags, applicable scenarios, calling constraints, version information, and dependencies; the semantic relationship is divided into attribute relationship (the direct ownership relationship between the service entity and the attribute entity) and association relationship (the semantic extension relationship between the attribute entity and the associated entity).
[0021] Step (1.1.2) For each service s, extract a two-hop local subgraph centered on s from the collaborative knowledge graph, containing service entities, attribute entities, and associated entities extended from the attribute entities, to obtain the service central subgraph, which contains the first-order attribute triples of the service. Second-order relation triples with random sampling .
[0022] ; ; In this structure, the first-order attribute triple has a head entity `s` representing the service entity, a semantic association `r` representing the attribute relation, and a tail entity `e` representing the attribute entity. The second-order relation triple has a head entity `e` representing the attribute entity, a semantic association `r` representing the association relation, and a tail entity `k` representing the association entity. Association entities are auxiliary entities in the service knowledge graph used to expand the deeper semantics of services; they exist in relation to attribute entities. Step (1.2) involves semantic understanding and embedding generation of service relationships based on a large language model, as follows: Step (1.2.1) involves taking the first-order attribute triples from the service center subgraph obtained in step (1.1.2). splicing as the basic text By using a predefined fixed sentence pattern mapping template, second-order relation triples are mapped... Transform into coherent natural language sentences Combined with prompts that enhance the semantics of service relationships Construct a complete prompt sequence for service relationship semantic understanding, input it into a pre-trained large language model, guide the model to parse the deep semantic associations of services, and output a semantic description text of service relationships. ; This process is defined by the following formula: ; The prompt word template for generating service relationship semantic descriptions in this invention adopts a structured hierarchical design, divided into three fixed modules from top to bottom: The system instruction module is fixed at "Assume you are a service recommendation expert...". Its function is to clarify the role and output requirements of the large language model and guide the model to focus on the core semantic features and related information of the service. First-order knowledge triple module: Used to fill in the first-order attribute triples obtained in step (1.1.2) and concatenate them into the base text. Each first-order attribute triple is in the format "(service entity, attribute relationship, attribute entity)", providing the direct attribute information of the service. The second-order knowledge extension module is used to fill in the natural language statement Dr′ after the transformation of the second-order relation triplet obtained in step (1.1.2), in the format "[attribute entity] also developed...;services with the similar tags also include...;services with similar functionality also include:..", providing deep relational semantic information of the services provided.
[0023] Step (1.2.2) uses a pre-trained large language model encoder to process the service relationship semantic description text obtained in step (1.2.1). The service relationship embedding is converted into a continuous vector representation to obtain the enhanced service relationship embedding of the large language model. The formula for this process is: ; Where P represents the large language model encoder. In this embodiment, OpenAI pre-trained text-embedding-3-large is used as the text embedding encoder.
[0024] Step (1.3) involves user preference semantic understanding and embedding generation based on a large language model, as follows: Step (1.3.1) in the collaborative knowledge graph In this process, the target user is the core, and all services that the user has historically interacted with are extracted to form a set of user interaction services. For each service Extract the set of first-order triples from its knowledge graph, denoted as The local knowledge subgraph, centered on the target user and consisting of the set of user interaction services and the set of first-order triples corresponding to each service, is designated as the user-centric subgraph. The first-order triples within this subgraph are then... splicing as the basic text Then concatenate the names and corresponding text of all user history interaction services. User subgraph information description The formula is as follows: ; in, It represents a serial operation. Indicates service s The name; Step (1.3.2) describes the user subgraph information obtained in step (1.3.1). Combined with prompt word templates that enhance user preference semantics This process generates a sequence of prompts to understand user preferences, which is then input into a large language model to guide semantic reasoning based on user history interactions, ultimately generating interpretable text describing user preferences. The formula is as follows: ; The prompt word template for generating user preference descriptions in this invention also adopts a structured hierarchical design, divided into two fixed modules from top to bottom: The system instruction module is fixed as "Assume you are an expert in service recommendation. Based on the triplets provided below, infer the services that the user might be interested in and generate an explainable text describing the user's preferences." Its function is to clarify the task objectives of the large language model and guide the model to infer the user's potential preferences from the knowledge triplets of the user's historical interactions. User history interaction knowledge module: Used to fill in the user history interaction services and their corresponding first-order knowledge triples obtained in step (1.3.1), in the format "["service name":(service entity, attribute relationship, attribute entity),...]", each service and its triples are listed separately, providing factual evidence of user preferences.
[0025] Step (1.3.3) uses the large language model encoder described in step (1.2.2) to process the user preference description text obtained in step (1.3.2). Decomposed into a sequence of semantic sub-word tokens, which is then mapped to the corresponding token embedding matrix. .
[0026] ; in, For large language model encoders, The text tokenization operation, built into the large language model encoder, breaks down the text into the smallest semantic sub-word units. }, express The first in the sequence i One token, n It is the total number of tokens. Each token was converted into a dimension. The semantic vector, d1 is the dimension of the token embedding vector output by the large language model encoder.
[0027] Step (1.3.4) involves modifying the token embedding matrix obtained in step (1.3.3). Perform max pooling to extract the global maximum feature from the embedding matrix, resulting in a fixed-dimensional interpretable text embedding. The formula for this process is: ; Here, `max` is the max-pooling operation, which extracts the global maximum value feature of the embedding matrix. express The Middle j Embedding vectors of tokens, Indicates user The final embedding vector of interpretable text.
[0028] The second step is graph structure encoding based on semantic enhancement of the large language model: the service description and service relationship are embedded with semantic enhancement of the large language model, and processed by user-service interaction graph collaboration encoding and service knowledge graph relationship perception encoding to obtain the final user representation and the final service representation that integrates interaction collaboration signals and global semantic association. The second step of this embodiment is as follows: Step (2.1) involves semantic enhancement and embedding alignment of service description information based on a large language model, as follows: Step (2.1.1) enhances the semantics of service relationships through prompt words. Semantic enhancement is performed on the original service description document to obtain a service description document enhanced with a large language model. The formula is as follows: ; in, For large language models used for semantic enhancement, Enhance the prompts in the service description. For the original service description document; Step (2.1.2) uses the large language model encoder described in step (1.2.2) to process the enhanced service description document obtained in step (2.1.1). Encoding is performed to obtain the original service semantic embedding enhanced by the large language model. The formula is as follows: ; Step (2.1.3) introduces a linear transformation layer to embed the original service semantics obtained in step (2.1.2). Projecting onto the same dimension space as the service ID embedding yields a dimension-aligned service description embedding. .
[0029] The formula for this process is: ; in, The weight matrix is a linear transformation matrix. For bias terms, It is the dimension of service ID embedding. This linear transformation layer will be used for dimension alignment of service description embedding and subsequent service relationship embedding, and adopts a parameter sharing design to unify the semantic space. Step (2.2) User-service interaction graph collaborative coding, as follows: Step (2.2.1) Calculate the set of neighboring services for each user and the set of neighboring users for each service; The initial user embedding uses ID embedding, and the initial service embedding uses service description embedding aligned with a large language model. For each user, the embedding of the previous layer of all its neighboring services is symmetrically normalized and weighted, resulting in the user's current layer embedding. For each service, the embedding of the previous layer of all its neighboring users is symmetrically normalized and weighted, resulting in the service's current layer embedding. This process is repeated until propagation through layer L is complete, yielding all embeddings for all nodes, as shown in the following formula: ; ; in, , These represent user u and service s respectively in the first place. Embedding of the propagation layer , Let each represent the set of neighboring nodes of user u and service s, respectively. The initial embedding in step (2.2.2) can be represented as: , For each user / service, the embeddings of all layers are summed and averaged to obtain the final node representation. The final user and service representations are output, which already contain interaction and collaboration signals and service semantic information, and can be directly used for subsequent recommendation prediction and similarity calculation tasks. Average pooling is performed on the embeddings of each layer to generate the final user representation of the user-service interaction graph. With service representation The formula is as follows: ; ; Where L is the total number of convolutional layers; Step (2.3) Service knowledge graph relation-aware encoding is as follows: Step (2.3.1) uses the weight matrix and head entity embedding Perform matrix multiplication to obtain the query vector. For each neighbor triple, embed the relation. Tail-end entity embedding Perform element-wise multiplication to obtain the fusion vector; use the weight matrix. Perform matrix multiplication with the fused vector to obtain a linearly transformed vector; input the linearly transformed vector into the tanh function to obtain the key vector of this triple. Then, perform a dot product between the query vector of the head entity and the key vector of this triple to obtain the current raw attention score. The formula is as follows: ; in, It refers to the dimensions of the query vector and key vector in the attention mechanism. , ; Step (2.3.2) involves counting the neighborhood triples of the service entity h with h as the head entity. The total number of sets formed To ensure that the attention coefficients are comparable among the head entity's neighbors, the Softmax function is used to adjust the current raw attention score obtained in step (2.3.1). Normalize the original attention scores of all neighbor triples with h as the head entity. Take the natural exponents, sum them up, and use the sum as the denominator. Then, calculate the original attention score for the current triple. Take the natural index, divide it by the sum of the denominators, and the final result is the attention weight of the current triple. The formula for calculating its weight is as follows: ; Here, the tanh function is the hyperbolic tangent activation function, which performs a non-linear transformation on the vector, compressing the values to the interval (-1, 1); ⊙ is the Hadamard product, which is the element-wise multiplication of two vectors, used to fuse semantic information. It is any semantic relation with h as the head entity. It is any tail entity that has h as its head entity; Step (2.3.3) involves modifying the original relational semantic vector from step (1.2.2). Perform a linear transformation to convert the relation semantic vector and the weight matrix. Adding bias terms during matrix multiplication The result is the dimension-aligned relation embedding, as shown in the following formula: ; Step (2.3.4) embeds the aligned relation obtained in step (2.3.3) for each triple (h,r,t). With the tail entity in the first Layer embedding Element-wise multiplication yields the fused semantic vector for each triple. For each triple's fused semantic vector, multiply it by its corresponding attention weight to obtain the triple's final contribution vector to the head entity. Then, sum the contribution vectors of all neighboring triples to obtain the total aggregate vector. Divide the total aggregate vector by the total number of neighboring triples. After performing average normalization, the final result is the head entity h at the th . Embedded after layer update The formula is as follows: ; Step (2.3.5) involves summing all the embedding vectors of the target service entity s from layer 0 to layer g in the knowledge graph encoding process element by element to obtain the final embedding of the service in the knowledge graph. This vector fully integrates full-scale information about the service, from its own semantics to higher-order global associations. The specific process is as follows: ; When the service entity s is used as the head entity h, It directly became The embedding of service entity s at layer g , where g is the upper limit of the number of embedding aggregation layers in the last convolution.
[0030] Step (2.3.6) represents the service interaction graph obtained in step (2.2.2). The service knowledge graph representation obtained in step (2.3.5) By combining the data, we obtain the final representation of the service. The interaction probability is predicted by calculating the inner product of the final user representation and the final service representation. .
[0031] The formula for this process is: ; .
[0032] The third step is text domain cross-aware processing based on multi-head cross-attention: inputting multi-source heterogeneous ID embedding, graph structure embedding and interpretable text embedding into the multi-head cross-attention module, completing deep fusion through semantic interaction across feature spaces, and concatenating the full feature vectors to obtain a complete prompt sequence for interpretation of the generated data. The third step in this embodiment is as follows: Step (3.1) Cross-attention interaction of multi-source embeddings is as follows: Step (3.1.1) involves performing linear transformations on the target embedding and source embedding using the corresponding weight matrix for each attention head, obtaining the query matrix Q, key matrix K, and value matrix V corresponding to that attention head. The transposes of Q and K are then multiplied to obtain the similarity matrix. This similarity matrix is scaled using the square root of the vector dimension, and the scaled matrix is then input into the softmax function to obtain the normalized attention weights. Finally, the attention weights are multiplied by V to obtain the output of the single-head attention. The calculation process is defined by the following formula: ; Among them, when the dimension is extremely high, It acts as a scaling parameter, mitigating the potential amplification of the inner product value. It is the feature dimension of a single attention head. The similarity scores are converted into a probability distribution between 0 and 1, with a sum of 1, to quantify the contribution of each K to Q. , , , To query the sequence length, The length of the key / value sequence is given. Since all embeddings involved in the cross-attention calculation in this method are single vectors rather than multi-token sequences, therefore... =1 and =1, To ensure that the total dimension after splicing the multi-head outputs matches the input embedding dimension. Maintain consistency = ; Step (3.1.2) uses the three weight matrices specific to the j-th head to perform matrix multiplication on the global Q, K, and V respectively, to obtain the weights specific to this head. The final vector obtained by performing cross-attention calculation is the output of the j-th attention head. The process formula is as follows: ; Step (3.1.3) concatenates the outputs of all attention heads obtained in step (3.1.2) along the vector dimension, and then performs linear projection to obtain the enhanced embedding: ; Among them, symbols Used only as a marker for cross vectors, the symbol This can be represented as user ID embedding. Service ID Embedded User embedded in the image Service embedding in the graph , The function is a function wrapper for multi-head cross-attention, which internally includes the entire process of single-head cross-attention calculation, multi-head result concatenation, and linear projection. H is the total number of attention heads. The trained linear projection matrix maps the concatenated multi-head high-dimensional vector to the target dimension required in subsequent processes, while also fusing multi-head information. The above four embeddings are then compared with interpretable text embeddings. Cross-attention interaction is performed to generate four cross vectors. , , , .
[0033] Step (3.2) involves constructing a prompt sequence that integrates information from multiple sources, as follows: Concatenate all cross vectors with the original embeddings to construct the complete cue sequence S, which is then input into the subsequent interpretation generation module, as shown in the following formula: The formula for this process is: ; in This indicates a vector concatenation operation.
[0034] The fourth step is personalized recommendation explanation generation and optimization: the generated prompt sequence is subjected to autoregressive generation and semantic optimization of personalized recommendation explanation, and the optimal recommendation explanation is obtained by generating a large language model through explanation; The fourth step in this embodiment is as follows: Step (4.1) generates the initial interpretation based on the Transformer, as follows: The prompt sequence S obtained in step (3.2) is added with a positional code and input into the pre-trained Transformer decoder to obtain the encoded sequence. Record its total length. An autoregressive generation method is used, generating only one word per step. When generating the next word, only the input sequence can be used. This process involves generating all words already generated. Starting with the first word, each step calculates the generation probability of all possible words, selecting the word with the highest probability as the generated result for the current position. Words are then concatenated in the generation order to form a complete explanatory text sequence. Generation stops when a text terminator is generated or the preset maximum text length is reached, yielding the initial optimal recommended explanation. : ; in, Represents the set of generated word sequences. For sequence Length, Represents the explanatory text sequence The first in t Each word element, Indicates the first Generating lexical units at each position The probability of.
[0035] Step (4.2) involves secondary optimization of the explanatory text based on the large language model, as follows: Using an interpretable recommendation template, the initial explanatory text obtained in step (4.1.1) is transformed into an interpretable recommendation template. The input large language model performs semantic optimization, logical completion, and personalization enhancement on the initial explanation to obtain the final personalized recommendation explanation. .
[0036] The formula for this process is: .
[0037] in, To explain the generation of a large language model, the structure of the prompt is as follows: Figure 1 As shown in Module 4.
[0038] This embodiment uses the Programmable Web dataset for experimental verification, including users, APIs, categories, tags, and descriptions. From the Programmable Web dataset, 4892 users and 11930 APIs were selected. The experimental environment was as follows: Python was used as the programming language. The computer configuration was an AMD Ryzen 7 5800X 8-core processor and 16GB of RAM to implement the LLM-KDESR model.
[0039] The experimental setup is as follows: 70% of the data is randomly selected as the training set, and the remaining 30% is used as the test set. Grid search is used to find the most suitable hyperparameters. The learning rate is selected from {0.001, 0.003, 0.006}, the number of convolutional layers ranges from {1, 2, 3, 4, 5}, and the number of attention heads in the multi-head self-attention mechanism is [not specified]. hThe temperature hyperparameter is selected from {2,4,8} and adjusted within the range of {0.02,0.04,0.06,0.08,0.1}. This embodiment uses the ADAM optimizer to optimize the proposed method and Xavier initialization to initialize the model parameters.
[0040] Evaluation metrics: To comprehensively evaluate the performance of explainable recommendations, the experiment was conducted based on three main aspects: text quality, explainability, and recommendation performance.
[0041] In terms of text quality assessment, the experiment adopted the Bilingual Evaluation Understudy (BLEU) method, a widely used indicator for evaluating the quality of generated text. Its core principle is to calculate the quality difference between the generated text and the reference text. n The degree of matching of -grams is used to measure the performance of translation or generation tasks. Considering both evaluation requirements and computational efficiency, the experiment uses BLEU-1 and BLEU-4 as evaluation metrics. BLEU-1 ensures accurate matching of key terms in the generated explanation, while BLEU-4 assesses sentence fluency and semantic coherence. The formula for calculating the BLEU metric is as follows: ; ; Among them, To generate the text length, For reference text length, refer to n The weights of a gram are typically set to uniform weights, meaning that for any gram... n All , As a penalty factor, a higher BLEU score indicates stronger generated text. With reference text The higher the similarity between them, the better the generated quality. This represents the n-gram precision rate, which is the proportion of n-grams in the generated text that match the reference text to the total number of n-grams in the generated text.
[0042] This embodiment uses Recall-Oriented Understudy for Gisting Evaluation (Rouge), a commonly used evaluation metric in text summarization tasks. Rouge primarily assesses the recall of generated explanatory text by calculating the overlap between the generated explanatory text and the reference text. Unlike BLEU, Rouuge focuses on Precision, Recall, and F1 score. Rouge helps assess whether the generated explanation covers the key information that users care about, thus better measuring the completeness of the explanation. The formulas for each metric are as follows: ; ; ; However, BLEU and ROUGE primarily rely on word matching to evaluate the quality of generated text, leading to inherent limitations in semantic consistency detection. Therefore, BLEU and ROUGE perform only moderately well when evaluating the personalization of generated text. To better evaluate personalized generated text, the experiment introduced the USR (Unique Sentence Ratio) metric to calculate the uniqueness ratio of generated sentences, as shown below: ; in, This represents the set of sentences generated by the model, where N is the total number of explanatory texts generated.
[0043] Furthermore, for interpretability evaluation, the experiment used Feature Matching Ratio (FMR), Feature Coverage Ratio (FCR), and Feature Diversity (DIV). FMR measures the percentage of real-text features contained in the generated interpretive text, and the calculation formula is shown below: ; ; Among them, for user-service pairs , This represents the generated explanatory text. Represents the true characteristics, where N is the total number of user-service pairs in the test set.
[0044] FCR measures the proportion of features contained in the generated explanatory text to the total number of true features, and is calculated as follows: ; in, This indicates the number of features in the actual explanatory text. This indicates the number of different features that appear in the generated explanatory text.
[0045] DIV measures the intersection of features between different generated texts, and its calculation method is as follows: ; in, and This represents the feature set contained in the two generated texts, where N is the total number of generated explanatory texts.
[0046] To evaluate the accuracy and effectiveness of different models, this experiment uses two widely used evaluation metrics to assess the performance of service recommendation results: Hit Rate (HR) and Normalized Discounted Cumulative Gain (NDCG).
[0047] The HR metric is used to evaluate the accuracy of service recommendation results. A higher HR metric value indicates better model accuracy. The calculation method is as follows: ; Where N is the total number of explanatory texts generated. For the hit function, Indicates service Is it in the recommended list? If it is in the recommended list, The value is 1, indicating that the item does not appear in the recommendation list. The value is then 0. During the experiment, the service recommendation list length was selected as 10 or 20, and the HR indicator was recorded as HR@10 or HR@20.
[0048] NDCG is a ranking-related evaluation metric. A higher NDCG value indicates a better ranking result and stronger recommendation performance of the model. The formula for calculating this metric is as follows: ; ; in, B This represents the length of the recommended list. Representing the b The relevance score for each API service is represented by IDCG, which stands for DCG under ideal conditions. During the experiment, the service recommendation list length was set to 10 or 20, in which case the NDCG metric was recorded as NDCG@10 or NDCG@20.
[0049] Baseline methods: To verify the performance advantages of the method of this invention, seven mainstream advanced baseline methods in the field of interpretable recommendations were selected for comparison, namely NRT, Att2Seq, PETER, PEPLER, IWRER, RRPLEF, and SGDiff-KSR. NRT: Proposes a joint learning model that simultaneously predicts ratings and generates short hints. The model uses a neural network to generate textual explanations from the latent vectors of users and items, aiming to improve the interpretability of recommendations.
[0050] Att2Seq proposes an attribute-to-sequence model that uses an attention mechanism to encode attributes such as users, items, and ratings into vectors and generates product reviews through a sequence decoder, emphasizing the generation of personalized text through attribute alignment.
[0051] PETER: This model is the first to apply Transformer to personalized, explainable recommendations. By designing a context prediction task, it maps user and item IDs to a text space to generate personalized explanations. The model can perform both recommendation and explanation generation simultaneously.
[0052] PEPLER: Utilizing the pre-trained language model GPT-2 and learning from prompts by taking user and item IDs as input, it generates high-quality explanations and proposes an order optimization strategy to improve the relevance and diversity of generated text.
[0053] IWRER addresses the sparsity of user review data by using user-item interactions as input and generating simulated reviews through a reinforcement learning agent. These simulated reviews serve as pseudo-labels to enhance the training data. Through self-learning, it dynamically adjusts the weights of the training samples, improving the fluency and relevance of the generated explanations.
[0054] RRPLEF: A cue learning method for explainable recommendations. It optimizes cue embeddings through reparameterization and combines feature attention mechanisms to capture fine-grained user-item interactions, thereby generating more accurate and personalized explanations.
[0055] In the recommendation task, in addition to comparisons with the NRT and PETER models, it was also compared with five other models.
[0056] PMF: A traditional probabilistic matrix factorization technique used to represent users and items using latent factors.
[0057] SVD++: Combines matrix factorization and neighborhood methods, leveraging implicit feedback to improve prediction accuracy.
[0058] NETE: Proposes a neural template-based framework that generates high-quality interpretations through gated fusion recurrent units.
[0059] KnowRec: Introduces knowledge graph-enhanced recommendation, generating objective explanations through KG entities and relationships to solve the problems of data sparsity and cold start.
[0060] SGDiff-KSR addresses the issues of data sparsity and insufficient semantic fusion by removing redundant noise through an adaptive knowledge graph enhancement strategy, reconstructing the user-service interaction graph using multi-semantic guided diffusion, and aligning the representation space through cross-view comparative learning.
[0061] Baseline comparison experiment: Detailed information on the experimental results is shown in Tables 1 and 2, where the best results for the indicators are bolded and the second-best results are underlined.
[0062] Table 1 shows the experimental results of baseline comparison of the LLM-KDESR interpretable task;
[0063] Among the selected comparison models, the NRT method based on neural network models performed poorly across various metrics, with a USR of only 0.08. NRT, through joint learning of ratings and prompts, was the first to introduce multi-task learning into recommendation systems, capable of generating brief explanations. However, it relies solely on user-service IDs and rating data, lacking explicit modeling of specific service attributes and user historical preferences. This results in low personalization of recommendation explanations, easily leading to ambiguous text interpretations and poor text quality. Due to limited model capacity and a lack of semantic priors, grammatical errors or repetitive word usage may occur. Att2Seq, building upon this, introduces an attention mechanism to dynamically align user attributes and service features, generating more relevant comment explanations. Metrics such as B1 and B4 show some improvement compared to NRT. However, it relies on manually defined attribute templates, making it difficult to adapt to dynamic user needs in complex service relationships. When generating long texts, it may lose long-term dependencies, leading to inconsistencies in explanations. PETER, employing a Transformer architecture, directly maps user and service IDs to the semantic space and uses a self-attention mechanism for dynamic weighting to achieve personalized explanation generation. This solves the instability problem of sequence model-generated explanations, significantly improving text quality metrics. However, a significant semantic gap exists between the embedding space of user service IDs and the embedding space of generated text, leading to potentially insufficient depth and accuracy in the model's description of services, resulting in a certain degree of decline in the FCR metric. The PEPLER method improves both FMR and FCR metrics. It utilizes a pre-trained language model (GPT-2) and cue learning, using user and service ID information as cues to guide LLM in generating fluent natural language explanations, thus improving the fluency of the explained text. However, the simple cue design may not fully and accurately express complex user-service relationships, causing explanations to deviate from the core recommendation rationale. Addressing the challenge of missing comments in real-world scenarios, IWRER uses adversarial networks to complete the interactions of missing comments, mitigating data sparsity. It can model users' implicit preferences for services, especially for long-tail users and services with sparse interactions, generating more reasonable explanations, with significant improvements in USR and FCR in sparse scenarios. RRPLEF further introduces reparameterized cues and feature attention mechanisms, dynamically weighting service attributes to generate more accurate explanations, but it ignores higher-order interactions between users and services, making it difficult to accurately understand users' true preferences.
[0064] Experimental results show that the LLM-KDESR method significantly outperforms existing baseline models in interpretable service recommendation tasks. Specifically, in terms of interpretability metrics, LLM-KDESR achieves an FMR of 0.21, a 10.53% improvement over the second-best baseline RRPLEF, and an FCR of 0.54, a 25.58% improvement. LLM-KDESR also achieves satisfactory results on USR and DIV metrics, with the DIV metric decreasing to 1.46, a reduction of 5.19%. The lack of significant performance improvement on DIV indicates that diversity alone cannot guarantee interpretation quality. In service scenarios, service functions are often relatively concentrated, and interpretation cannot be evaluated solely based on diversity without considering the actual needs of users. Regarding text quality metrics, LLM-KDESR improves by 22.34% and 14.73% on B1 and B4, respectively; ROUGE-1 improves precision and recall by 20.62% and 14.12%, respectively. The corresponding metrics for the ROUGE-2 series improve by 24.45% and 11.62%. This indicates that the generated explanatory text shows significant improvements in fluency, information quality, and semantic coherence.
[0065] Table 2 shows the baseline comparison results of the LLM-KDESR recommended tasks;
[0066] As shown in Table 2, the LLM-KDESR method significantly outperforms existing baseline models in recommendation accuracy. Specifically, in key evaluation metrics, LLM-KDESR achieves a HR@10 of 0.6281, a 1.27% improvement over the second-best method, SGDiff-KSR; and an NDCG@10 of 0.5924, a 1.53% improvement. HR@20 is 0.6643, a 1.19% improvement over SGDiff-KSR; and NDCG@20 is 0.6078, a 1.33% improvement. Compared to KnowRec, LLM-KDESR demonstrates a significant performance improvement, indicating the effectiveness of LLM-KDESR in leveraging LLM's deep understanding of knowledge graph semantics and enhancing service representation learning. The advantage of LLM-KDESR stems from its innovative integration of an LLM-enhanced knowledge graph understanding module and a text domain cross-sensing mechanism, enabling the model to more accurately capture the complex relationships between user preferences and service functions, thus achieving a synergistic improvement in semantic understanding and decision optimization in service recommendation tasks.
[0067] Ablation Experiments: Ablation experiments were conducted on the proposed LLM-KDESR model to explore the effectiveness of each component in improving model performance. Six LLM-KDESR variants were constructed: LLM-KDESR-A removes interpretable text embeddings generated by LLM prompts; LLM-KDESR-B removes service relation embeddings generated by LLM prompts; LLM-KDESR-C removes LLM semantically enhanced service text embeddings; LLM-KDESR-D removes graph structure embedding markers from cross-attention; LLM-KDESR-E removes cross-embedding markers from sequences; and LLM-KDESR-F removes both graph structure embedding markers and cross-embedding markers from cross-attention. The same hyperparameters were used for all variant models during the experiments, such as... Figure 2 The results shown are the experimental results for each evaluation index under different interpretability metrics.
[0068] The results from the data in the figure are analyzed as follows: Compared to LLM-KDESR, its ablation variant, LLM-KDESR-A, removes the interpretable text embeddings generated by LLM prompts, resulting in a significant decrease in all indicators. Specifically, FMR and FCR decreased by 47.62% and 51.85%, respectively. Since the user preference text generated by LLM from the knowledge graph has rich semantic information and interpretability, it provides a high-quality semantic template; its absence directly impairs the fluency of interpretation and content relevance. LLM-KDESR-B removes the service relationship embeddings generated by LLM prompts, reducing R1-P by 7.00%, indicating that this module can deeply mine the semantic relationships between services, improving the accuracy and coverage of recommendation reasons. After removing the LLM semantically enhanced service text embeddings, LLM-KDESR-C has R1-P and R1-R of only 22.97 and 18.93, respectively. The deep semantic information of the service description text cannot be fully captured, indicating that LLM's deep understanding of service descriptions can construct high-quality service representations and enhance the quality of text generation. Comparing LLM-KDESR-D and LLM-KDESR-E, it was found that the removal of graph structure embedding markers resulted in a greater decline in all metrics, particularly in interpretability metrics FCR and FMR, with FMR reaching only 0.15. This is because graph embeddings can capture higher-order user-service interaction information, enhancing feature representation. Graph structures accommodate more node information and better help the model utilize neighborhood information to generate recommendation explanations. LLM-KDESR-F further removed graph structure embedding markers and cross-embedding markers from the cross-attention mechanism, leading to further decreases in text quality metrics BLEU-1 and BLEU-4 by 19.72% and 13.51%, respectively. This indicates that the cross-attention mechanism can bridge the semantic gap between ID embedding, graph embedding, and text embedding, improving the fluency of explanations and text quality.
[0069] In conclusion, the LLM-KDESR model proposed in this invention significantly improves the quality and personalization of generated text while ensuring recommendation accuracy through the organic synergy of LLM-enhanced KG understanding, LLM-enhanced graph embedding, and cross-attention components, thus verifying the necessity of each module.
[0070] Hyperparameter Experiment: This experiment selects the number of convolutional layers for interpreting the generation task. This serves as an experimental subject to verify the impact of hyperparameters on the recommendation performance of LLM-KDESR. The number of convolutional layers is also verified. Impact on recommendation performance. This experiment seeks the optimal number of convolutional layers within the range of 1 to 5. Experimental results are as follows: Figure 3 As shown in the figure, the model achieves optimal performance across all metrics when the number of convolutional layers is 3. Recommendation performance deteriorates with too many or too few layers. The reason for this is that a smaller number of convolutional layers limits the propagation of service node information within the graph, hindering the effective learning of higher-order information from API service nodes. This results in the interpretation of user-service interactions relying on shallow, direct association features, leading to poor accuracy and interpretability of the recommendation results. When the number of convolutional layers is 1, the HR@10 and NDCG@10 metrics are low, at only 0.5317 and 0.5035 respectively. However, when the number of convolutional layers is 5, the FMR, FCR, and USR metrics in the observed graph decline by 23.8%, 27.78%, and 31.42% respectively compared to the optimal metrics, indicating a significant decrease in the interpretability of the recommendations. This is because too many convolutional layers lead to similar service node features, making it difficult for the model to capture the important features that distinguish nodes. This results in ambiguous and unpersonalized interpretations, leading to oversmoothing and a decline in recommendation performance.
[0071] The embodiments described in this specification are merely examples of implementations of the inventive concept and are for illustrative purposes only. The scope of protection of this invention should not be considered limited to the specific forms described in these embodiments; rather, it extends to equivalent technical means conceived by those skilled in the art based on the inventive concept.
Claims
1. A knowledge-driven, interpretable service recommendation method based on a large language model, characterized in that, First, a collaborative knowledge graph for the service recommendation scenario is constructed, and service-centric and user-centric subgraphs are extracted. Using a large language model and prompt templates, structured triples are transformed into interpretable natural language descriptions, which are then mapped to service relationship embeddings and interpretable text embeddings through a pre-trained text embedding model. Next, the service description semantics enhanced by the large language model are used as the initial embedding for graph encoding. Collaborative encoding and relationship-aware encoding are implemented on the user-service interaction graph and service knowledge graph, respectively, learning user and service representations that balance collaborative signals and knowledge semantics, and predicting interaction probabilities. Then, multi-source heterogeneous embeddings are fed into a multi-head cross-attention module to complete cross-feature space interaction, and the resulting complete prompt sequence is constructed to generate the explanation. Finally, a pre-trained Transformer decoder is used to generate initial recommendation explanations word by word, which are then optimized a second time by the large language model to obtain personalized recommendation explanations that match the recommendation decision.
2. The knowledge-driven interpretability service recommendation method based on a large language model as described in claim 1, characterized in that, The method includes the following steps: The first step involves inputting the service knowledge graph triples constructed for the service recommendation scenario and the user's historical interaction service data into the large language model. After semantic parsing and encoder mapping guided by customized prompt templates, the service relationship embedding, user preference embedding, and interpretable text embedding that integrate deep semantic associations of services and personalized user preferences are extracted. The second step is to embed the service description and service relationship into the semantically enhanced big language model, and then process them through user-service interaction graph collaboration encoding and service knowledge graph relationship perception encoding to obtain the final user representation and final service representation that integrates interaction collaboration signals and global semantic association. The third step involves inputting the multi-source heterogeneous ID embedding, graph structure embedding, and interpretable text embedding into the multi-head cross-attention module. Deep fusion is achieved through semantic interaction across feature spaces, and the full feature vectors are concatenated to obtain a complete prompt sequence for interpreting the generated data. The fourth step involves autoregressive generation and semantic optimization of personalized recommendation explanations on the generated prompt sequence. The optimal recommendation explanation is obtained by generating a large language model through the explanation.
3. The knowledge-driven interpretability service recommendation method based on a large language model as described in claim 2, characterized in that, The process of the first step is as follows: Step (1.1) Construct the knowledge graph and core subgraph for the service recommendation scenario; We construct a service knowledge graph for the service recommendation domain. The knowledge graph uses semantic relationship triples, which consist of three elements: head entity, semantic relationship, and tail entity, as the basic unit. Among them, the service entity is the Web API service to be recommended in the service recommendation scenario and is the core entity object of the knowledge graph. The attribute entity is the feature description entity of the service entity's inherent attributes such as functional characteristics, technical parameters, belonging subject, category label, applicable scenario, calling constraints, version information, and dependency relationship. The association entity is the auxiliary entity that is attached to the attribute entity and is used to expand the deeper semantics of the service. The semantic relationship is the general term for the logical relationship between all entities and the relation part of the knowledge graph triple, which includes two types of sub-relationships: attribute relationship and association relationship. A user-service interaction graph is constructed, with user entities and service entities as two independent types of nodes. When a user and a service have historical interactions, connection edges are established between the corresponding nodes. The user entity is a node representing a real user or a group of users. The user-service interaction graph is then integrated with the service knowledge graph to obtain a collaborative knowledge graph that uniformly represents users, services, attribute entities, and various relationships. For each service, a two-hop local subgraph, namely the service center subgraph, is extracted from the collaborative knowledge graph. This subgraph centers on the service and contains service entities, attribute entities, and related entities derived from the attribute entities. It contains first-order attribute triples and randomly sampled second-order relation triples. The head entity of the first-order attribute triple is the service entity, the semantic association is the attribute relation, and the tail entity is the attribute entity. The head entity of the second-order relation triple is the attribute entity, the semantic association is the association relation, and the tail entity is the related entity.
4. The knowledge-driven interpretability service recommendation method based on a large language model as described in claim 3, characterized in that, The first step also includes: Step (1.2) concatenates the first-order attribute triples obtained in step (1.1) into the base text. Using a predefined fixed sentence mapping template, the second-order relation triples are transformed into coherent natural language statements. Combined with prompts that enhance the semantics of service relationships, a complete prompt sequence is formed. This sequence is then input into a pre-trained large language model to parse the deep semantic associations of the services, outputting a semantic description of the service relationships. This description is then mapped into service relationship embeddings by the large language model encoder. ; Step (1.3) in the collaborative knowledge graph This approach focuses on the target user, extracting all services that generated their historical interactions to form a user interaction service set. For each service, a set of first-order attribute triples from the knowledge graph is extracted. The user interaction service set and the corresponding first-order attribute triples for each service constitute a user-centric subgraph. The first-order attribute triples are concatenated into basic text, and the names of all historical interaction services are linked with their corresponding texts to obtain a user subgraph information description. This is combined with prompts that enhance the semantics of user preferences, input into a large language model, and latent preferences are inferred based on the user's historical interactions to generate interpretable user preference description text. The large language model encoder then decomposes the user preference description text into a semantic sub-word token sequence and maps it to a token embedding matrix. Max pooling is performed on this matrix to extract the global maximum feature, forming a fixed-dimensional interpretable text embedding. .
5. The knowledge-driven interpretability service recommendation method based on a large language model as described in claim 2, characterized in that, The second step is as follows: Step (2.1) enhances the semantics of the original service description document by driving the large language model with prompts that enhance the semantics of service relationships, resulting in a semantically enhanced service description document. This document is then mapped to a service semantic embedding by the large language model encoder, and projected onto the same dimensional space as the service ID embedding through a linear transformation layer, resulting in a dimensionally aligned service description embedding. The linear transformation layer employs a parameter-sharing design.
6. The knowledge-driven explainability service recommendation method based on a large language model according to claim 5, wherein, The second step also includes: Step (2.2) embedding with user ID initially embedding for users, embedding for services with dimension alignment initially embedding for services, for each user, symmetric normalization weighted sum of all neighbor services' last layer embedding, getting user's current propagation layer embedding, for each service, symmetric normalization weighted sum of all neighbor users' last layer embedding, getting service's current propagation layer embedding, repeating the above propagation operation to L layer, adding and averaging each layer embedding, forming the final user representation considering both interaction collaborative signal and service semantic information with service representation ; Step (2.3) embeds the service relationship obtained in step (1.2). Perform the parameter-sharing linear transformation described in step (2.1) to obtain the dimension-aligned relation embedding. Through a relation-based attention mechanism, a query vector is constructed from the head entity embedding. The relation embedding and the tail entity embedding are multiplied element-wise to obtain a fusion vector, which is then used to construct a key vector. The original attention score of the head entity for each neighborhood triplet is calculated. The scores of all neighborhood triplets of the same head entity are normalized to obtain the attention weight. The dimension-aligned relation embeddings are then used to construct the key vector. The fused semantic vector is obtained by multiplying the embedding of the tail entity element-wise with the embedding of the next layer above. The fused semantic vector of each neighborhood triple is then weighted and summed according to the attention weight, and then normalized by the total number of neighborhood triples to obtain the updated embedding of the head entity. The above aggregation process is repeated layer by layer up to layer g. The embeddings of the service entity in the knowledge graph encoding from layer 0 to layer g are added element-wise to obtain the service knowledge graph representation. This representation is then concatenated with the service representation obtained in step (2.2) to obtain the final service representation. and through end-user representation With the final representation of the service The inner product predicts the probability of user-service interaction.
7. The knowledge-driven interpretability service recommendation method based on a large language model as described in claim 2, characterized in that, The process of the third step is as follows: Step (3.1) transforms the end-user representation obtained in step (2.2) into a single representation. The final service representation obtained in step (2.3) Embedded along with user ID Embedded with Service ID The interpretable text obtained in step (1.3) is embedded as query embeddings. Simultaneously serving as both key and value embeddings, multi-head cross-attention computation is performed. Each attention head performs a linear transformation on the query, key, and value embeddings using a head-specific weight matrix. The similarity matrix between the query and key is normalized to attention weights after being scaled by the square root of the vector dimension. The value embeddings are then weighted and summed using these attention weights to obtain the head's output. The outputs of all attention heads are concatenated along the vector dimension and linearly projected to obtain the user ID embedding, service ID embedding, final user representation, and final service representation, which are then compared with interpretable text embeddings. Four cross vectors for cross-fusion; Step (3.2) embeds the user ID Service ID embedding and its cross-vectors with interpretable text embeddings, end-user representation Service final representation and its cross vector with interpretable text embedding, along with interpretable text embedding By concatenating them in sequence, a complete prompt sequence for the input interpretation generation module is formed. .
8. The knowledge-driven interpretability service recommendation method based on a large language model as described in claim 2, characterized in that, The process of the fourth step is as follows: Step (4.1) involves using the prompt sequence obtained in step (3.2). With positional encoding added, the input to a pre-trained Transformer decoder yields an output encoded sequence. An autoregressive approach is used to generate explanatory text word by word. At each step, the generation probability of each candidate word is calculated based on the encoded sequence and all previously generated words. The word with the highest probability is selected as the generation result for the current position. The process stops when a text terminator is generated or the preset maximum text length is reached, thus obtaining the initial recommended explanation. ; Step (4.2) uses an interpretable recommendation-specific prompt template to interpret the initial recommendation obtained in step (4.1). Integrating user preference information and service feature information into an optimized prompt sequence, the input explanation generates a large language model. The initial explanation is then semantically optimized, logically completed, and personalized to obtain the final personalized recommendation explanation. .
Citation Information
Patent Citations
Knowledge-guided credible API recommendation method based on large language model
CN119474540A
Personalized intelligent recommendation method and system based on large language model
CN120873294A
API intelligent recommendation method and system based on semantic knowledge graph
CN121166190A
