Model construction method and device based on model application scenario

By obtaining scene description information, identifying model construction intentions, matching lightweight models and tuning hardware resources, the problems of high cost of pre-trained large models and narrow application scope of lightweight models are solved, and a model suitable for complex scenarios is realized Build, reduces costs and improves the adaptability of the model.

CN118734697BActive Publication Date: 2024-12-17BEIJING HANBO TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410842320.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-27
Publication Date
2024-12-17
Estimated Expiration
2044-06-27

AI Technical Summary

Technical Problem

The existing pre-trained large models require a large amount of hardware resources due to large orders of magnitude model parameters, which leads to high implementation costs; while the lightweight models can only apply a single model application scenario, making it difficult to meet the needs of complex model application scenarios.

Method used

By obtaining a sequence of scene description information, identifying the model construction intention, matching the lightweight model, and assembling and tuning the model according to the hardware resource state, a model suitable for complex model application scenarios is generated.

Benefits of technology

On the premise of reducing the cost of model implementation, it meets the needs of complex model application scenarios and improves the usability and adaptability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118734697B_ABST
    Figure CN118734697B_ABST
Patent Text Reader

Abstract

The embodiments of the present disclosure disclose a model building method and device based on a model application scenario. A specific implementation of the method includes: obtaining a scene description information sequence; performing model building intent recognition on the scene description information to generate a model building intent; determining a first model that matches the model building intent according to the scene type and scene constraint information included in the model building intent; generating a model application logic chain that matches the model application scenario according to the scene description information sequence and the obtained first model sequence; assembling the first model in the first model sequence according to the model application logic chain; determining the first real-time hardware resource status; and optimizing the second model in response to the first real-time hardware resource status representing a low hardware resource availability state. This implementation can not only reduce the model implementation cost, but also meet the model requirements of complex model application scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present disclosure relate to the field of computer technology, and in particular to a model building method and device based on a model application scenario. Background Art

[0002] With the development of computer-related technologies, especially the advancement of research in the field of machine learning, neural network models have been rapidly applied to various industries. At present, in the process of model construction, there are usually two paths: one is to build a general pre-trained large model to achieve the application of different model application scenarios; the other is to build a dedicated lightweight model to achieve the application of a single model application scenario.

[0003] However, when the above method is adopted, the following technical problems often occur:

[0004] First, due to the large number of model parameters, pre-trained large models often require a large amount of hardware resources for model training, which results in high implementation costs.

[0005] Second, lightweight models can often only be applied to a single model application scenario. When there are more complex model application scenarios, it is difficult to match the model requirements of the complex model application scenarios. Summary of the invention

[0006] The content of this disclosure is used to introduce concepts in a brief form, which will be described in detail in the detailed implementation section below. The content of this disclosure is not intended to identify the key features or essential features of the technical solution claimed for protection, nor is it intended to limit the scope of the technical solution claimed for protection.

[0007] Some embodiments of the present disclosure propose a model construction method and device based on a model application scenario to solve one or more of the technical problems mentioned in the above background technology section.

[0008] In a first aspect, some embodiments of the present disclosure provide a model building method based on a model application scenario, the method comprising: obtaining a scene description information sequence, wherein the scene description information sequence represents multiple rounds of scene descriptions for the model application scenario initiated by a user; performing model building intent recognition on each scene description information in the scene description information sequence to generate a model building intent and obtain a model building intent sequence, wherein the model building intent in the model building intent sequence includes: scene type and scene constraint information; for each model building intent in the model building intent sequence, identifying the scene type and scene constraint information according to the scene type and scene constraint information included in the model building intent According to the scenario constraint information, determine the first model that matches the above-mentioned model construction intention; according to the above-mentioned scenario description information sequence and the obtained first model sequence, generate a model application logic chain that matches the above-mentioned model application scenario; according to the above-mentioned model application logic chain, assemble the first model in the above-mentioned first model sequence to generate a second model; determine a first real-time hardware resource state, wherein the above-mentioned first real-time hardware resource state represents a real-time resource availability state of the hardware resources used to run the above-mentioned second model; in response to the above-mentioned first real-time hardware resource state representing a low hardware resource availability state, perform model tuning on the above-mentioned second model to generate a tuned second model.

[0009] In a second aspect, some embodiments of the present disclosure provide a model building device based on a model application scenario, the device comprising: an acquisition unit, configured to acquire a scene description information sequence, wherein the scene description information sequence represents multiple rounds of scene descriptions for the model application scenario initiated by a user; a model building intention recognition unit, configured to perform model building intention recognition on each scene description information in the scene description information sequence to generate a model building intention and obtain a model building intention sequence, wherein the model building intention in the model building intention sequence includes: scene type and scene constraint information; a first determination unit, configured to, for each model building intention in the model building intention sequence, identify the scene type and scene constraint information included in the model building intention; information, determining a first model that matches the above-mentioned model building intention; a generating unit, configured to generate a model application logic chain that matches the above-mentioned model application scenario according to the above-mentioned scenario description information sequence and the obtained first model sequence; a model assembling unit, configured to perform model assembly on the first model in the above-mentioned first model sequence according to the above-mentioned model application logic chain to generate a second model; a second determining unit, configured to determine a first real-time hardware resource state, wherein the above-mentioned first real-time hardware resource state represents a real-time resource availability state of hardware resources for running the above-mentioned second model; a model tuning unit, configured to perform model tuning on the above-mentioned second model in response to the above-mentioned first real-time hardware resource state representing a low hardware resource availability state to generate a tuned second model.

