Tag prediction method, device and equipment for measurement knowledge graph, and medium
By simultaneously handling the label recommendation task and reviewing the necessity prediction task under a modeling framework, the high cost and inefficiency problems caused by modeling and training in the prior art are solved, and a more efficient and economical label prediction effect is achieved.
Patent Information
- Application Number
- CN202411870154.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-03-28
AI Technical Summary
In the prior art, modeling and training are carried out for label recommendation tasks and review necessity prediction tasks, resulting in high prediction efficiency and prediction cost of label prediction.
Provide a label prediction method for metrological knowledge graph. By obtaining the request text, determining the prediction task objectives, generating a prompt vector, and stitching it with the code vector and the request subject vector and inputting it into the mask language model to obtain the prediction tag, so as to simultaneously handle the label recommendation task and review the necessity prediction task under a model framework.
The time and resource costs brought by separate modeling and training are reduced, the prediction efficiency of label prediction is improved, and the prediction cost is reduced.
Smart Images

Figure CN119719352A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of metrology knowledge graph query technology, and specifically to a label prediction method, device, equipment and medium for metrology knowledge graph. Background Art
[0002] In the field of metrology, knowledge graphs, as a structured knowledge representation method, organize metrology-related entities (such as units of measurement, measurement processes, instruments and equipment, etc.) and their relationships (such as conversion relationships, dependencies, etc.) in the form of graphs, providing strong support for the retrieval, analysis and application of metrology data. However, with the increasing scale and complexity of metrology knowledge graphs, how to ensure the accuracy, consistency and reliability of graph queries, that is, how to ensure the query quality of metrology knowledge graphs has become an urgent problem to be solved. The query quality assurance of metrology knowledge graphs can be defined into two main tasks: query tag recommendation and review necessity prediction. Query tag recommendation aims to understand the user's query intent, while review necessity prediction focuses on screening query content that has review necessity.
[0003] In the prior art, when simultaneously implementing the two tasks of query label recommendation and review necessity prediction, appropriate architectures are designed for the query label recommendation task and the review necessity prediction task respectively to ensure query quality. The prediction of the two tasks is achieved through one architecture, which leads to an increase in modeling time and cost as well as training time and resource cost for the metrology knowledge graph.
[0004] Therefore, there is an urgent need to provide a label prediction method, device, equipment and medium for metrology knowledge graphs, so as to realize the simultaneous processing of label recommendation tasks and review necessity prediction tasks under the same model framework, and reduce the time and resource costs brought by separate modeling and training. Summary of the invention
[0005] In view of this, it is necessary to provide a label prediction method, device, equipment and medium for metrology knowledge graph to solve the technical problems existing in the prior art of separately modeling and training label recommendation tasks and review necessity prediction tasks, resulting in high prediction efficiency and prediction cost of label prediction.
[0006] On the one hand, in order to solve the above technical problems, the present invention provides a label prediction method for a metrology knowledge graph, comprising: Obtaining a request text, wherein the request text includes a request body and a language code; Determining a prediction task target of the request text, and generating a prompt vector based on the prediction task target and a task descriptive prompt template; generating a code vector based on the language code and generating a request body vector based on the request body; Concatenate the prompt vector, the code vector and the request body vector to obtain a concatenated vector; Inputting the concatenated vector into a masked language model to obtain a prediction label corresponding to the prediction task target; Among them, the prediction task objectives include a label recommendation task and a review necessity prediction task; the prediction labels include a prediction recommendation label corresponding to the label recommendation task and a review necessity category label corresponding to the review necessity prediction task.
[0007] In a possible implementation, the task descriptive prompt template includes a task descriptive field and a mask field, and the mask field includes at least one mask byte.
[0008] In a possible implementation, generating a task descriptive prompt vector based on the predicted task target and a task descriptive prompt template includes: The task descriptive text of the task descriptive field and the mask label in the mask byte are determined based on the predicted task target, and the task descriptive text and the mask label constitute the task descriptive hint vector.
[0009] In a possible implementation, generating a code vector based on the language code includes: Parsing the language code, determining important nodes and variable information of the language code, and constructing an abstract syntax tree based on the important nodes and the variable information; The abstract syntax tree is parsed to obtain a data flow graph, and the code vector is generated based on the data flow graph; the nodes in the data flow graph represent the variable information, and the edges in the data flow graph represent the information flow between nodes.
[0010] In a possible implementation, the request text includes professional terms in the field of metrology; then the method further includes: Obtain professional knowledge interpretations of the professional terms from the professional knowledge base in the field of metrology; Generate a professional prefix vector based on the professional knowledge interpretation, and concatenate the professional prefix vector to the code vector to obtain a concatenated code vector; Then, the step of concatenating the prompt vector, the code vector and the request body vector to obtain a concatenated vector includes: The prompt vector, the concatenated code vector and the request body vector are concatenated to obtain the concatenated vector.
[0011] In a possible implementation, inputting the concatenated vector into a mask language model to obtain a prediction label corresponding to the prediction task target includes: Inputting the concatenated vector into the masked language model to obtain a plurality of predicted words; The predicted word is mapped based on a preset mapping function to obtain the predicted label.
[0012] In a possible implementation, inputting the concatenated vector into the masked language model to obtain a plurality of predicted words includes: Inputting the concatenated vector into the masked language model to obtain a plurality of initial predicted words; Determining the matching probability between each of the initially predicted words and a preset vocabulary; A plurality of predicted words among the plurality of initial predicted words are determined based on the matching probability and a Top k algorithm.
[0013] On the other hand, the present invention also provides a label prediction device for a metrology knowledge graph, comprising: A request text acquisition unit, used to acquire a request text, wherein the request text includes a request body and a language code; A prompt vector generating unit, used for determining a prediction task target of the request text, and generating a prompt vector based on the prediction task target and a task descriptive prompt template; a request body vector generating unit, configured to generate a code vector based on the language code, and generate a request body vector based on the request body; A vector concatenation unit, configured to concatenate the prompt vector, the code vector and the request body vector to obtain a concatenated vector; A label prediction unit, used for inputting the concatenated vector into a masked language model to obtain a predicted label corresponding to the prediction task target; Among them, the prediction task objectives include a label recommendation task and a review necessity prediction task; the prediction labels include a prediction recommendation label corresponding to the label recommendation task and a review necessity category label corresponding to the review necessity prediction task.
[0014] On the other hand, the present invention also provides an electronic device, including a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps in the label prediction method for the metrology knowledge graph described in any one of the possible implementation methods above.
[0015] On the other hand, the present invention also provides a computer-readable storage medium for storing computer-readable programs or instructions, which, when executed by a processor, can implement the steps of the label prediction method for the metrology knowledge graph described in any of the above possible implementation methods.
[0016] The beneficial effects of the present invention are as follows: the label prediction method for the metrology knowledge graph provided by the present invention, after determining the prediction task target of the request text, generates a prompt vector based on the prediction task target and the task descriptive prompt template, and based on the prompt vector, it can be characterized whether the prediction task target is a label recommendation task or a review necessity prediction task, and the present invention concatenates the prompt vector with the code vector and the request body vector and inputs them into the mask language model to obtain the prediction label, thereby achieving the purpose of simultaneously processing the label recommendation task and the review necessity prediction task under one model framework, reducing the time cost and resource cost brought by separate modeling and training, improving the prediction efficiency of label prediction while reducing the prediction cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 A schematic flow chart of an embodiment of a label prediction method for a metrology knowledge graph provided by the present invention; Figure 2 A schematic diagram of an embodiment of a task description prompt template provided by the present invention; Figure 3 For the present invention Figure 1 A schematic diagram of an embodiment of a flow chart of generating a code vector in S103; Figure 4 A schematic diagram of an embodiment of a data flow graph generation process provided by the present invention; Figure 5 A schematic flow chart of another embodiment of the label prediction method for the metrology knowledge graph provided by the present invention; Figure 6 A schematic diagram of an embodiment of a splicing vector provided by the present invention; Figure 7 For the present invention Figure 1 A schematic flow chart of an embodiment of S105; Figure 8 For the present invention Figure 7 A schematic flow chart of an embodiment of S701; Fig. 9 A schematic diagram of the structure of an embodiment of a label prediction device for a metrology knowledge graph provided by the present invention; Fig.10 A schematic structural diagram of an embodiment of an electronic device provided by the present invention. DETAILED DESCRIPTION
[0019] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0020] It should be understood that the schematic drawings are not drawn to scale. The flowchart used in the present invention shows the operations implemented according to some embodiments of the present invention. It should be understood that the operations of the flowchart can be implemented out of order, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art, under the guidance of the content of the present invention, can add one or more other operations to the flowchart, and can also remove one or more operations from the flowchart. Some of the block diagrams shown in the accompanying drawings are functional entities, which do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor systems and / or microcontroller systems.
[0021] Reference to an "embodiment" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiment may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0022] The present invention provides a label prediction method, device, equipment and medium for metrology knowledge graph, which are described below respectively.
[0023] Figure 1 A schematic flow chart of an embodiment of a label prediction method for a metrology knowledge graph provided by the present invention is as follows: Figure 1 As shown in Figure 2, the label prediction methods for metrology knowledge graphs include: S101, obtaining a request text, where the request text includes a request body and a language code; S102, determining a prediction task target of the request text, and generating a prompt vector based on the prediction task target and a task descriptive prompt template; S103, generating a code vector based on the language code, and generating a request body vector based on the request body; S104, concatenating the prompt vector, the code vector and the request body vector to obtain a concatenated vector; S105, inputting the concatenated vector into the mask language model to obtain a prediction label corresponding to the prediction task target; Among them, the prediction task objectives include label recommendation tasks and review necessity prediction tasks; the prediction labels include prediction recommendation labels corresponding to the label recommendation tasks and review necessity category labels corresponding to the review necessity prediction tasks.
[0024] It should be understood that the request body includes a title and a description, specifically: req i ={title i ,des i } ,in, req i is the request body of the i-th request text, title i is the title of the request body; des i A description of the request body.
[0025] It should be noted that for different prediction task objectives, namely, for the label recommendation task and the review necessity prediction task, the format and number of bytes of the task descriptive prompt template are the same, and the only difference lies in the specific content in the task descriptive prompt template.
[0026] It should also be noted that the specific lengths of the prompt vector, code vector and request body vector can be set or adjusted according to the actual application scenario and are not specifically limited here.
[0027] Compared with the prior art, the label prediction method for the metrology knowledge graph provided by the embodiment of the present invention, after determining the prediction task target of the request text, generates a prompt vector based on the prediction task target and the task descriptive prompt template, and based on the prompt vector, it can be characterized whether the prediction task target is a label recommendation task or a review necessity prediction task. In addition, the embodiment of the present invention concatenates the prompt vector with the code vector and the request body vector and inputs them into the mask language model to obtain the predicted label, thereby achieving the purpose of simultaneously processing the label recommendation task and the review necessity prediction task under one model framework, reducing the time cost and resource cost brought by separate modeling and training, and improving the prediction efficiency of label prediction while reducing the prediction cost.
[0028] In a specific embodiment of the present invention, Figure 2 As shown, the task descriptive prompt template includes a task descriptive field and a mask field, and the mask field includes at least one mask byte.
[0029] The mask byte is used to fill in the mask.
[0030] It should be understood that when the prediction task objectives are different, the specific contents of the task descriptive field and the mask field are different.
[0031] In a specific embodiment of the present invention, the descriptive prompt of the label recommendation task is: “The requested label is [MASK][MASK][MASK]”, and the Chinese version is: “The requested label is [MASK][MASK][MASK]”, where MASK is a mask.
[0032] The descriptive prompt for the review necessity prediction task is: “Is this request necessary for review? [MASK]”, and the Chinese version is: “Is this request necessary for review? [MASK]”.
[0033] In a specific embodiment of the present invention, generating a task descriptive prompt vector based on the predicted task target and the task descriptive prompt template in step S102 includes: The task descriptive text of the task descriptive field and the mask label in the mask byte are determined based on the predicted task target, and the task descriptive text and the mask label constitute the task descriptive prompt vector.
[0034] The embodiment of the present invention can achieve prediction of different prediction target tasks by filling different contents in the task descriptive field and mask byte of the same format.
[0035] Since the composition, organization structure and semantic expression of code segments in the field of metrology are different from those of general natural languages, if code vectors are generated by converting natural languages into vectors in the prior art, the understanding of the semantics in the language code is hindered, resulting in low accuracy of the prediction results. In order to solve this technical problem, in some embodiments of the present invention, such as Figure 3 As shown, the code vector is generated based on the language code in step S103, including: S301, parsing the language code, determining important nodes and variable information of the language code, and constructing an abstract syntax tree based on the important nodes and variable information; S302, parse the abstract syntax tree to obtain a data flow graph, and generate a code vector based on the data flow graph; the nodes in the data flow graph represent variable information, and the edges in the data flow graph represent the flow of information between nodes.
[0036] The embodiment of the present invention constructs an abstract syntax tree based on important nodes and variable information of the language code, parses the abstract syntax tree to obtain a data flow graph, and forms a concatenated vector with the code vector represented by the graph structure of the data flow graph. In the process of label prediction, the semantic information in the language code is more accurately understood and represented, thereby improving the accuracy of the final predicted label.
[0037] The specific method of generating a code vector based on a data flow graph in step S302 is: using the data flow graph as an input of a pre-set code encoder, and the output obtained is a concatenated vector.
[0038] In a specific embodiment of the present invention, the language code is as follows: Figure 4 As shown in a, the function name is max, the parameters include a and b, and the important nodes and variable information in the language code are extracted to obtain Figure 4 The abstract syntax tree shown in b can be obtained by arranging the recognition order in the abstract syntax tree as follows Figure 4 c, and then use nodes to record the variable nodes of the code segment. The edges represent the information flow between nodes, and we get Figure 4 d shows the data flow diagram.
[0039] For example, if b is assigned to a, this code statement will be parsed into two nodes, a and b, and the data flow will be represented by an edge from b to a.
[0040] Due to the specificity of the metrology field, the request text includes professional terms in the metrology field. Existing methods mostly recognize / predict the request text based on pre-trained language models. The pre-trained language models are trained based on samples in conventional fields and have not previously learned professional knowledge in the metrology field. As a result, the professional knowledge in the metrology field cannot be well characterized, resulting in a poor accuracy rate of the predicted labels. To solve this technical problem, in some embodiments of the present invention, such as Figure 5 As shown in the figure, the label prediction method for the measurement knowledge graph also includes: S501. Obtain professional knowledge interpretation of professional terms from the professional knowledge base in the field of metrology; S502, generating a professional prefix vector based on the professional knowledge interpretation, and concatenating the professional prefix vector to the code vector to obtain a concatenated code vector; Then step S104 is specifically as follows: The prompt vector, the concatenated code vector and the request body vector are concatenated to obtain a concatenated vector.
[0041] The embodiment of the present invention generates a professional prefix vector and uses the expertise in the measurement field to guide the masked language model to learn the expertise, thereby helping the masked language model to better understand and learn the expertise in the request text, thereby improving the accuracy of the obtained prediction labels.
[0042] It should be noted that: before step S501, the following steps are also included: The request text is segmented to obtain multiple words, and words that are not in the regular word list among the multiple words are used as professional terms.
[0043] It should be understood that: when the request text is "should be", the word segmentation process may be: performing word segmentation process on the request text according to spaces to obtain multiple words.
[0044] In order to improve the robustness of the label prediction method for the metrology knowledge graph, in some embodiments of the present invention, professional terms can be fuzzy capitalized, tense and part of speech converted to obtain multiple professional-related terms, and professional knowledge interpretations can be associated with professional-related terms.
[0045] The embodiment of the present invention uses fuzzy case conversion, tense conversion, and part-of-speech conversion processing to find professional knowledge interpretations when professional terms are deformed terms, thereby improving the robustness of the label prediction method for the metrology knowledge graph.
[0046] In a specific embodiment of the present invention, Figure 6 As shown, the concatenated vector includes a hint vector, a request body vector, a professional prefix vector, and a code vector.
[0047] In order to mark the beginning and the end of the splicing vector, a CLS byte is set at the front of the splicing vector, and a SEP byte is set at the end of the splicing vector.
[0048] Since the output of the masked language model is not a predicted label but a predicted word in machine language, in some embodiments of the present invention, Figure 7 As shown, step S105 includes: S701, inputting the concatenated vector into a masked language model to obtain multiple predicted words; S702: Map the predicted word based on a preset mapping function to obtain a predicted label.
[0049] In a specific embodiment of the present invention, the predicted label is: ,in, To predict words; is the mapping function.
[0050] In practical applications, only a certain number of predicted labels are needed to accurately query the measurement knowledge graph, and the number of predicted words obtained in the masked language model is sometimes large. In order to avoid the query time caused by a large number of prediction units, in some embodiments of the present invention, Figure 8 As shown, step S701 includes: S801, inputting the concatenated vector into a masked language model to obtain a plurality of initial predicted words; S802, determining the matching probability between each initial predicted word and a preset vocabulary; S803: Determine multiple predicted words among the multiple initial predicted words based on the matching probability and the Top k algorithm.
[0051] Wherein, step S802 specifically includes: determining the matching probability between the initial predicted word and the preset vocabulary through the Softmax function.
[0052] Step S803 specifically includes: determining a preset number of initial predicted words with the highest matching probability among multiple initial predicted words based on the Top k algorithm, and using the preset number of initial predicted words as predicted words.
[0053] It should be understood that the Top k algorithm is an existing mature algorithm and will not be described in detail here.
[0054] It should be noted that the mask language model in step S105 needs to be trained before use, and the sample data used in the training are prompt vectors, professional prefix vectors, code vectors and request body vectors, among which the code vector is a non-updatable vector, and the prompt vector, professional prefix vector and request body vector are updateable vectors.
[0055] Among them, a task descriptive prompt template has multiple masks, and the training goal of the mask language model is to train with the minimum sum of the position losses of all masks as the optimization goal.
[0056] In summary, the label prediction method for the metrology knowledge graph proposed in the embodiment of the present invention, first, reconstructs the review necessity prediction task and the query label recommendation task into a generation task, realizes the simultaneous processing of multiple tasks under one model framework, and reduces the time and resource costs brought by separate modeling and training. Secondly, the semantic representation method such as data flow graph that conforms to the structure of the code segment is adopted, so that the model can better understand and learn the professional knowledge in the query statement. Finally, by introducing external professional knowledge, the model can understand the specific meaning of the metrology field vocabulary in the request content that has not been learned by the model, which helps the model learn the professional knowledge therein, and greatly improves the performance of the method.
[0057] In order to better implement the label prediction method for the metrology knowledge graph in the embodiment of the present invention, based on the label prediction method for the metrology knowledge graph, the embodiment of the present invention also provides a label prediction device for the metrology knowledge graph, such as Fig. 9 As shown, the label prediction device 900 for the metrology knowledge graph includes: A request text acquisition unit 901 is used to acquire a request text, where the request text includes a request body and a language code; A prompt vector generating unit 902 is used to determine the prediction task target of the request text and generate a prompt vector based on the prediction task target and the task descriptive prompt template; A request body vector generating unit 903, configured to generate a code vector based on the language code and generate a request body vector based on the request body; A vector concatenation unit 904 is used to concatenate the prompt vector, the code vector and the request body vector to obtain a concatenated vector; The label prediction unit 905 is used to input the concatenated vector into the mask language model to obtain a predicted label corresponding to the prediction task target; Among them, the prediction task objectives include label recommendation tasks and review necessity prediction tasks; the prediction labels include prediction recommendation labels corresponding to the label recommendation tasks and review necessity category labels corresponding to the review necessity prediction tasks.
[0058] The label prediction device 900 for the metrology knowledge graph provided in the above embodiment can implement the technical solution described in the above embodiment of the label prediction method for the metrology knowledge graph. The specific implementation principles of the above modules or units can refer to the corresponding contents in the above embodiment of the label prediction method for the metrology knowledge graph, which will not be repeated here.
[0059] like Fig.10 As shown, the present invention also provides an electronic device 1000. The electronic device 1000 includes a processor 1001, a memory 1002 and a display 1003. Fig.10 Only some components of the electronic device 1000 are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0060] In some embodiments, the processor 1001 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run program codes or process data stored in the memory 1002, such as the label prediction method for the metrology knowledge graph in the present invention.
[0061] In some embodiments of the present invention, processor 1001 may be a single server or a server group. The server group may be centralized or distributed. In some embodiments, processor 1001 may be local or remote. In some embodiments, processor 1001 may be implemented in a cloud platform. In one embodiment, the cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud, a distributed cloud, an internal cloud, a multi-cloud, etc., or any combination thereof.
[0062] In some embodiments, the memory 1002 may be an internal storage unit of the electronic device 1000, such as a hard disk or memory of the electronic device 1000. In other embodiments, the memory 1002 may also be an external storage device of the electronic device 1000, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc., equipped on the electronic device 1000.
[0063] Furthermore, the memory 1002 may include both an internal storage unit of the electronic device 1000 and an external storage device. The memory 1002 is used to store application software installed in the electronic device 1000 and various data.
[0064] In some embodiments, the display 1003 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 1003 is used to display information of the electronic device 1000 and to display a visual user interface. The components 1001-1003 of the electronic device 1000 communicate with each other via a system bus.
[0065] In some embodiments of the present invention, when the processor 1001 executes the tag prediction program for the metrology knowledge graph in the memory 1002, the following steps may be implemented: Get the request text, which includes the request body and language code; Determine the prediction task target of the request text, and generate a prompt vector based on the prediction task target and the task descriptive prompt template; generating a code vector based on the language code and generating a request body vector based on the request body; Concatenate the prompt vector, the code vector, and the request body vector to obtain a concatenated vector; Input the concatenated vector into the masked language model to obtain the predicted label corresponding to the prediction task target; Among them, the prediction task objectives include label recommendation tasks and review necessity prediction tasks; the prediction labels include prediction recommendation labels corresponding to the label recommendation tasks and review necessity category labels corresponding to the review necessity prediction tasks.
[0066] It should be understood that: when the processor 1001 executes the label prediction program for the metrology knowledge graph in the memory 1002, in addition to the above functions, other functions can also be implemented. For details, please refer to the description of the corresponding method embodiment above.
[0067] Furthermore, the embodiment of the present invention does not specifically limit the type of the electronic device 1000 mentioned, and the electronic device 1000 may be a portable electronic device such as a mobile phone, a tablet computer, a personal digital assistant (PDA), a wearable device, a laptop computer, etc. Exemplary embodiments of portable electronic devices include but are not limited to portable electronic devices equipped with IOS, Android, Microsoft or other operating systems. The above-mentioned portable electronic devices may also be other portable electronic devices. It should also be understood that in some other embodiments of the present invention, the electronic device 1000 may not be a portable electronic device, but a desktop computer with a touch-sensitive surface (such as a touch panel).
[0068] Accordingly, an embodiment of the present invention also provides a computer-readable storage medium, which is used to store computer-readable programs or instructions. When the program or instructions are executed by a processor, the steps or functions of the label prediction method for the metrology knowledge graph provided in the above-mentioned method embodiments can be implemented.
[0069] Those skilled in the art will appreciate that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware (such as a processor, a controller, etc.) through a computer program, and the computer program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.
[0070] The above is a detailed introduction to a label prediction method, device, equipment and medium for a metrology knowledge graph provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A label prediction method for metrology knowledge graph, characterized in that: include: Obtaining a request text, wherein the request text includes a request body and a language code; Determining a prediction task target of the request text, and generating a prompt vector based on the prediction task target and a task descriptive prompt template; generating a code vector based on the language code and generating a request body vector based on the request body; Concatenate the prompt vector, the code vector and the request body vector to obtain a concatenated vector; Inputting the concatenated vector into a masked language model to obtain a prediction label corresponding to the prediction task target; Among them, the prediction task objectives include a label recommendation task and a review necessity prediction task; the prediction labels include a prediction recommendation label corresponding to the label recommendation task and a review necessity category label corresponding to the review necessity prediction task.
2. The label prediction method for metrology knowledge graph according to claim 1 is characterized in that: The task descriptive prompt template includes a task descriptive field and a mask field, and the mask field includes at least one mask byte.
3. The label prediction method for metrology knowledge graph according to claim 2 is characterized in that: The step of generating a task descriptive prompt vector based on the predicted task target and the task descriptive prompt template includes: The task descriptive text of the task descriptive field and the mask label in the mask byte are determined based on the predicted task target, and the task descriptive text and the mask label constitute the task descriptive hint vector.
4. The label prediction method for metrology knowledge graph according to claim 1 is characterized in that: The generating a code vector based on the language code comprises: Parsing the language code, determining important nodes and variable information of the language code, and constructing an abstract syntax tree based on the important nodes and the variable information; The abstract syntax tree is parsed to obtain a data flow graph, and the code vector is generated based on the data flow graph; the nodes in the data flow graph represent the variable information, and the edges in the data flow graph represent the information flow between nodes.
5. The label prediction method for metrology knowledge graph according to claim 1 is characterized in that: The request text includes professional terms in the field of metrology; the method further includes: Obtain professional knowledge interpretations of the professional terms from the professional knowledge base in the field of metrology; Generate a professional prefix vector based on the professional knowledge interpretation, and concatenate the professional prefix vector to the code vector to obtain a concatenated code vector; Then, the step of concatenating the prompt vector, the code vector and the request body vector to obtain a concatenated vector includes: The prompt vector, the concatenated code vector and the request body vector are concatenated to obtain the concatenated vector.
6. The label prediction method for metrology knowledge graph according to claim 1 is characterized in that: The step of inputting the concatenated vector into a mask language model to obtain a prediction label corresponding to the prediction task target includes: Inputting the concatenated vector into the masked language model to obtain a plurality of predicted words; The predicted word is mapped based on a preset mapping function to obtain the predicted label.
7. The label prediction method for metrology knowledge graph according to claim 6 is characterized in that: The step of inputting the concatenated vector into the masked language model to obtain a plurality of predicted words comprises: Inputting the concatenated vector into the masked language model to obtain a plurality of initial predicted words; Determining the matching probability between each of the initially predicted words and a preset vocabulary; A plurality of predicted words among the plurality of initial predicted words are determined based on the matching probability and a Top k algorithm.
8. A label prediction device for metrology knowledge graph, characterized in that: include: A request text acquisition unit, used to acquire a request text, wherein the request text includes a request body and a language code; A prompt vector generating unit, used for determining a prediction task target of the request text, and generating a prompt vector based on the prediction task target and a task descriptive prompt template; a request body vector generating unit, configured to generate a code vector based on the language code, and generate a request body vector based on the request body; A vector concatenation unit, configured to concatenate the prompt vector, the code vector and the request body vector to obtain a concatenated vector; A label prediction unit, used for inputting the concatenated vector into a masked language model to obtain a predicted label corresponding to the prediction task target; Among them, the prediction task objectives include a label recommendation task and a review necessity prediction task; the prediction labels include a prediction recommendation label corresponding to the label recommendation task and a review necessity category label corresponding to the review necessity prediction task.
9. An electronic device, characterized in that: comprising a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps in the label prediction method for the metrology knowledge graph described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Used to store computer-readable programs or instructions, which, when executed by a processor, can implement the steps of the label prediction method for the metrology knowledge graph described in any one of claims 1 to 7.
Citation Information
Patent Citations
Conversation recommendation system based on prompt learning method
CN115525744A
Dialogue text relation extraction method based on knowledge assistance
CN117573878A
Multi-task recommendation method and device based on user evaluation information, terminal and medium
CN118260411A
Adaptive knowledge enhancement multi-domain recommendation method based on large language model
CN118898269A
Constrained prefix matching for generating next token predictions
US20230418567A1