Interface scheduling method and device, electronic equipment and computer readable storage medium
By generating a combination of semantic eigenvectors and entity vectors, combined with large language models and hierarchical reinforcement learning models, the problem of inaccurate user intention recognition is solved, and more accurate and efficient interface scheduling is achieved.
Patent Information
- Application Number
- CN202510669143.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-22
- Publication Date
- 2025-08-15
AI Technical Summary
In the prior art, the user's intention recognition accuracy before interface calls is low, which affects the accuracy of interface calls.
By obtaining the user request text, extracting semantic features to generate semantic feature vectors, and combining preset entity vectors to generate user intent analysis results, using large language models and hierarchical reinforcement learning models to determine the target interface and its call order, and considering factors such as interface performance, historical effects and business priorities for interface scheduling.
Improve the accuracy of user intention recognition, thereby improving the accuracy and efficiency of interface scheduling.
Smart Images

Figure CN120493907A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of artificial intelligence technology, and specifically relates to an interface scheduling method, device, electronic device and computer-readable storage medium. Background Art
[0002] In recent years, artificial intelligence (AI) has rapidly empowered various industries. Large language models, with their powerful language understanding and generation capabilities, have become the core driving force behind natural language interaction systems. With the deepening of digital transformation, user needs are becoming increasingly diverse, cross-domain, and scenario-specific. A single system relying on large models is no longer able to meet these complex user demands, requiring the use of external interfaces to achieve complete service responses.
[0003] In related technologies, semantic recognition of user request text is required before the interface is called to understand the user's intention. The commonly used method is to unilaterally identify the user's intention based only on semantic features. The accuracy of user intention identified by this method is low, which affects the accuracy of the interface call.
[0004] Therefore, the accuracy of user intention recognition in the interface calling method in the related technology needs to be further optimized. Summary of the Invention
[0005] The technical problem to be solved by this application is to provide an interface scheduling method, device, electronic device and computer-readable storage medium in response to the above-mentioned deficiencies in the existing technology. By using this interface scheduling method, the accuracy of user intention recognition can be improved, thereby improving the accuracy of interface scheduling.
[0006] In a first aspect, an embodiment of the present application provides an interface scheduling method, comprising:
[0007] Get the user request text to be parsed;
[0008] Extract semantic features from user request text and generate corresponding semantic feature vectors;
[0009] Generate user intent parsing results corresponding to the user request text based on the semantic feature vector and the preset entity vector; the preset entity vector is generated by the preset graph neural network based on all entities of the preset knowledge graph;
[0010] Call the corresponding target interface based on the user intent analysis result.
[0011] In some implementations of the first aspect, extracting semantic features from the user request text and generating corresponding semantic feature vectors includes:
[0012] Use the word segmenter in the large language model trained to convergence to segment the user request text and generate a corresponding word vector sequence;
[0013] The encoder in the large language model is used to extract semantic features from the word vector sequence to generate a semantic feature vector.
[0014] In some implementations of the first aspect, the large language model is provided with adaptation layer parameters related to the knowledge domain;
[0015] Generate user intent parsing results corresponding to the user request text based on the semantic feature vector and preset entity vector, including:
[0016] Use a large language model to load the adaptation layer parameters corresponding to the semantic feature vector;
[0017] The semantic feature vector and the preset entity vector are input into the preset attention mechanism fusion algorithm using the large language model after loading the adaptation layer parameters, and the fused target feature vector is generated based on the preset attention mechanism fusion algorithm;
[0018] Map the target feature vector to the user intent parsing result.
[0019] In some embodiments of the first aspect, there are multiple target interfaces;
[0020] Call the corresponding target interface based on the user intent analysis result, including:
[0021] The upper-layer policy network of the preset hierarchical reinforcement learning model determines all target interfaces and the calling order of each target interface based on the user intent analysis results;
[0022] The lower-level strategy network of the preset hierarchical reinforcement learning model calls each target interface in sequence according to the calling order.
[0023] In some implementations of the first aspect, an upper-layer policy network of a preset hierarchical reinforcement learning model is used to determine all target interfaces and the order in which the target interfaces are called according to the user intent analysis results, including:
[0024] The upper-layer strategy network is used to determine the scoring parameters of multiple candidate interfaces according to the user intent analysis results;
[0025] Determine a corresponding interface score based on the score-related parameters of each candidate interface;
[0026] Determine all target interfaces from all candidate interfaces according to the scores of each interface;
[0027] The calling order of each target interface is determined according to the scoring parameters of each target interface.
[0028] In some implementations of the first aspect, the scoring-related parameters include interface performance, historical effect score, and service priority;
[0029] Determine a corresponding interface score based on the scoring parameters of each candidate interface, including:
[0030] Calculating a first product between the interface performance corresponding to each candidate interface and the first weight;
[0031] Calculate the second product of the historical effect score corresponding to each candidate interface and the second weight;
[0032] Calculate the third product between the service priority corresponding to each candidate interface and the third weight;
[0033] Sum the first product, second product, and third product corresponding to each candidate interface to generate a corresponding interface score;
[0034] The calling order of each target interface is determined based on the score-related parameters of each target interface, including:
[0035] The calling order of each target interface is generated in descending order according to the service priority corresponding to each target interface.
[0036] In some embodiments of the first aspect, before performing word segmentation processing on the user request text using a word segmenter in a large language model trained to convergence and generating a corresponding word vector sequence, the method further includes:
[0037] Obtain a training set; the training set includes historical request text, preset entity vectors, and actual user intent parsing results that match the historical request text;
[0038] Train the preset large language model based on the training set;
[0039] The total loss during training is determined based on a preset loss function. The total loss includes text semantic loss and entity loss. The text semantic loss is the loss between the predicted text semantics and the actual text semantics corresponding to the historical request text. The entity loss is the loss between the predicted entity and the actual entity corresponding to the historical request text. Both the predicted entity and the actual entity are entities in the knowledge graph.
[0040] If the total loss is less than the preset loss threshold, the preset large language model is determined to be the large language model trained to convergence.
[0041] Based on the same inventive concept, in a second aspect, an embodiment of the present application further provides an interface scheduling device, including:
[0042] The acquisition module is used to obtain the user request text to be parsed;
[0043] The extraction module is used to extract semantic features from the user request text and generate corresponding semantic feature vectors;
[0044] A generation module is used to generate a user intent parsing result corresponding to the user request text based on the semantic feature vector and the preset entity vector; the preset entity vector is generated by the preset graph neural network based on all entities of the preset knowledge graph;
[0045] The calling module is used to call the corresponding target interface according to the user intent analysis results.
[0046] In some embodiments of the second aspect, the extraction module is specifically configured to:
[0047] The word segmenter in the large language model trained to convergence is used to segment the user request text and generate a corresponding word vector sequence; the encoder in the large language model is used to extract semantic features from the word vector sequence and generate a semantic feature vector.
[0048] In some implementations of the second aspect, the large language model is provided with adaptation layer parameters related to the knowledge domain;
[0049] The generation module is specifically used to:
[0050] A large language model is used to load the adaptation layer parameters corresponding to the semantic feature vector; the large language model after loading the adaptation layer parameters is used to input the semantic feature vector and the preset entity vector into the preset attention mechanism fusion algorithm, and a fused target feature vector is generated based on the preset attention mechanism fusion algorithm; the target feature vector is mapped to the user intent analysis result.
[0051] In some embodiments of the second aspect, there are multiple target interfaces;
[0052] The calling module is specifically used to:
[0053] The upper-layer policy network using the preset hierarchical reinforcement learning model determines all target interfaces and the calling order of each target interface according to the user intention analysis results; the lower-layer policy network using the preset hierarchical reinforcement learning model calls each target interface in sequence according to the calling order.
[0054] In some embodiments of the second aspect, when the calling module determines all target interfaces and the calling order of each target interface according to the user intent analysis result using the upper-layer policy network of the preset hierarchical reinforcement learning model, it is specifically used to:
[0055] An upper-layer policy network is used to determine the scoring-related parameters of multiple candidate interfaces according to the results of user intent analysis; a corresponding interface score is determined according to the scoring-related parameters of each candidate interface; all target interfaces are determined from all candidate interfaces according to the scores of each interface; and the calling order of each target interface is determined according to the scoring-related parameters of each target interface.
[0056] In some implementations of the second aspect, the scoring-related parameters include interface performance, historical effect score, and service priority;
[0057] When the calling module determines a corresponding interface score based on the score-related parameters of each candidate interface, it is specifically used to:
[0058] Calculate a first product between the interface performance corresponding to each candidate interface and the first weight; calculate a second product between the historical effect score corresponding to each candidate interface and the second weight; calculate a third product between the service priority corresponding to each candidate interface and the third weight; sum the first product, the second product, and the third product corresponding to each candidate interface to generate a corresponding interface score;
[0059] When the calling module determines the calling order of each target interface according to the score-related parameters of each target interface, it is specifically used to:
[0060] The calling order of each target interface is generated in descending order according to the service priority corresponding to each target interface.
[0061] In some embodiments of the second aspect, the apparatus further comprises:
[0062] A training module is used to obtain a training set; the training set includes historical request text, preset entity vectors, and actual user intent parsing results matching the historical request text; a preset large language model is trained based on the training set; the total loss in the training process is determined based on a preset loss function; the total loss includes text semantic loss and entity loss; the text semantic loss is the loss between the predicted text semantics and the actual text semantics corresponding to the historical request text; the entity loss is the loss between the predicted entity and the actual entity corresponding to the historical request text; both the predicted entity and the actual entity are entities in the knowledge graph; if the total loss is less than the preset loss threshold, the preset large language model is determined to be a large language model trained to convergence.
[0063] Based on the same inventive concept, in a third aspect, an embodiment of the present application further provides an electronic device, the electronic device comprising:
[0064] memory and processor;
[0065] Memory stores computer-executable instructions;
[0066] The processor executes the computer-executable instructions stored in the memory to implement the interface scheduling method as described in any one of the first aspects.
[0067] Based on the same inventive concept, in the fourth aspect, an embodiment of the present application also provides a computer-readable storage medium, in which computer execution instructions are stored. When the computer execution instructions are executed by a processor, they are used to implement an interface scheduling method as described in any one of the first aspects.
[0068] According to the interface scheduling method, device, electronic device, and computer-readable storage medium provided in the embodiments of the present application, the user request text to be parsed is obtained, the semantic features in the user request text are extracted, and a corresponding semantic feature vector is generated. At the same time, a user intent parsing result corresponding to the user request text is generated based on the semantic feature vector and the preset entity vector. Based on the semantic feature vector and the preset entity vector, more potential requirements in the user request can be determined, thereby determining a more comprehensive and accurate user intent, improving the accuracy of user intent recognition, and thus improving the accuracy of interface scheduling. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] Figure 1 A schematic diagram showing a flow chart of the interface scheduling method provided in an embodiment of the present application is shown;
[0070] Figure 2 Another flow chart of the interface scheduling method provided in an embodiment of the present application is shown;
[0071] Figure 3 Another flow chart of the interface scheduling method provided in the embodiment of the present application is shown;
[0072] Figure 4 A schematic diagram of the deep semantic parsing process provided by an embodiment of the present application is shown;
[0073] Figure 5 A schematic diagram of the interface decision process provided by an embodiment of the present application is shown;
[0074] Figure 6 A structural diagram of an interface scheduling device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0075] In order to enable those skilled in the art to better understand the technical solution of the present application, the present application is further described in detail below with reference to the accompanying drawings and embodiments.
[0076] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only configured to explain the present application and are not configured to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is merely to provide a better understanding of the present application by illustrating the examples of the present application.
[0077] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus.
[0078] The interface scheduling method used in related technologies may not fully identify user intent and may have difficulty identifying hidden user intent, resulting in low accuracy in user intent and affecting the accuracy of interface calls. Therefore, further optimization is needed.
[0079] Example 1
[0080] The interface scheduling method provided in the embodiment of the present application can be executed by an interface scheduling device and an electronic device, etc. The following description will be made by taking the interface scheduling method executed by an electronic device as an example.
[0081] like Figure 1 As shown, the interface scheduling method provided in the embodiment of the present application may include steps S101 to S104.
[0082] S101: Obtain the user request text to be parsed.
[0083] For example, the user request text may include "I am going on a business trip to a certain city tomorrow and would like to know the weather there in advance so that I can prepare appropriate clothing," or "Please make a travel plan for a certain city," etc. The user request text may include scenarios, purposes, requirements, etc.
[0084] Exemplarily, a method of obtaining the user request text may be obtaining it from a user terminal, obtaining it from an electronic device storing the user request text, etc., which is not limited in this embodiment.
[0085] For example, users can submit natural language requests through terminals such as computers, mobile phones, and smart speakers. Natural language requests can be multimodal, such as text, voice, and images. Voice requests can be converted to text using the Whisper model, and image requests use OCR (Optical Character Recognition) technology to extract text to obtain the user's request text.
[0086] S102: Extract semantic features from the user request text and generate corresponding semantic feature vectors.
[0087] Exemplarily, the semantic features in the user request text may be extracted by using a large language model (LLM), a recurrent neural network, or the like.
[0088] S103: Generate a user intent analysis result corresponding to the user request text based on the semantic feature vector and the preset entity vector. The preset entity vector is generated by the preset graph neural network based on all entities of the preset knowledge graph.
[0089] For example, Graph Neural Network (GNN) refers to a general term for algorithms that use neural networks to learn graph-structured data, extract and discover features and patterns in graph-structured data, and meet the needs of graph learning tasks such as clustering, classification, prediction, segmentation, and generation.
[0090] Exemplarily, the entity of the preset knowledge graph is the smallest semantic unit of the knowledge graph, which is used to represent independently existing objects, such as specific objects such as people and places, or abstract concepts such as theories and emotions.
[0091] For example, the graph neural network converts all entities in a pre-set knowledge graph into pre-set entity vectors. By combining semantic feature vectors with pre-set entity vectors, more potential requirements in user requests can be identified, resulting in a more comprehensive and accurate user intent analysis result.
[0092] S104: Call the corresponding target interface according to the user intent analysis result.
[0093] For example, the user intent analysis result includes the parsed semantics and entities matching the user request text. For example, if the user request text is "Plan a food tour route in a certain city," the user intent analysis result might be {Destination: certain city, Activity: Food tour, Planning type: route}. Based on the user intent analysis result, the target interface to be called can be determined as the city interface, food interface, travel interface, route interface, etc., and these target interfaces can be called simultaneously or sequentially based on their relevance.
[0094] Exemplarily, the result of user intent parsing is a requirement description with entity annotations.
[0095] According to the interface scheduling method provided in the embodiments of the present application, the user request text to be parsed is obtained, the semantic features in the user request text are extracted, and a corresponding semantic feature vector is generated. Simultaneously, a user intent parsing result corresponding to the user request text is generated based on the semantic feature vector and the preset entity vector. Based on the semantic feature vector and the preset entity vector, more potential requirements in the user request can be determined, thereby determining a more comprehensive and accurate user intent, improving the accuracy of user intent recognition and thus improving the accuracy of interface scheduling.
[0096] Example 2
[0097] like Figure 2 As shown, the interface scheduling method provided in the embodiment of the present application is further described based on the interface scheduling method provided in Example 1 of the present application, and may include steps S201 to S208. Steps S202 to S203 can be replaced with step S102 in Example 1, steps S204 to S206 can be replaced with step S103 in Example 1, and steps S207 to S208 can be replaced with step S104 in Example 1. This embodiment does not limit this.
[0098] S201: Obtain the user request text to be parsed.
[0099] The implementation of S201 in this embodiment is similar to that of S101 in the previous embodiment, and will not be repeated here.
[0100] S202: Use the word segmenter in the large language model trained to convergence to perform word segmentation on the user request text to generate a corresponding word vector sequence.
[0101] For example, using a large language model to perform word segmentation on user request text can improve the accuracy of word vector sequences and provide a basis for the subsequent generation of more accurate semantic feature vectors.
[0102] In some implementations, before S202, a training process is further included, specifically as follows:
[0103] Obtain a training set. The training set includes historical request text, preset entity vectors, and actual user intent parsing results that match the historical request text. The actual user intent parsing results include the actual text semantics and actual entities.
[0104] Train the preset large language model based on the training set.
[0105] The total loss during training is determined based on a preset loss function. This total loss consists of text semantic loss and entity loss. Text semantic loss is the loss between the predicted text semantics and the actual text semantics corresponding to the historical request text. Entity loss is the loss between the predicted entities and the actual entities corresponding to the historical request text. Both the predicted entities and the actual entities are entities in the knowledge graph.
[0106] The predicted text semantics are the text semantics determined by the preset large language model during the training process. The predicted entities are similar to the predicted text semantics and are the corresponding entities determined, matched, and fused from the preset entity vectors during the training process.
[0107] If the total loss is less than the preset loss threshold, the preset large language model is determined to be the large language model trained to convergence.
[0108] By constructing a loss function and training a large language model, the accuracy of the large language model in extracting semantic feature vectors and fusing semantic feature vectors with preset entity vectors can be improved, thereby improving the accuracy of user intent recognition.
[0109] For example, the preset loss function is: L = αL T +βL G Among them, L T L is the text semantic loss, which can be calculated using cross entropy loss to measure the difference between the text semantics predicted by the model and the actual text semantics (true semantics). G It is the entity loss, which is obtained by calculating the distance between the predicted entity and the actual entity (real entity), such as the Euclidean distance.
[0110] The weights can be set as follows: α=0.7 , β = 0.3, thereby balancing the weights of the two loss terms and enabling the model to achieve accurate alignment of text semantics and knowledge graph entities.
[0111] For example, the large language model can be further trained using a contrastive learning strategy. This strategy extracts a feature vector Z from a user request and uses contrastive learning to maximize the similarity of feature vectors for different predicted versions of the same request, while minimizing the similarity of feature vectors for different requests.
[0112] The objective function is as follows:
[0113]
[0114] Where N is the number of requests, O[·] is the indicator function, c i is the category of request i, c j is the category of request j, sim(·) is the similarity function, τ is the temperature parameter, Z i is the feature vector of request i, Z jis the feature vector of request j, Z k is the feature vector for request k.
[0115] For example, in order to reduce the training cost of domain-specific models and improve the model's semantic understanding ability in different fields, adaptation layer parameters related to the knowledge domain can also be introduced. The large language model loads adaptation layer parameters from different fields to improve its semantic understanding ability in the corresponding field.
[0116] S203: Use the encoder in the large language model to extract semantic features from the word vector sequence to generate a semantic feature vector.
[0117] Exemplarily, the encoder may adopt a Transformer encoder to improve the accuracy of semantic feature extraction of word vector sequences.
[0118] It should be noted that the large language model of this embodiment is provided with adaptation layer parameters related to knowledge domains, and the specific knowledge domains involved can be set according to actual applications.
[0119] S204: Use the large language model to load adaptation layer parameters corresponding to the semantic feature vector.
[0120] Exemplarily, the adaptation layer parameters are related to the knowledge domain. After the semantic feature vector is determined, the knowledge domain corresponding to the semantic feature vector can be determined, thereby determining the corresponding adaptation layer parameters.
[0121] For example, the knowledge domain may be tourism domain, geographic location domain, technology domain, etc.
[0122] S205. Using the large language model after loading the adaptation layer parameters, the semantic feature vector and the preset entity vector are input into the preset attention mechanism fusion algorithm, and a fused target feature vector is generated based on the preset attention mechanism fusion algorithm.
[0123] By loading the adaptation layer parameters of the corresponding field, the large language model can improve the semantic understanding ability in the corresponding field and improve the accuracy of the semantic feature vector.
[0124] For example, the preset attention mechanism fusion algorithm is as follows:
[0125]
[0126] H TG =A(X G W v )
[0127] Among them, W Q 、W K 、W vIt is a learnable parameter matrix that is continuously adjusted and optimized during model training to better capture semantic relationships. k is the vector dimension, and A is the attention matrix, which is used to measure the degree of association between different entities and text semantic features. TG is the target feature vector after fusion, X G is the preset entity vector, H T is the text semantic feature vector.
[0128] S206: Map the target feature vector to a user intent analysis result.
[0129] Exemplarily, the target feature vector is mapped to a user intent parsing result through full connection, wherein the user intent parsing result is a requirement description with entity annotations.
[0130] S207: Using the upper-layer strategy network of the preset hierarchical reinforcement learning model to determine all target interfaces and the calling order of each target interface according to the user intention analysis result.
[0131] In this embodiment, there are multiple target interfaces. The hierarchical task decomposition of the layered reinforcement learning model improves the efficiency and versatility of calling the interface.
[0132] For example, a Hierarchical Reinforcement Learning (HRL) model is pre-configured. The model uses hierarchical reinforcement learning, a method for improving reinforcement learning efficiency through hierarchical task decomposition. This method breaks down complex problems into multi-level subtasks, using high-level strategies to plan goals and low-level strategies to execute actions. In this embodiment, the high-level strategy is used to determine the target interface and the order in which the target interfaces are called. The calling order can be sequential, parallel, or mixed.
[0133] For example, the upper-layer policy network is responsible for deciding the order of interface calls and can be trained in the following way:
[0134] With the current system status s i Calling sequence of actions for input and output interfaces By maximizing the cumulative reward For training, the formula is as follows:
[0135]
[0136] Where γ is the discount factor, is the reward obtained by the upper strategy network at time t+k, and Tt is the maximum value at that time.
[0137] For example, in the e-commerce after-sales scenario, the upper-level policy network determines the system status that needs to be queried, such as order status and logistics information, based on the results of user intent analysis. It decides to first call the logistics query interface and then call the refund interface to maximize user satisfaction and system efficiency.
[0138] In some implementations, the process of step S207 may be specifically as follows:
[0139] The upper-layer strategy network is used to determine the scoring-related parameters of multiple corresponding candidate interfaces based on the user intent analysis results.
[0140] A corresponding interface score is determined based on the score-related parameters of each candidate interface.
[0141] All target interfaces are determined from all candidate interfaces according to the scores of each interface.
[0142] The calling order of each target interface is determined according to the scoring parameters of each target interface.
[0143] The interface score of each candidate interface is used to identify all target interfaces from all candidate interfaces, thereby determining higher-quality interfaces, such as those with higher efficiency or greater relevance. The call order is determined by parameters related to the target interface scores, allowing for example to prioritize interfaces with business priorities or to call two interfaces without business relevance in parallel.
[0144] Exemplarily, the scoring-related parameters include service priority, interface performance (eg, real-time performance), historical effect score, service relevance, service type, and the like.
[0145] Exemplarily, all target interfaces are determined from all candidate interfaces based on the interface scores, and the interface with the highest interface score can be selected from each associated interface of the same type. For example, if the associated interface types determined are weather and city, and there may be multiple weather interfaces and multiple city interfaces, then the interface with the highest interface score among the weather interfaces and the interface with the highest interface score among the city interfaces are selected as the target interface.
[0146] For example, it is possible to determine whether there is a call order between the target interfaces. For example, if the interfaces determined are the weather interface and the city interface, there is a business priority and a certain call order, and the city interface must be called first, and then the weather interface. If the interfaces determined are the food interface and the weather interface, there is no business priority between the two interfaces and they can be called simultaneously.
[0147] For example, if the interface call fails, for example, the target interface has an exception, then the backup interface can be switched, and the backup interface can be the interface with the second highest interface score. Secondly, an exponential backoff retry strategy can also be used to stably determine a usable target interface.
[0148] In some embodiments, scoring parameters include interface performance, historical performance score, and service priority. Interface performance can be the real-time performance of the interface, such as response delay, error rate, etc. Historical performance score can be a score after user use. Service priority is the service priority level when the interface is called.
[0149] The process of determining a corresponding interface score based on the score-related parameters of each candidate interface can be specifically as follows:
[0150] A first product of the interface performance corresponding to each candidate interface and the first weight is calculated.
[0151] A second product of the historical effect score corresponding to each candidate interface and the second weight is calculated.
[0152] A third product of the service priority corresponding to each candidate interface and the third weight is calculated.
[0153] The first product, the second product, and the third product corresponding to each candidate interface are summed to generate a corresponding interface score.
[0154] The process of determining the calling order of each target interface according to the score-related parameters of each target interface can be as follows:
[0155] The calling order of each target interface is generated in descending order according to the service priority corresponding to each target interface.
[0156] By building multi-dimensional scoring parameters to evaluate each candidate interface, the most suitable target interface can be selected and determined. By generating the calling order of each target interface in descending order of business priority, interfaces with higher business priorities can be called first, improving the calling efficiency of interfaces with higher business priorities and making the calling order of target interfaces more consistent with business logic and business needs.
[0157] For example, the interface performance R is calculated from the response delay D and the error rate E using the formula R = 0.6D + 0.4E. D and E need to be normalized so that their values are within the range of [0, 1].
[0158] The historical performance score H is calculated based on the user score S and the interface success rate P, using the formula H = 0.5S + 0.5P. Similarly, S and P need to be normalized.
[0159] The interface score C is calculated based on the interface performance R, the historical effect score H, and the service priority B. The formula is C = 0.4R + 0.3H + 0.3B.
[0160] S208: Using the lower-layer strategy network of the preset hierarchical reinforcement learning model to call each target interface in sequence according to the calling order.
[0161] For example, the lower layer strategy network optimizes the calling parameters of a single interface according to the interface calling sequence of the upper layer decision network. The training process can be as follows: t and upper-level actions Actions that call parameters for input and output interfaces By maximizing the cumulative reward For training, the formula is as follows:
[0162]
[0163] in, The reward obtained by the lower-level policy network at time t+k. Other parameters can refer to the parameters of the upper-level policy network. Based on the example of the upper-level policy network, the lower-level policy network optimizes the query time range, query frequency and other parameters for the logistics query interface to improve the efficiency of the interface call.
[0164] For example, after calling the interface, the data returned by the interface can be integrated with the content generated by the large language model, the data can be checked for consistency and format converted, natural language response data can be generated, and fed back to the user.
[0165] The interface scheduling method provided in this embodiment adopts a dual-channel input architecture to fuse a large language model and a knowledge graph. The main channel processes the user request text to extract semantic features, and the auxiliary channel converts the knowledge graph information into a vector. The two are integrated to explore potential needs. Secondly, the adaptation layer parameters are introduced, and the comparative learning strategy is used to achieve precise alignment of text semantics and knowledge graph entities, breaking through the limitations of traditional semantic understanding and being able to understand user intentions more deeply and accurately. The interface score is calculated and updated in real time through scoring related parameters such as business priority, interface performance and historical effect score. With the help of a hierarchical reinforcement learning framework, the upper layer determines the interface call order, and the lower layer optimizes the single interface parameters. It is dynamically adjusted according to the response speed, user score, etc., to generate and optimize the interface call strategy, and achieve efficient and reasonable scheduling of interface resources.
[0166] The interface scheduling method provided in this embodiment closely coordinates all steps, from receiving a user request through deep semantic analysis, dynamic interface decision-making, and interface call execution. During interface call execution, independent interfaces are called in parallel. In the event of failure, a backup interface is switched based on the score, and an exponential backoff retry strategy is employed. These steps work together to ensure efficient and stable operation of intelligent interface calls using large language models.
[0167] In order to better understand the interface scheduling method provided in the embodiment of the present application, a specific application implementation method is described below.
[0168] like Figure 3 As shown, the interface scheduling method of this embodiment is executed by the electronic device, and the specific process is as follows:
[0169] S301: Receiving and transmitting user requests. Users submit natural language requests, such as "places suitable for strolling the kids on rainy days," through interactive devices such as computers, mobile phones, and smart speakers. The request data is quickly transmitted to the electronic device using HTTP / HTTPS. The electronic device supports multimodal input, including text, voice, and image input. Voice requests are converted to text using the Whisper model, while image requests use optical character recognition (OCR) technology to extract text.
[0170] S302, deep semantic analysis. The interface scheduling method integrates a large language model with a knowledge graph to perform deep semantic analysis. It adopts a dual-channel design, with the main channel responsible for processing user request text and the auxiliary channel for processing knowledge graph information. The main channel segments the user request text and extracts text semantic features. The auxiliary channel converts the information in the knowledge graph into vector form and integrates it with the text semantic features extracted by the main channel to deeply explore the potential needs in the user request. Electronic devices use a preset attention mechanism fusion algorithm to achieve precise matching of text semantics and information in the knowledge graph. In addition, for different fields, special adaptation parameters are loaded to fully utilize the basic capabilities of the large language model, extract common features of requests from different fields, and improve the ability to understand cross-domain requests.
[0171] S303, dynamic interface decision-making. Based on a multi-dimensional scoring model, the interface score is calculated for each interface by comprehensively considering the interface performance, historical effect score and business priority. The interface performance refers to the response delay and error rate of the interface, the historical effect score is based on the user score and the interface success rate, and the business priority is set according to the importance of the business. The model updates the interface score every 10 minutes. At the same time, with the help of a hierarchical reinforcement learning framework, the upper layer determines the order of interface calls based on the current system status, and the lower layer optimizes the call parameters of a single interface based on the upper layer decision and the system status. Based on factors such as interface response speed, user score and call cost, the model parameters are continuously adjusted to generate the optimal interface call strategy.
[0172] S304: Interface call execution. The target interface is called according to the established strategy, and the return data is obtained. For independent interfaces, the system uses parallel calls to reduce overall processing time. If an interface call fails, the system automatically switches to a backup interface based on the interface's score and retries using an exponential backoff strategy, with a maximum of three retries.
[0173] S305: Result fusion output. The data returned by the interface is integrated with the content generated by the large language model. Consistency checks and format conversions are performed on the data, and a natural language response is generated and fed back to the user via the interactive terminal. At the same time, the interface call details are recorded to facilitate subsequent tracing and analysis.
[0174] In this embodiment, accurately understanding user intent is the core of achieving efficient service. The overall process of this part is as follows: Figure 4 As shown in the figure, through the collaboration of a series of technologies, the limitations of traditional semantic understanding are broken, accurate analysis of complex user requests is achieved, and the accuracy of semantic parsing can be significantly improved.
[0175] First, a dual-channel input architecture was designed, with the primary and secondary channels receiving different data inputs. Using a Transformer encoder and a graph neural network, the user request text was integrated with the knowledge graph. This architecture primarily consists of three components: the primary channel, the secondary channel, and the output layer.
[0176] In the main channel, the user request text T is used as input, and the request text is segmented by the word segmenter to convert it into a word vector sequence X T =[x T1 ,x T2 ,…,x Tn Then, the word vector sequence is input into the Transformer encoder, which uses its powerful self-attention mechanism to analyze the word vector sequence, extract the key semantic features in the text, and generate the text semantic feature vector H T The auxiliary channel is responsible for processing the knowledge graph information. The knowledge graph consists of a node set N and an edge set E. Through the graph neural network, the knowledge graph entity is encoded into a graph entity vector X G =[x G1 ,x G2 ,…,x Gn The vectors H generated by the main and auxiliary channels are T and X G , according to the specific attention interaction mechanism, the fusion is performed to generate the fused feature vector H TG .
[0177] After interactive fusion, it enters the output layer and is fully connected to the fused feature vector H TG Map it into a requirement description Y with entity annotations to complete the analysis of user intent.
[0178] In order to further improve the accuracy of semantic parsing, a loss function is constructed based on deep semantic parsing: L = αL T +βL G. The meaning of the parameters is the same as that in the preset loss function in the aforementioned embodiment 2, and is used to determine the loss of entity alignment.
[0179] In addition, in order to reduce the training cost of domain-specific models and improve the semantic understanding ability of the model in different fields, the domain adapter module is introduced and a contrastive learning strategy is adopted. i , load the adaptation layer parameters θ i , fine-tune the large model parameter θ, the formula is: θ′=θ+λθ i , where λ is the fine-tuning coefficient. The contrastive learning strategy extracts the feature vector Z from the user request, maximizes the similarity of the feature vectors of the same request under different prediction versions through contrastive learning, and minimizes the similarity of the feature vectors of different requests.
[0180] Taking a user's request "Plan a food tour in a certain city" as an example, the main channel extracts key semantic features such as "city," "food," and "travel route" through a Transformer encoder. The auxiliary channel utilizes a graph neural network to retrieve information about a city's food courts, specialty restaurants, and popular attractions from the knowledge graph and fuses it with the main channel's feature vector. The output layer generates annotations such as "{Destination: city, Activity: food tour, Planning type: route}." During training, a preset loss function ensures that the model accurately matches the request text with relevant entities in the knowledge graph. When the model processes requests in the tourism domain, it loads parameters from the tourism adaptation layer to enhance its understanding of tourism-related concepts. A comparative learning strategy increases the similarity between the feature vectors of similar requests such as "Plan a food tour in a certain city" and "Explore a snack tour in a certain city," while decreasing the similarity between the feature vectors of different requests such as "Conduct business."
[0181] In the process of intelligent calling of large language model interface, it is crucial to properly call interface resources after accurately understanding the user's intention. To this end, this embodiment proposes a dynamic interface decision and resource optimization scheduling technology, namely the content of step S303. The specific process and details are as follows: Figure 5 This technology achieves accurate decision-making for interface calls and optimized resource allocation by building a multi-dimensional scoring model and a hierarchical reinforcement learning framework.
[0182] First, a multi-dimensional interface evaluation matrix is constructed to score the interfaces based on interface performance, historical effects, and business priorities to generate an interface score.
[0183] A hierarchical reinforcement learning (HRL) framework was built to optimize the interface call sequence and parameters. The upper-level policy network determines the interface call sequence, while the lower-level policy network optimizes the parameters of individual interfaces based on the interface call sequence determined by the upper layer. Ultimately, the interface call sequence and parameter optimization results are obtained.
[0184] For example, if a user requests a textile company to take an order for sportswear, the user's request text is "I need 500 pieces of a certain sportswear, style A, within one month." After recognizing the user's intention, the corresponding order instruction can be generated (the user and the company have signed a relevant agreement in advance, so that the user can be considered to have placed an order through request text recognition and the corresponding order instruction can be generated).
[0185] When a company receives an order instruction, it immediately triggers the task of "accepting the order, supplementing and improving the process documentation, and completing the order production." During the interface scoring phase, the 150ms response delay and 0.5% error rate of the process standard query interface are standardized and substituted into the formula to calculate the real-time performance score. The user rating of 4.8 points (out of 5) and the 95% interface success rate over the past year are standardized to calculate the historical performance score. Given the importance of orders to the company's collaboration with sportswear brands, the business priority is set high, which is then used to determine the interface score.
[0186] Based on information such as order style, quantity, and delivery time, the upper-level strategy network first calls the process standard query interface to retrieve the process standards for similar orders from the sports brand in the past. It then calls the process file generation interface to combine the standards with order information to generate a file. Finally, it calls the production execution interface to initiate production. The lower-level strategy network optimizes query parameters for the process standard query interface, such as limiting the query scope to sports top orders for the sports brand over the past three years. This reduces the amount of data retrieved and improves query efficiency. For the process file generation interface, template parameters are adjusted to ensure that the generated process files meet the sports brand's format requirements. For the production execution interface, production equipment parameters are appropriately set, such as adjusting the sewing machine's stitch length and speed, to improve product quality and production efficiency.
[0187] Example 3
[0188] like Figure 6 As shown, the interface scheduling device 400 provided in the embodiment of the present application may include:
[0189] The acquisition module 401 is used to acquire the user request text to be parsed.
[0190] The extraction module 402 is used to extract semantic features from the user request text and generate corresponding semantic feature vectors.
[0191] The generation module 403 is configured to generate a user intent parsing result corresponding to the user request text based on the semantic feature vector and the preset entity vector. The preset entity vector is generated by a preset graph neural network based on all entities of a preset knowledge graph.
[0192] The calling module 404 is used to call the corresponding target interface according to the user intention analysis result.
[0193] In some implementations, the extraction module 402 is specifically configured to:
[0194] The word segmenter in the large language model trained to convergence is used to segment the user request text and generate a corresponding word vector sequence. The encoder in the large language model is used to extract semantic features from the word vector sequence and generate a semantic feature vector.
[0195] In some implementations, the large language model is provided with knowledge domain-dependent adaptation layer parameters.
[0196] The generation module 403 is specifically used for:
[0197] The large language model is used to load the adaptation layer parameters corresponding to the semantic feature vector. Using the large language model loaded with the adaptation layer parameters, the semantic feature vector and the preset entity vector are input into the preset attention mechanism fusion algorithm. Based on the preset attention mechanism fusion algorithm, a fused target feature vector is generated. The target feature vector is mapped to the user intent analysis result.
[0198] In some implementations, there are multiple target interfaces.
[0199] The calling module 404 is specifically used to:
[0200] The upper-layer policy network, which uses a preset hierarchical reinforcement learning model, determines all target interfaces and the calling order of each target interface based on the user intent analysis results. The lower-layer policy network, which uses a preset hierarchical reinforcement learning model, calls each target interface in sequence according to the calling order.
[0201] In some embodiments, when the calling module 404 uses the upper-layer policy network of the preset hierarchical reinforcement learning model to determine all target interfaces and the calling order of each target interface according to the user intent analysis result, it is specifically configured to:
[0202] The upper-layer policy network determines the scoring parameters for multiple candidate interfaces based on the user intent analysis results. A corresponding interface score is determined based on the scoring parameters for each candidate interface. Based on the scores for each interface, all target interfaces are identified from all candidate interfaces. The order in which each target interface is called is determined based on the scoring parameters for each target interface.
[0203] In some implementations, the scoring-related parameters include interface performance, historical performance score, and service priority.
[0204] When determining a corresponding interface score based on the score-related parameters of each candidate interface, the calling module 404 is specifically configured to:
[0205] Calculate a first product between the interface performance and the first weight for each candidate interface. Calculate a second product between the historical performance score and the second weight for each candidate interface. Calculate a third product between the service priority and the third weight for each candidate interface. Sum the first, second, and third products for each candidate interface to generate a corresponding interface score.
[0206] When determining the calling order of each target interface according to the score-related parameters of each target interface, the calling module 404 is specifically used to:
[0207] The calling order of each target interface is generated in descending order according to the service priority corresponding to each target interface.
[0208] In some implementations, the interface scheduling apparatus 400 further includes:
[0209] A training module is used to obtain a training set. The training set includes historical request text, preset entity vectors, and actual user intent parsing results that match the historical request text. The preset large language model is trained based on the training set. The total loss during the training process is determined based on a preset loss function. The total loss includes text semantic loss and entity loss. The text semantic loss is the loss between the predicted text semantics and the actual text semantics corresponding to the historical request text. The entity loss is the loss between the predicted entity and the actual entity corresponding to the historical request text. Both the predicted entity and the actual entity are entities in the knowledge graph. If the total loss is less than the preset loss threshold, the preset large language model is determined to be the large language model trained to convergence.
[0210] The interface scheduling device provided in the embodiment of the present application has the beneficial effects and implementation methods of the interface scheduling methods provided in Examples 1 and 2 of the present application. For details, please refer to the specific description of the interface scheduling method in the above Examples 1 and 2, and this embodiment will not be repeated here.
[0211] Example 4
[0212] An embodiment of the present application further provides an electronic device, comprising:
[0213] Memory and processor.
[0214] Memory stores computer-executable instructions.
[0215] The processor executes the computer-executable instructions stored in the memory to implement the interface scheduling method of embodiment 1 and embodiment 2.
[0216] The electronic device provided in the embodiment of the present application has the beneficial effects and implementation methods of the interface scheduling methods of embodiment 1 and embodiment 2 of the present application. For details, please refer to the specific description of the interface scheduling method in the above embodiments 1 and embodiment 2, and this embodiment will not be repeated here.
[0217] Example 5:
[0218] This embodiment further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the interface scheduling method in the above-mentioned embodiment 1 or embodiment 2 is implemented.
[0219] The computer-readable storage medium provided in the embodiment of the present application has the beneficial effects and implementation methods of the interface scheduling methods of embodiments 1 and 2 of the present application. For details, please refer to the specific description of the interface scheduling method in the above embodiments 1 and 2, and this embodiment will not be repeated here.
[0220] Those skilled in the art will readily conceive of other implementations of the embodiments of the present application after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the embodiments of the present application, which follow the general principles of the embodiments of the present application and include common knowledge or customary technical means in the art not disclosed in the embodiments of the present application.
[0221] It is understood that the above embodiments are merely exemplary embodiments for illustrating the principles of the present application, and the present application is not limited thereto. Those skilled in the art may make various modifications and improvements without departing from the spirit and substance of the present application, and such modifications and improvements are also considered to be within the scope of protection of the present application.
Claims
1. An interface scheduling method, characterized in that: include: Get the user request text to be parsed; Extracting semantic features from the user request text and generating corresponding semantic feature vectors; Generating a user intention parsing result corresponding to the user request text according to the semantic feature vector and the preset entity vector; The preset entity vector is generated by a preset graph neural network based on all entities of a preset knowledge graph; The corresponding target interface is called according to the user intent analysis result.
2. The method according to claim 1, characterized in that The step of extracting semantic features from the user request text and generating corresponding semantic feature vectors includes: Using a word segmenter in a large language model trained to convergence to perform word segmentation on the user request text to generate a corresponding word vector sequence; The encoder in the large language model is used to extract semantic features from the word vector sequence to generate the semantic feature vector.
3. The method according to claim 2, characterized in that The large language model is provided with adaptation layer parameters related to the knowledge domain; Generating a user intention parsing result corresponding to the user request text according to the semantic feature vector and the preset entity vector includes: Using the large language model to load adaptation layer parameters corresponding to the semantic feature vector; Using the large language model loaded with adaptation layer parameters, the semantic feature vector and the preset entity vector are input into a preset attention mechanism fusion algorithm, and a fused target feature vector is generated based on the preset attention mechanism fusion algorithm; The target feature vector is mapped to the user intent analysis result.
4. The method according to claim 1, wherein There are multiple target interfaces; The calling of the corresponding target interface according to the user intent analysis result includes: An upper-layer strategy network of a preset hierarchical reinforcement learning model is used to determine all target interfaces and the calling order of each target interface according to the user intent analysis result; The lower layer strategy network of the preset hierarchical reinforcement learning model is used to call each of the target interfaces in sequence according to the calling order.
5. The method according to claim 4, characterized in that The upper-layer strategy network using the preset hierarchical reinforcement learning model determines all target interfaces and the calling order of each target interface according to the user intent analysis result, including: Determining score-related parameters of corresponding multiple candidate interfaces according to the user intent analysis result using the upper-layer strategy network; Determine a corresponding interface score based on the score-related parameters of each candidate interface; Determine all target interfaces from all candidate interfaces according to the scores of the interfaces; The calling order of each target interface is determined according to the score-related parameters of each target interface.
6. The method according to claim 5, characterized in that The scoring-related parameters include interface performance, historical effect score and service priority; Determining a corresponding interface score based on the score-related parameters of each candidate interface includes: Calculating a first product between the interface performance corresponding to each candidate interface and a first weight; Calculating a second product between the historical effect score corresponding to each candidate interface and the second weight; Calculating a third product between the service priority corresponding to each candidate interface and a third weight; Summing the first product, the second product, and the third product corresponding to each candidate interface to generate a corresponding interface score; The determining the calling order of each target interface according to the score-related parameters of each target interface includes: The calling order of each target interface is generated in descending order according to the service priority corresponding to each target interface.
7. The method according to claim 2, characterized in that Before performing word segmentation processing on the user request text using the word segmenter in the large language model trained to convergence to generate a corresponding word vector sequence, the method further includes: Obtaining a training set; the training set includes historical request text, the preset entity vector, and actual user intent parsing results matching the historical request text; Training a preset large language model based on the training set; Determine the total loss during the training process based on a preset loss function; the total loss includes text semantic loss and entity loss; the text semantic loss is the loss between the predicted text semantics and the actual text semantics corresponding to the historical request text; the entity loss is the loss between the predicted entity and the actual entity corresponding to the historical request text; the predicted entity and the actual entity are both entities of the knowledge graph; If the total loss is less than a preset loss threshold, it is determined that the preset large language model is the large language model trained to convergence.
8. An interface scheduling device, characterized in that: include: The acquisition module is used to obtain the user request text to be parsed; An extraction module, configured to extract semantic features from the user request text and generate corresponding semantic feature vectors; A generation module, configured to generate a user intent analysis result corresponding to the user request text based on the semantic feature vector and the preset entity vector; The preset entity vector is generated by a preset graph neural network based on all entities of a preset knowledge graph; The calling module is used to call the corresponding target interface according to the user intention analysis result.
9. An electronic device, characterized in that: include: memory and processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the interface scheduling method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the interface scheduling method according to any one of claims 1 to 7.