[0010] In a third aspect, some embodiments of the present disclosure provide an electronic device comprising: one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation manner of the above-mentioned first aspect.

[0011] In a fourth aspect, some embodiments of the present disclosure provide a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the method described in any implementation manner of the above-mentioned first aspect is implemented.

[0012] The above-mentioned embodiments of the present disclosure have the following beneficial effects: through the model construction method based on the model application scenario of some embodiments of the present disclosure, the model requirements of complex model application scenarios can be met while reducing the model implementation cost. Specifically, the reasons for the high implementation cost and the inability to meet the model requirements of complex model application scenarios are: first, due to the large number of model parameters, the pre-trained large model often needs to match a large amount of hardware resources for model training, and the implementation cost is high; second, the lightweight model can often only be applied to a single model application scenario. When there is a more complex model application scenario, it is difficult to match the model requirements of the complex model application scenario. Based on this, the model construction method based on the model application scenario of some embodiments of the present disclosure, first, obtains a scene description information sequence, wherein the above-mentioned scene description information sequence represents the scene description of multiple rounds of model application scenarios initiated by the user. In this way, the user's scene description for the model application scenario is obtained. Secondly, the model construction intention is identified for each scene description information in the above-mentioned scene description information sequence to generate a model construction intention and obtain a model construction intention sequence, wherein the model construction intention in the above-mentioned model construction intention sequence includes: scene type and scene constraint information. In this way, multiple model building intentions of the user are obtained. Then, for each model building intention in the above-mentioned model building intention sequence, according to the scenario type and scenario constraint information included in the above-mentioned model building intention, the first model matching the above-mentioned model building intention is determined. In this way, a lightweight first model matching the model building intention is matched. Further, according to the above-mentioned scenario description information sequence and the obtained first model sequence, a model application logic chain matching the above-mentioned model application scenario is generated. In this way, the application logic between the first models corresponding to different model application scenarios is obtained. In addition, according to the above-mentioned model application logic chain, the first model in the above-mentioned first model sequence is model assembled to generate a second model. In this way, the automatic assembly of multiple lightweight models for complex model application scenarios is realized. Then, the first real-time hardware resource state is determined, wherein the above-mentioned first real-time hardware resource state represents the real-time resource availability state of the hardware resources used to run the above-mentioned second model. Finally, in response to the above-mentioned first real-time hardware resource state representing the low hardware resource availability state, the above-mentioned second model is model tuned to generate a tuned second model. When the available hardware resources are less, the second model is further model tuned to improve the availability of the model. In this way, the model implementation cost can be reduced while meeting the model requirements of complex model application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that components and elements are not necessarily drawn to scale.

[0014] Figure 1 is a flow chart of some embodiments of a model building method based on a model application scenario according to the present disclosure;

[0015] Figure 2 It is a structural schematic diagram of some embodiments of a model building device based on a model application scenario according to the present disclosure;

[0016] Figure 3 It is a schematic diagram of the structure of an electronic device suitable for implementing some embodiments of the present disclosure. DETAILED DESCRIPTION

[0017] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0018] It should also be noted that, for ease of description, only the parts related to the invention are shown in the drawings. In the absence of conflict, the embodiments and features in the embodiments of the present disclosure can be combined with each other.

[0019] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0020] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0021] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0022] The present disclosure will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.

[0023] refer to Figure 1, shows a process 100 of some embodiments of a model building method based on a model application scenario according to the present disclosure. The model building method based on a model application scenario comprises the following steps:

[0024] Step 101: Obtain a scene description information sequence.

[0025] In some embodiments, the execution subject (e.g., computing device) of the model construction method based on the model application scenario can obtain the above-mentioned scene description information sequence through a wired connection or a wireless connection. The above-mentioned scene description information sequence represents multiple rounds of scene descriptions for the model application scenario initiated by the user. In practice, the scene description information can be a scene description for the model application scenario generated by the above-mentioned execution subject and the user in a question-and-answer manner.

[0026] As an example, a scenario description information sequence may be [“automatic execution of customer service through dialogue understanding and sentiment analysis”, “decision support through decision intent recognition and data analysis”, “feedback of the top K optimal results based on multiple decision results”].

[0027] It should be noted that the above-mentioned wireless connection methods may include but are not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or developed in the future.

[0028] It should be noted that the above-mentioned computing device can be hardware or software. When the computing device is hardware, it can be implemented as a distributed cluster consisting of multiple servers or terminal devices, or it can be implemented as a single server or a single terminal device. When the computing device is embodied as software, it can be installed in the hardware devices listed above. It can be implemented as multiple software or software modules for providing distributed services, for example, or it can be implemented as a single software or software module. No specific limitation is made here.

[0029] Step 102: Perform model building intent recognition on each scene description information in the scene description information sequence to generate a model building intent and obtain a model building intent sequence.

[0030] In some embodiments, the execution subject may identify the model building intention for each scene description information in the scene description information sequence to generate a model building intention and obtain a model building intention sequence. The model building intention in the model building intention sequence includes: scene type and scene constraint information. The scene type characterizes the scene type of the model application scene. The scene constraint information may be information extracted from the scene description information that limits the model corresponding to the scene description information. For example, the scene constraint information may include but is not limited to: model function limitation, model structure limitation, model input and output limitation, etc. The model function limitation may be the function of limiting the model. In practice, for the same model structure, training with different training samples can obtain a machine learning model with the same model structure but different model functions. The model structure limitation is used to limit the model structure of the model. In practice, for the same model usage requirements, machine learning models with different model structures can be used to implement it. Therefore, the model structure limitation may be limited to: the model structure of the model, the hardware resource requirements when the model is running, etc. The model input and output limitation is used to limit the input and output of the model to ensure that the input and output of the model are valid. In practice, the above-mentioned execution entity can use the intent recognition model to perform model building intent recognition on the scene description information to generate the model building intent. Specifically, the intent recognition model can be an ALBERT model, which reduces the computational complexity and model size of the model compared to the BERT model.

[0031] In some optional implementations of some embodiments, the execution subject performs model building intent recognition on each scene description information in the scene description information sequence to generate a model building intent, which may include the following steps:

[0032] In the first step, the scene description information is segmented into sentence granularity to generate scene description sentences and obtain a scene description sentence sequence.

[0033] In practice, for example, the execution subject can implement the sentence granularity segmentation of the scene description information based on statistical rules, such as through the sent_tokenize() function in the NLTK library. For another example, the execution subject can also implement the sentence granularity segmentation of the scene description information based on punctuation marks, such as through the Split() function.

[0034] In the second step, semantic features are extracted for each scene description sentence in the above scene description sentence sequence to generate semantic features and obtain a semantic feature sequence.

[0035] In practice, the above-mentioned execution subject can realize semantic feature extraction of scene description sentences through a semantic feature extraction model to generate semantic features. Specifically, the semantic feature extraction model may include: an input layer, 7 hidden layers and an output layer. The semantic feature extraction model adopts the model architecture of a recurrent neural network model.

[0036] The third step is to generate a semantic association value matrix based on the above semantic feature sequence.

[0037] Among them, the matrix size of the above semantic association value matrix is ​​M×M. M is the number of semantic features in the semantic feature sequence. The semantic association values ​​on the matrix diagonal and the semantic association values ​​below the matrix diagonal in the above semantic association value matrix are 0. The semantic association values ​​above the matrix diagonal in the above semantic association value matrix represent the semantic association between the corresponding two semantic features. The semantic association values ​​above the matrix diagonal in the above semantic association value matrix are greater than or equal to 0. In practice, since the semantic features in the semantic feature sequence are all generated by the same semantic feature extraction model, that is, it can be understood that the semantic features in the semantic feature sequence are located in the same feature space, therefore, the above execution subject can determine the semantic association value between every two semantic features by calculating the cosine similarity. Specifically, since the semantic association value between semantic feature A and semantic feature B is the same as the semantic association value between semantic feature B and semantic feature A, in order to avoid repeated calculations, the semantic association value below the matrix diagonal in the constructed semantic association value matrix is ​​0. In addition, the semantic association value between semantic feature A and semantic feature A is meaningless, therefore, the semantic association value on the matrix diagonal in the semantic association value matrix is ​​also 0.

[0038] The fourth step is to adjust the feature order of the semantic features in the semantic feature sequence according to the upper triangular matrix in the semantic association value matrix to generate an adjusted semantic feature sequence.

[0039] In practice, the execution subject may adjust the position of the semantic feature in the semantic feature sequence according to the size of the semantic association value, so as to ensure that the semantic association value corresponding to the path corresponding to the final semantic feature sequence is the maximum.

[0040] As an example, the semantic feature sequence can be [semantic feature A, semantic feature B, semantic feature C]. Then the matrix size of the semantic association value matrix is ​​3×3. Among them, [[0, 0.8, 0.9], [0, 0, 0.98], [0, 0, 0]], where 0.8 represents the semantic association value of semantic feature A and semantic feature B. 0.9 represents the semantic association value of semantic feature A and semantic feature C. 0.98 represents the semantic association value of semantic feature B and semantic feature C. Then semantic feature A->semantic feature B->semantic feature C, the sum of the semantic association values ​​of the corresponding path = 0.8+0.98. The adjusted semantic feature sequence can be: semantic feature A->semantic feature C->semantic feature B, the sum of the semantic association values ​​of the corresponding path = 0.9+0.98. By adjusting the position of semantic features in the sequence according to the semantic association value, we can avoid the problem of feature forgetting caused by a large distance between semantic features with association when there are many semantic features. At the same time, we ensure that the positions of semantic features under approximate semantics are close, so as to extract features between associated features.

[0041] The fifth step is to build an intent recognition model based on the adjusted semantic feature sequence and the pre-trained model to generate the model building intent corresponding to the scene description information.

[0042] The model construction intention recognition model includes: a scene type classification model and a scene constraint information extraction model. The scene type classification model is used to generate scene types. The scene constraint information extraction model is used to generate scene constraint information.

[0043] In practice, the scene type classification model can be implemented using a fully connected layer. The scene constraint information extraction model can also use the ALBERT model. Specifically, since the intent recognition model processes a single scene description information, the features processed by the scene constraint information extraction model are also extracted from the scene description information. Therefore, the scene constraint information extraction model can reuse the feature extraction part of the intent recognition model.

[0044] Step 103: for each model building intention in the model building intention sequence, determine the first model matching the model building intention according to the scene type and scene constraint information included in the model building intention.

[0045] In some embodiments, the above-mentioned execution subject determines the first model that matches the model building intent for each model building intent in the model building intention sequence according to the scenario type and scenario constraint information included in the model building intent. Among them, the first model can be a machine learning model in the model library that meets the model building intent. The model library can be used to store trained machine learning models. Specifically, the constant type of the model application scenario corresponding to the first model is the same as the scenario type included in the building intent. The first model satisfies the scenario constraint information included in the model building intent. In practice, the same model structure, trained with different training samples, may correspond to different model application scenarios, so the scenario type needs to be constrained. In addition, for the same model application scenario, the model input, output, structure, etc. of different machine learning models are also different, so they need to be constrained by scenario constraint information.

[0046] In some optional implementations of some embodiments, the execution subject determines the first model matching the model building intention according to the scene type and scene constraint information included in the model building intention, which may include the following steps:

[0047] The first step is to determine the model library that matches the scenario types included in the above model building intention.

[0048] Among them, the above-mentioned model library is used to store machine learning models that have completed model training.

[0049] The second step is to obtain the meta-model information corresponding to the above model library.

[0050] Among them, the above-mentioned meta-model information includes: a model description information set. The model description information in the above-mentioned model description information set represents the model description corresponding to the machine learning model stored in the above-mentioned model library, and the model description information includes: model structure description information, model performance description information and model usage restriction description information. The model structure description information is used to describe the model architecture of the machine learning model. The model performance description information is used to describe the model performance of the machine learning, such as prediction accuracy, etc. The model usage restriction description information is used to describe the input, output, hardware requirements and other information of the machine learning model.

[0051] The third step is to generate a model description feature for each model description information in the above model description information set according to the model structure description information, model performance description information and model usage restriction description information included in the above model description information.

[0052] In practice, the above-mentioned execution entity can generate model description features through word embedding according to the model structure description information, model performance description information and model usage restriction description information included in the above-mentioned model description information.

[0053] The fourth step is to generate scene constraint features based on the above scene constraint information.

[0054] In practice, the execution subject can also generate the scene constraint features by word embedding, thereby mapping the model description features and the scene constraint features to the same feature space.

[0055] In the fifth step, based on the above scenario constraint features and the obtained model description feature set, the model description information that meets the screening conditions is screened out from the above model description information set as the target model description information.

[0056] The above screening condition is: the feature similarity between the scene constraint feature and the model description feature is the largest.

[0057] In the sixth step, the machine learning model corresponding to the target model description information is determined as the first model that matches the above model construction intention.

[0058] Step 104: Generate a model application logic chain matching the model application scenario according to the scenario description information sequence and the obtained first model sequence.

[0059] In some embodiments, the execution subject may generate a model application logic chain matching the model application scenario according to the scenario description information sequence and the obtained first model sequence, wherein the model application logic chain represents the usage order between the first model sequences.

[0060] In some optional implementations of some embodiments, the execution subject generates a model application logic chain matching the model application scenario according to the scenario description information sequence and the obtained first model sequence, which may include the following steps:

[0061] The first step is to generate a model node set according to the above first model sequence.

[0062] There is a one-to-one correspondence between the first model and the model nodes.

[0063] As an example, the first model sequence includes: a first model A, a first model B, and a first model C. Then the generated model node set includes: model node A, model node B, and model node C.

[0064] In the second step, data flow features are extracted from the scene description information in the above scene description information set to generate initial data flow edges and obtain an initial data flow edge set.

[0065] In practice, since each scene description information corresponds to an adjusted semantic feature sequence. Therefore, the above-mentioned execution entity can determine whether there is a data flow edge between the scene description information and the direction of the data flow edge through the data flow classification model. Specifically, the data flow classification model adopts the GAN model architecture. That is, the data flow classification model first determines the correlation between the adjusted semantic feature sequences corresponding to the two scene description information in the semantic order. When the correlation is greater than 0, the correlation direction of the two adjusted semantic feature sequences is determined by a 2-classifier. When the correlation direction is positive, the corresponding data flow edge is characterized as positive. When the correlation direction is reverse, the corresponding data flow edge is characterized as reverse.

[0066] As an example, scenario description information A is "first identify customer intent through sentiment analysis and conversation understanding". Scenario description information B is "based on the sentiment analysis results, decision support is achieved through decision intent identification and data analysis". Scenario description information C is "when the user's emotions change, re-perform sentiment analysis and conversation understanding to identify customer intent". Among them, scenario description information A corresponds to model node A. Scene description information B corresponds to model node B. Scene description information C corresponds to model node C. Therefore, the obtained initial flow edge includes: the data flow edge from model node A to model node B. The data flow edge from model node B to model node C. The data flow edge from model node C to model node B. Among them, the data flow edge from model node C to model node B is valid when the user's emotions change.

[0067] The third step is to update the edge node of each initial data flow edge in the above initial data flow edge set according to the model description information of the first model corresponding to the model node to generate an updated data flow edge and obtain an updated data flow edge set.

[0068] The updated data flow edge represents the data flow between two model nodes. In practice, the execution subject can align the input and output between the model nodes that have a connection relationship according to the model usage restriction description information included in the model description information.

[0069] The fourth step is to generate the above model application logic chain based on the above updated data flow edge set and the above model node set.

[0070] In practice, the initial data flow direction edge can be stored in the form of a tuple. The tuple includes (starting model node, ending model node), which indicates that there is a directed edge from the starting model node to the ending model node.

[0071] Step 105: assemble the first model in the first model sequence according to the model application logic chain to generate a second model.

[0072] In some embodiments, the execution subject may assemble the first model in the first model sequence according to the model application logic chain to generate the second model. In practice, the execution subject may control the order of using the first model in the first model sequence according to the model application logic chain to achieve the purpose of virtually assembling the first model and thereby obtain the second model.

[0073] Step 106, determining a first real-time hardware resource state.

[0074] In some embodiments, the execution subject may determine a first real-time hardware resource state. The first real-time hardware resource state represents the real-time resource availability state of the hardware resources used to run the second model. In practice, the execution subject may scan the current state of the hardware resources used to run the second model to obtain the first real-time hardware resource state. In practice, the first real-time hardware resource state may include: CPU (Central Processing Unit) state, GPU (Graphic Processing Unit) state, cluster state, etc. Specifically, when the second model is run in a cluster mode, each cluster node may respond to the CPU state and GPU state.

[0075] Step 107 : In response to the first real-time hardware resource status indicating a low hardware resource availability state, perform model tuning on the second model to generate a tuned second model.

[0076] In some embodiments, the execution subject may perform model tuning on the second model in response to the first real-time hardware resource status representing a low hardware resource availability state to generate a tuned second model. In practice, the execution subject may delay loading of the first model in the second model that requires a start condition to achieve model optimization and obtain the tuned second model.

[0077] For example, the second model includes: a first model A and a first model B. The execution of the first model B is performed on the premise that the output result of the first model A meets the conditions. Therefore, the first model B can delay loading to reduce the data volume in the cache during loading, so as to achieve the purpose of model tuning.

[0078] In some optional implementations of some embodiments, the execution subject performs model tuning on the second model in response to the first real-time hardware resource status representing a low hardware resource availability state to generate a tuned second model, which may include the following steps:

[0079] The first step is to determine the resource occupancy information and model importance of each first model in the first model sequence.

[0080] The model importance is determined by the position of the first model in the above-mentioned model application logic chain. In practice, for example, the closer the position of the first model in the model application logic chain is, the higher the model importance is. For another example, when the sum of the out-degree and in-degree of the model node corresponding to the first model in the model application logic chain is higher, the model importance is higher. The resource occupancy information of the first model represents the computing resources required by the first model when it runs alone.

[0081] In the second step, according to the tuning strategy information corresponding to the first real-time hardware resource status, the first model in the second model whose corresponding resource occupancy information and model importance meet the tuning conditions is replaced to generate a candidate second model.

[0082] Among them, the policy type of the tuning policy information may include: resource priority and performance priority. In practice, when the policy type of the tuning policy information is resource priority, the tuning condition may be: for the first model with lower model importance and higher computing resource occupancy corresponding to resource occupancy information, replace it with a model with the same function but lower computing resource occupancy. When the policy type of the tuning policy information is performance priority, the tuning condition may be: for the first model with higher model importance, replace it with a model with the same function but better model performance.

[0083] The third step is to determine the second real-time hardware resource status.

[0084] The second real-time hardware resource availability status represents the real-time resource availability status of the hardware resources used to run the second candidate model.

[0085] In the fourth step, in response to the second real-time hardware resource state being a low hardware resource available state, the candidate second model is pruned to obtain the optimized second model.

[0086] In practice, the execution subject can prune the first model in the candidate second model that requires a startup condition to be executed, that is, delay the time of loading into the cache to avoid the problem of insufficient cache caused by loading all the second models into the cache.

[0087] In a fifth step, in response to the second real-time hardware resource state being a non-low hardware resource available state, the candidate second model is determined as the optimized second model.

[0088] In some optional implementations of some embodiments, the above method further includes:

[0089] The first step is to obtain query information.

[0090] The query information may be query information input by a user after the second model or the optimized second model is deployed, such as a function query for a certain model of equipment.

[0091] The second step is to determine the service scenario corresponding to the above query information.

[0092] In practice, the above execution status can determine the service scenario corresponding to the above query information through the intent recognition model.

[0093] The third step is to determine whether there is a query result matching the query information in the question and answer library in response to the service scenario being the same as the model application scenario.

[0094] In practice, the Q&A database can be a pre-built Q&A knowledge base that matches the service scenario. Specifically, the Q&A database is first used to determine if the database exists, and the query result can be fed back, thereby improving the response speed and avoiding computing resource usage caused by model loading as much as possible.

[0095] The fourth step is to feed back the query result matching the query information to the client that sent the query information in response to the existence.

[0096] Step 5: In response to non-existence, generate a query result corresponding to the query information according to the second model or the optimized second model.

[0097] In practice, the execution entity may input the query information into the second model or the optimized second model to generate the query result.

[0098] In some optional implementations of some embodiments, the above method further includes:

[0099] The first step is to construct a question-answer pair based on the above query results and the above query information.

[0100] In practice, the execution subject may construct a question-answer pair in the form of a QA pair, where Q corresponds to query information and A corresponds to query results. In practice, the question-answer pair may be stored in the form of a binary tuple.

[0101] The second step is to store the above question and answer pairs in the above question and answer database.

[0102] In practice, for example, the execution subject may store the question-answer pairs in the question-answer database in real-time. For another example, the execution subject may also use a delayed update method, such as storing the question-answer pairs in the question-answer database after accumulating a certain number of question-answer pairs. For another example, the question-answer pairs are stored in the question-answer database at a fixed time, such as 00:00 in the morning.

[0103] The above-mentioned embodiments of the present disclosure have the following beneficial effects: through the model construction method based on the model application scenario of some embodiments of the present disclosure, the model requirements of complex model application scenarios can be met while reducing the model implementation cost. Specifically, the reasons for the high implementation cost and the inability to meet the model requirements of complex model application scenarios are: first, due to the large number of model parameters, the pre-trained large model often needs to match a large amount of hardware resources for model training, and the implementation cost is high; second, the lightweight model can often only be applied to a single model application scenario. When there is a more complex model application scenario, it is difficult to match the model requirements of the complex model application scenario. Based on this, the model construction method based on the model application scenario of some embodiments of the present disclosure, first, obtains a scene description information sequence, wherein the above-mentioned scene description information sequence represents the scene description of multiple rounds of model application scenarios initiated by the user. In this way, the user's scene description for the model application scenario is obtained. Secondly, the model construction intention is identified for each scene description information in the above-mentioned scene description information sequence to generate a model construction intention and obtain a model construction intention sequence, wherein the model construction intention in the above-mentioned model construction intention sequence includes: scene type and scene constraint information. In this way, multiple model building intentions of the user are obtained. Then, for each model building intention in the above-mentioned model building intention sequence, according to the scenario type and scenario constraint information included in the above-mentioned model building intention, the first model matching the above-mentioned model building intention is determined. In this way, a lightweight first model matching the model building intention is matched. Further, according to the above-mentioned scenario description information sequence and the obtained first model sequence, a model application logic chain matching the above-mentioned model application scenario is generated. In this way, the application logic between the first models corresponding to different model application scenarios is obtained. In addition, according to the above-mentioned model application logic chain, the first model in the above-mentioned first model sequence is model assembled to generate a second model. In this way, the automatic assembly of multiple lightweight models for complex model application scenarios is realized. Then, the first real-time hardware resource state is determined, wherein the above-mentioned first real-time hardware resource state represents the real-time resource availability state of the hardware resources used to run the above-mentioned second model. Finally, in response to the above-mentioned first real-time hardware resource state representing the low hardware resource availability state, the above-mentioned second model is model tuned to generate a tuned second model. When the available hardware resources are less, the second model is further model tuned to improve the availability of the model. In this way, the model implementation cost can be reduced while meeting the model requirements of complex model application scenarios.

[0104] Further references Figure 2 As an implementation of the methods shown in the above figures, the present disclosure provides some embodiments of a model building device based on a model application scenario. These device embodiments are similar to Figure 1Corresponding to the method embodiments shown, the model building device based on the model application scenario can be specifically applied to various electronic devices.

[0105] like Figure 2 As shown, some embodiments of the model building device 200 based on the model application scenario include: an acquisition unit 201, a model building intention recognition unit 202, a first determination unit 203, a generation unit 204, a model assembly unit 205, a second determination unit 206 and a model tuning unit 207. The acquisition unit 201 is configured to acquire a scene description information sequence, wherein the scene description information sequence represents multiple rounds of scene descriptions for the model application scenario initiated by the user; the model building intention recognition unit 202 is configured to perform model building intention recognition on each scene description information in the scene description information sequence to generate a model building intention and obtain a model building intention sequence, wherein the model building intention in the model building intention sequence includes: scene type and scene constraint information; the first determination unit 203 is configured to determine, for each model building intention in the model building intention sequence, a first model matching the model building intention according to the scene type and scene constraint information included in the model building intention. ; The generation unit 204 is configured to generate a model application logic chain matching the above-mentioned model application scenario according to the above-mentioned scenario description information sequence and the obtained first model sequence; the model assembly unit 205 is configured to perform model assembly on the first model in the above-mentioned first model sequence according to the above-mentioned model application logic chain to generate a second model; the second determination unit 206 is configured to determine a first real-time hardware resource state, wherein the above-mentioned first real-time hardware resource state represents a real-time resource availability state of the hardware resources used to run the above-mentioned second model; the model tuning unit 207 is configured to perform model tuning on the above-mentioned second model in response to the above-mentioned first real-time hardware resource state representing a low hardware resource availability state to generate a tuned second model.

[0106] It can be understood that the units recorded in the model construction device 200 based on the model application scenario are similar to the reference Figure 1 Therefore, the operations, features and beneficial effects described above for the method are also applicable to the model building device 200 based on the model application scenario and the units contained therein, and will not be described in detail here.

[0107] Reference below Figure 3 , which shows a structural schematic diagram of an electronic device (eg, a computing device) 300 suitable for implementing some embodiments of the present disclosure. Figure 3 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0108] like Figure 3 As shown, the electronic device 300 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 301, which can perform various appropriate actions and processes according to a program stored in a read-only memory 302 or a program loaded from a storage device 308 into a random access memory 303. Various programs and data required for the operation of the electronic device 300 are also stored in the random access memory 303. The processing device 301, the read-only memory 302, and the random access memory 303 are connected to each other via a bus 304. An input / output interface 305 is also connected to the bus 304.

[0109] Typically, the following devices may be connected to the I / O interface 305: input devices 306 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 307 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 308 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 309. The communication devices 309 may allow the electronic device 300 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 3 The electronic device 300 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead. Figure 3 Each block shown in the figure may represent one device, or may represent multiple devices as required.

[0110] In particular, according to some embodiments of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, some embodiments of the present disclosure include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In some such embodiments, the computer program can be downloaded and installed from the network through the communication device 309, or installed from the storage device 308, or installed from the read-only memory 302. When the computer program is executed by the processing device 301, the above-mentioned functions defined in the method of some embodiments of the present disclosure are executed.

[0111] It should be noted that the computer-readable medium recorded in some embodiments of the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In some embodiments of the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In some embodiments of the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0112] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (Hyper Text Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0113] The above-mentioned computer-readable medium may be included in the above-mentioned electronic device; or it may exist independently without being installed in the electronic device. The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: obtains a scene description information sequence, wherein the above-mentioned scene description information sequence represents multiple rounds of scene descriptions for model application scenarios initiated by the user; performs model building intent recognition on each scene description information in the above-mentioned scene description information sequence to generate a model building intent and obtain a model building intent sequence, wherein the model building intent in the above-mentioned model building intent sequence includes: scene type and scene constraint information; for each model building intent in the above-mentioned model building intention sequence, according to the scene description information included in the above-mentioned model building intention According to the scene type and scene constraint information, determine the first model that matches the above-mentioned model construction intention; according to the above-mentioned scene description information sequence and the obtained first model sequence, generate a model application logic chain that matches the above-mentioned model application scenario; according to the above-mentioned model application logic chain, assemble the first model in the above-mentioned first model sequence to generate a second model; determine a first real-time hardware resource state, wherein the above-mentioned first real-time hardware resource state represents the real-time resource availability state of the hardware resources used to run the above-mentioned second model; in response to the above-mentioned first real-time hardware resource state representing the low hardware resource availability state, model tune the above-mentioned second model to generate a tuned second model.

[0114] Computer program code for performing the operations of some embodiments of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0115] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0116] The units described in some embodiments of the present disclosure may be implemented by software or by hardware. The described units may also be provided in a processor, for example, may be described as: a processor including an acquisition unit, a model building intention recognition unit, a first determination unit, a generation unit, a model assembly unit, a second determination unit, and a model tuning unit. Among them, the names of these units do not constitute a limitation on the unit itself under certain circumstances. For example, the model tuning unit may also be described as "a unit that performs model tuning on the above-mentioned second model in response to the above-mentioned first real-time hardware resource status representing a low hardware resource availability state to generate a tuned second model".

[0117] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0118] The above descriptions are only some preferred embodiments of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present disclosure is not limited to the technical solutions formed by a specific combination of the above-mentioned technical features, but should also cover other technical solutions formed by any combination of the above-mentioned technical features or their equivalent features without departing from the above-mentioned inventive concept. For example, the above-mentioned features are replaced with the technical features with similar functions disclosed in the embodiments of the present disclosure (but not limited to) and the technical solutions formed.

Claims

1. A model construction method based on a model application scenario, comprising: Acquire a scene description information sequence, wherein the scene description information sequence represents multiple rounds of scene descriptions for model application scenarios initiated by a user; Performing model building intent recognition on each scene description information in the scene description information sequence to generate a model building intent and obtain a model building intent sequence, wherein the model building intent in the model building intent sequence includes: scene type and scene constraint information; For each model building intention in the model building intention sequence, determining a first model matching the model building intention according to the scene type and scene constraint information included in the model building intention; Generating a model application logic chain matching the model application scenario according to the scenario description information sequence and the obtained first model sequence; According to the model application logic chain, assembling the first model in the first model sequence to generate a second model; Determine a first real-time hardware resource state, wherein the first real-time hardware resource state represents a real-time resource availability state of hardware resources used to run the second model; In response to the first real-time hardware resource state representing a low hardware resource availability state, performing model tuning on the second model to generate a tuned second model; Get query information; Determining a service scenario corresponding to the query information; In response to the service scenario being the same as the model application scenario, determining whether there is a query result matching the query information in the question and answer library; In response to existence, feeding back a query result matching the query information to the client sending the query information; In response to the absence of the query information, generating a query result corresponding to the query information according to the second model or the tuned second model; Constructing a question-answer pair according to the query result and the query information; The question-answer pair is stored in the question-answer library.

2. The method according to claim 1, wherein: The performing model building intent recognition on each scene description information in the scene description information sequence to generate a model building intent includes: Segmenting the scene description information into sentence granularity to generate scene description sentences and obtain a scene description sentence sequence; Extracting semantic features from each scene description sentence in the scene description sentence sequence to generate semantic features and obtain a semantic feature sequence; Generate a semantic association value matrix according to the semantic feature sequence, wherein the matrix size of the semantic association value matrix is ​​M×M, M is the number of semantic features in the semantic feature sequence, the semantic association values ​​on the matrix diagonal and the semantic association values ​​below the matrix diagonal in the semantic association value matrix are 0, the semantic association values ​​above the matrix diagonal in the semantic association value matrix represent the semantic association degree of the corresponding two semantic features, and the semantic association values ​​above the matrix diagonal in the semantic association value matrix are greater than or equal to 0; According to the upper triangular matrix in the semantic association value matrix, the feature order of the semantic features in the semantic feature sequence is adjusted to generate an adjusted semantic feature sequence; An intention recognition model is constructed according to the adjusted semantic feature sequence and a pre-trained model to generate a model construction intention corresponding to the scene description information, wherein the model construction intention recognition model includes: a scene type classification model and a scene constraint information extraction model, the scene type classification model is used to generate a scene type, and the scene constraint information extraction model is used to generate scene constraint information.

3. The method according to claim 2, wherein: The determining, according to the scene type and scene constraint information included in the model building intention, a first model matching the model building intention comprises: Determine a model library that matches the scenario type included in the model building intention, wherein the model library is used to store machine learning models that have completed model training; Obtaining metamodel information corresponding to the model library, wherein the metamodel information includes: a model description information set, the model description information in the model description information set represents the model description corresponding to the machine learning model stored in the model library, and the model description information includes: model structure description information, model performance description information, and model use restriction description information; For each piece of model description information in the model description information set, generating a model description feature according to the model structure description information, the model performance description information and the model use restriction description information included in the model description information; generating a scene constraint feature according to the scene constraint information; According to the scene constraint feature and the obtained model description feature set, the model description information satisfying the screening condition is screened out from the model description information set as the target model description information; The machine learning model corresponding to the target model description information is determined as the first model that matches the model building intention.

4. The method according to claim 3, wherein: The step of generating a model application logic chain matching the model application scenario according to the scenario description information sequence and the obtained first model sequence includes: Generate a model node set according to the first model sequence; Extracting data flow features from the scene description information in the scene description information set to generate initial data flow edges, thereby obtaining an initial data flow edge set; According to the model description information of the first model corresponding to the model node, each initial flow direction data edge in the initial data flow direction edge set is updated to generate an updated data flow direction edge, and obtain an updated data flow direction edge set, wherein the updated data flow direction edge represents the data flow direction between two model nodes; The model application logic chain is generated according to the updated data flow edge set and the model node set.

5. The method according to claim 4, wherein: In response to the first real-time hardware resource state representing a low hardware resource available state, performing model tuning on the second model to generate a tuned second model includes: Determine resource occupancy information and model importance of each first model in the first model sequence, wherein the model importance is determined by the position of the first model in the model application logic chain; According to the tuning strategy information corresponding to the first real-time hardware resource state, a first model in the second model whose corresponding resource occupancy information and model importance meet the tuning condition is replaced to generate a candidate second model; Determine a second real-time hardware resource state, wherein the second real-time hardware resource state represents a real-time resource availability state of hardware resources for running the candidate second model; In response to the second real-time hardware resource state being a low hardware resource available state, performing model pruning on the candidate second model to obtain the tuned second model; In response to the second real-time hardware resource state being a non-low hardware resource available state, the candidate second model is determined as the tuned second model.

6. An electronic device comprising: one or more processors; a storage device having one or more programs stored thereon; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.

7. A computer readable medium having a computer program stored thereon, wherein: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.