Question and answer method, device and equipment based on numerical control machine tool operation manual and medium
By extracting sentence features based on word vectors and semantic models, and combining them with a question-answering model, the problem of low efficiency in finding answers in CNC machine tool operation manuals is solved, and efficient answer matching and querying are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-28
- Publication Date
- 2026-03-24
AI Technical Summary
The current technology for obtaining answers to problems from CNC machine tool operation manuals is inefficient because existing methods mainly rely on keyword matching, resulting in a large number of duplicate results and inefficient queries.
We employ a word vector extraction model and a semantic model to extract sentence features from questions. We then use a question-answering model to match answers in the user manual and a semantic model to extract the semantics of questions. By segmenting the questions before matching them, we reduce computation and improve efficiency.
By using sentence-level semantic matching, the efficiency of finding answers in CNC machine tool operation manuals has been significantly improved, while reducing computational resources and time consumption.
Smart Images

Figure CN116842167B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of CNC machining technology, and in particular to a question-and-answer method, apparatus, equipment and medium based on a CNC machine tool operation manual. Background Technology
[0002] CNC machine tools are complex devices requiring a high level of specialized knowledge to operate proficiently. In production, when CNC machine tool operators encounter machine errors or are unsure how to proceed with new machining tasks, they often need to consult the operation manual, which is often quite extensive. Current technology allows operators to search through hundreds of pages of CNC machine tool operation manuals using keywords. However, this method only finds words that are identical to the keywords, and these words may appear repeatedly in the manual. Therefore, this existing method generates a large number of search results, making it inefficient to obtain the answers to problems from the CNC machine tool operation manual. Summary of the Invention
[0003] This invention provides a question-and-answer method based on CNC machine tool operation manuals to solve the problem of low efficiency in obtaining answers to problems from CNC machine tool operation manuals in the prior art, and to achieve efficient acquisition of answers to problems from CNC machine tool operation manuals.
[0004] This invention provides a question-and-answer method based on a CNC machine tool operation manual, including:
[0005] Obtain the question to be answered, and obtain the initial word vector features corresponding to the question to be answered based on the word vector extraction model;
[0006] The initial word vector features corresponding to the question to be answered are input into the trained semantic model to obtain the sentence features corresponding to the question to be answered output by the semantic model.
[0007] Based on the sentence features corresponding to the questions to be answered, the target corpus segments are determined in the operation manual;
[0008] The question to be answered and the target corpus are input into the trained question-answering model in segments to obtain the answer output by the question-answering model;
[0009] The semantic model is trained based on multiple sets of first training data, each set of first training data including the initial word vector features corresponding to each sample sentence in the sample text; the training process of the semantic model includes:
[0010] The initial word vector features corresponding to each sample sentence in the sample text are input into the semantic model to obtain the sample sentence features corresponding to each sample sentence output by the semantic model.
[0011] After occluding the first sample sentence feature in the sample sentence features corresponding to each sample sentence in the sample text, the feature is input into the prediction model to obtain the first prediction value of the first sample sentence feature output by the prediction model.
[0012] The target training loss is determined based on the first predicted value and the first sample sentence features, and the parameters of the prediction model and the semantic model are updated based on the target training loss.
[0013] According to the present invention, a question-and-answer method based on a CNC machine tool operation manual is provided, wherein determining the target corpus segment in the operation manual based on the sentence features corresponding to the question to be answered includes:
[0014] The sentence features corresponding to the question to be answered are matched with the segment features corresponding to each corpus segment in the operation manual to obtain the matching results. The matching results include the similarity between the sentence features corresponding to the question to be answered and the segment features corresponding to each corpus segment.
[0015] The target corpus segments are determined based on the matching results;
[0016] The segment features corresponding to each corpus segment in the operation manual are obtained by inputting the initial word vector features corresponding to each sentence in the corpus segment into the semantic model.
[0017] According to the present invention, a question-and-answer method based on a CNC machine tool operation manual is provided, wherein matching the sentence features corresponding to the question to be answered with the segment features corresponding to each segment of the corpus in the operation manual to obtain a matching result includes:
[0018] Obtain the similarity score between the sentence features corresponding to the question to be answered and the sentence features corresponding to each sentence in the corpus segment;
[0019] The average value is obtained by averaging the similarity scores corresponding to the segments of the corpus.
[0020] Obtain the maximum value among the similarity scores corresponding to the corpus segments;
[0021] The similarity between the average value and the maximum value is obtained by weighted summation of the sentence features corresponding to the question to be answered and the segment features corresponding to the corpus segments.
[0022] According to the present invention, a question-and-answer method based on a CNC machine tool operation manual is provided, wherein determining the target corpus segmentation based on the matching result includes:
[0023] The segments of the corpus are arranged in descending order of similarity to the sentence features corresponding to the question to be answered, and the sorting result is obtained.
[0024] The first N segments of the corpus in the sorting result are taken as the target corpus segments, where N is a positive integer greater than 1.
[0025] According to the present invention, a question-and-answer method based on a CNC machine tool operation manual is provided. The word vector extraction model includes a first word vector extraction model and a second word vector extraction model. The method for obtaining initial word vector features corresponding to the question to be answered based on the word vector extraction model includes:
[0026] Based on the first word vector extraction model, the first initial word vector features corresponding to the question to be answered are obtained;
[0027] Based on the second word vector extraction model, the second initial word vector features corresponding to the question to be answered are obtained;
[0028] The initial word vector features of the question to be answered are obtained by averaging the first initial word vector features and the second initial word vector features.
[0029] According to the present invention, a question-answering method based on a CNC machine tool operation manual is provided, wherein determining the target training loss based on the first predicted value and the first sample sentence features includes:
[0030] The second sample sentence feature in the sample sentence feature corresponding to each sample sentence in the sample text is masked, and the first sample sentence feature is replaced with the first predicted value and then input into the prediction model to obtain the second predicted value of the second sample sentence feature output by the prediction model;
[0031] The first training loss is determined based on the difference between the first predicted value and the features of the first sample sentence.
[0032] The second training loss is determined based on the difference between the second predicted value and the features of the second sample sentence.
[0033] The target training loss is obtained by weighted summation of the first training loss and the second training loss.
[0034] According to the present invention, a question-answering method based on a CNC machine tool operation manual is provided. The question-answering model is obtained by adjusting multiple sets of second training data on the basis of a first trained model. The first model is a natural language question-answering model trained with a general corpus. The second training data is data extracted from the operation manual. Each set of second training data includes a sample question to be answered, the operation manual, and the answer label corresponding to the sample question to be answered.
[0035] The present invention also provides a question-and-answer device based on a CNC machine tool operation manual, comprising: a word feature module, used to obtain a question to be answered, and to obtain initial word vector features corresponding to the question to be answered based on a word vector extraction model;
[0036] The sentence feature module is used to input the initial word vector features corresponding to the question to be answered into the trained semantic model, and obtain the sentence features corresponding to the question to be answered output by the semantic model;
[0037] The matching module is used to determine the target corpus segment based on the sentence features corresponding to the question to be answered, as specified in the operation manual.
[0038] The answering module is used to input the question to be answered and the target corpus into the trained question-answering model in segments, and obtain the answer output by the question-answering model;
[0039] The semantic model is trained based on multiple sets of first training data, each set of first training data including the initial word vector features corresponding to each sample sentence in the sample text; the training process of the semantic model includes:
[0040] The initial word vector features corresponding to each sample sentence in the sample text are input into the semantic model to obtain the sample sentence features corresponding to each sample sentence output by the semantic model.
[0041] After occluding the first sample sentence feature in the sample sentence features corresponding to each sample sentence in the sample text, the feature is input into the prediction model to obtain the first prediction value of the first sample sentence feature output by the prediction model.
[0042] The target training loss is determined based on the first predicted value and the first sample sentence features, and the parameters of the prediction model and the semantic model are updated based on the target training loss.
[0043] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the question-and-answer method based on the CNC machine tool operation manual as described above.
[0044] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the question-and-answer method based on the CNC machine tool operation manual as described above.
[0045] The present invention provides a question-and-answer method, apparatus, device, and medium based on CNC machine tool operation manuals. It first inputs the initial word vector features of the question to be answered into a semantic model to obtain sentence-level features of the question. Then, based on the sentence features, it determines the corpus segments in the operation manual. The corpus segments and the question to be answered are then input into the question-and-answer model to obtain the answer output by the model. The semantic model can extract the semantics of the question to be answered. Based on the semantics extracted by the semantic model, instead of performing keyword matching across the entire operation manual, it first extracts partial segments, and then, based on the extracted semantics, matches these partial segments with the question to be answered, using the question-and-answer model to output the answer. This effectively improves the efficiency of finding answers to problems in operation manuals. Attached Figure Description
[0046] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0047] Figure 1 This is a flowchart illustrating the question-and-answer method based on the CNC operation manual provided by the present invention;
[0048] Figure 2 This is a schematic diagram of the question-and-answer device based on the CNC operation manual provided by the present invention;
[0049] Figure 3 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0050] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0051] The following is combined Figures 1-3 This invention describes the question-and-answer method, apparatus, equipment, and medium based on the CNC machine tool operation manual provided by this invention.
[0052] The question-and-answer method based on CNC machine tool operation manuals provided by this invention can be executed by an electronic device with computing capabilities, such as a computer, mobile terminal, wearable smart device, etc. Figure 1 As shown, the question-and-answer method based on the CNC machine tool operation manual provided by this invention includes the following steps:
[0053] S100. Obtain the question to be answered, and obtain the initial word vector features corresponding to the question to be answered based on the word vector extraction model;
[0054] S200. Input the initial word vector features corresponding to the question to be answered into the trained semantic model, and obtain the sentence features corresponding to the question to be answered output by the semantic model;
[0055] S300. Based on the sentence features corresponding to the question to be answered, determine the target corpus segmentation in the operation manual;
[0056] S400. Input the question to be answered and the target corpus into the trained question-answering model in segments, and obtain the answer output by the question-answering model.
[0057] The semantic model is used to obtain the overall semantics of a text sentence based on the word vectors of each word in the input text sentence. To achieve this, the semantic model is trained on multiple sets of first training data, each set of first training data including the initial word vector features of each sample sentence in the sample text; the training process of the semantic model includes:
[0058] The initial word vector features corresponding to each sample sentence in the sample text are input into the semantic model to obtain the sample sentence features corresponding to each sample sentence output by the semantic model.
[0059] After occluding the first sample sentence feature in the sample sentence features corresponding to each sample sentence in the sample text, the feature is input into the prediction model to obtain the first prediction value of the first sample sentence feature output by the prediction model.
[0060] The target training loss is determined based on the first predicted value and the first sample sentence features, and the parameters of the prediction model and the semantic model are updated based on the target training loss.
[0061] The method provided by this invention first inputs the initial word vector features of the question to be answered into a semantic model to obtain sentence-level features of the question. Then, based on the sentence features, it determines the corpus segments in the operation manual. The corpus segments and the question to be answered are then input into a question-answering model to obtain the answer output by the question-answering model. The semantic model can extract the semantics of the question to be answered. Based on the semantics extracted by the semantic model, instead of performing keyword matching on the entire operation manual, it first extracts some segments, and then uses the extracted semantics to match the partial segments and the question to be answered, and uses the question-answering model to output the answer. This can effectively improve the efficiency of finding the answer to the problem from the operation manual.
[0062] The word vector extraction model includes a first word vector extraction model and a second word vector extraction model. The initial word vector features corresponding to the question to be answered include the word vectors corresponding to each word in the question to be answered. The step of obtaining the initial word vector features corresponding to the question to be answered based on the word vector extraction model includes:
[0063] Based on the first word vector extraction model, the first initial word vector features corresponding to the question to be answered are obtained;
[0064] Based on the second word vector extraction model, the second initial word vector features corresponding to the question to be answered are obtained;
[0065] The initial word vector features of the question to be answered are obtained by averaging the first initial word vector features and the second initial word vector features.
[0066] In the existing technology, there are word vector extraction models with various structures, such as word2vec and glove. These models can be used to extract word vectors. In this invention, the word vectors generated by two word vector extraction models are averaged to obtain the initial word vector features used in the method provided by this invention.
[0067] The question to be answered is a sentence containing multiple words, each with a corresponding word vector. The word vectors of each word in the question to be answered are combined to obtain the initial word vector features corresponding to the question to be answered. In other words, the initial word vector features corresponding to the question to be answered include the word vectors corresponding to each word in the question to be answered. These initial word vector features are input into a trained semantic model to obtain the sentence features corresponding to the question to be answered, output by the semantic model. Specifically, although the initial word vector features corresponding to the question to be answered contain the semantics of the words, and their combination can reflect the semantics of the sentence to some extent, they still remain at the level of individual words. The feature vectors are not concise enough, and the combination of word vectors from multiple words increases the dimensionality, resulting in a high computational cost during matching, which is not conducive to quickly finding the answer to the question to be answered in the user manual. In the method provided by this invention, in order to improve matching efficiency, the semantics at the word level are elevated to the semantics at the sentence level to facilitate matching with longer corpora in the operation manual. That is, the dimension of the sentence features corresponding to the question to be answered is smaller than the dimension of the initial word vector features corresponding to the question to be answered.
[0068] To enable the semantic model to transform word vectors of multiple words into features reflecting the semantics of the entire sentence, the method provided in this invention trains the semantic model and a prediction model together. The semantic model outputs sentence features, and the prediction model evaluates the sentence features output by the semantic model. Specifically, the sample text is a piece of natural language corpus, and the sample sentences included in the sample text have contextual relationships. The sentence features corresponding to each sample sentence in the sample text in the semantic model are combined to obtain combined features. Then, the sentence features corresponding to the first sample sentence, i.e., the first sample sentence features, are masked. Specifically, the values of the first sample sentence features in the combined features can be set to 0. The masked combined features are input into the prediction model, and the prediction model predicts the sentence feature values of the masked part, i.e., outputs the first predicted value. The target training loss is determined based on the first predicted value and the first sample sentence features, including:
[0069] The second sample sentence feature in the sample sentence feature corresponding to each sample sentence in the sample text is masked, and the first sample sentence feature is replaced with the first predicted value and then input into the prediction model to obtain the second predicted value of the second sample sentence feature output by the prediction model;
[0070] The first training loss is determined based on the difference between the first predicted value and the features of the first sample sentence.
[0071] The second training loss is determined based on the difference between the second predicted value and the features of the second sample sentence.
[0072] The target training loss is obtained by weighted summation of the first training loss and the second training loss.
[0073] After obtaining the first predicted value, it is added to the position of the first sample sentence feature in the combined features input to the semantic model to obtain a new combined feature. Then, the sentence feature corresponding to the second sample sentence in the new combined feature is occluded, and then input into the semantic model to predict the second sample sentence feature to obtain the second predicted value. A first training loss is determined based on the difference between the first predicted value and the first sample sentence feature, and a second training loss is determined based on the difference between the second predicted value and the second sample sentence feature. The parameters of the semantic model and the prediction model are updated together based on the first training loss and the second training loss. In this way, two supervised training modes are actually completed at once: "predicting the semantics of the occluded sentence using the semantics of other sentences" and "predicting the semantics of other sentences using the predicted semantics". This can improve the accuracy of the sentence semantics extracted by the semantic model and improve training efficiency.
[0074] The following example illustrates the specific process of obtaining the target training loss. For instance, the sample text is: "When a CNC machine tool performs machining operations, it needs to select the corresponding tool based on the workpiece material. When the machine tool is stopped, the tool is installed on the machine tool. After the machine tool is turned on, the 'return to origin' button on the control panel is pressed to return the CNC machine tool to its origin." This includes multiple sample sentences: "When a CNC machine tool performs machining operations," "It needs to select the corresponding tool based on the workpiece material," "When the machine tool is stopped, the tool is installed on the machine tool," "After the machine tool is turned on, the 'return to origin' button on the control panel is pressed," and "Return the CNC machine tool to its origin." First, the word vectors of each word in each sample sentence are obtained based on the word vector extraction model. The word vectors of each word in each sentence are combined to obtain the initial word vector features corresponding to each sample sentence. Then, the initial word vector features corresponding to each sample sentence are input into the semantic model to obtain the sample sentence features corresponding to each sample sentence output by the semantic model. For example, after processing the sample sentence "When performing machining operations on a CNC machine tool," we obtain sample sentence feature A. Similarly, after processing "It is necessary to select the corresponding tool based on the material of the workpiece," we obtain sample sentence feature B. Likewise, the sample sentence feature corresponding to "Install the tool on the machine tool when the machine tool is stopped" is C, the sample sentence feature corresponding to "Press the return-to-origin button on the control panel after the machine tool is turned on" is D, and the sample sentence feature corresponding to "Return the CNC machine tool to its origin" is E (in practical applications, A, B, C, D, and E are vectors or matrices, respectively). Any sample sentence feature is arbitrarily selected as the first sample sentence feature. For example, selecting B corresponding to "It is necessary to select the corresponding tool based on the material of the workpiece" as the first sample sentence feature. After occluding B, the sample sentence features corresponding to the sample text become "AMaskCDE," where Mask represents an occlusion marker. "AMaskCDE" is input into the semantic model, and the semantic model predicts the sample sentence features at the Mask location based on ACDE, outputting a first predicted value b. If the sentence features corresponding to each sample text can accurately reflect the semantics of the sample sentence, and the semantic model has excellent predictive ability, then b should be consistent with B. In other words, the smaller the difference between the first predicted value b and the first sample sentence feature B, the better the performance of the semantic model and the predictive model. Furthermore, if the first predicted value b is more accurate, then using the first predicted value b to predict the sentence features of other sentences in the sample sentence should also be accurate.In the method provided by this invention, after obtaining b, sample sentence features other than the first sample sentence features are selected as the second sample sentence features. For example, the sample sentence feature E corresponding to "make the CNC machine tool return to the origin" is selected as the second sample sentence feature. B is replaced with b, and E is then masked and input into the prediction model again. That is, "AbCDMask" is input into the prediction model. The prediction model predicts the sentence features at Mask based on AbCD and outputs a second predicted value e. Similarly, the smaller the difference between the second predicted value e and E, the better the performance of the semantic model and the prediction model. The first training loss is determined based on the difference between b and B, and the second training loss is determined based on the difference between e and E. The first training loss and the second training loss are weighted and summed to obtain the target training loss. The parameters of the semantic model and the prediction model are updated based on the target training loss so that the parameters of the semantic model and the prediction model are optimized in the direction of making the difference between b and B smaller and the difference between e and E smaller.
[0075] After obtaining the sentence features corresponding to the question to be answered, the target corpus segmentation is determined based on the sentence features in the operation manual, specifically including:
[0076] The sentence features corresponding to the question to be answered are matched with the segment features corresponding to each corpus segment in the operation manual to obtain the matching results. The matching results include the similarity between the sentence features corresponding to the question to be answered and the segment features corresponding to each corpus segment.
[0077] The target corpus segments are determined based on the matching results;
[0078] The segment features corresponding to each corpus segment in the operation manual are obtained by inputting the initial word vector features corresponding to each sentence in the corpus segment into the semantic model.
[0079] The user manual contains a large amount of content. When performing question-and-answer queries, searching and matching the entire user manual as a target would consume a lot of computing resources and time. In order to improve efficiency, the method provided by this invention divides the content of the user manual into segments to obtain multiple corpus segments. The user manual can be segmented by a fixed number of paragraphs, such as three paragraphs per corpus segment, or by a fixed number of words, such as 4,000 words per corpus segment, or by chapter segmentation, such as each chapter per corpus segment.
[0080] In one possible implementation, the user manual can be segmented based on its table of contents. Specifically, the chapter titles in the table of contents of the user manual can be queried in the entire text corresponding to the user manual, and the content between two chapter titles can be segmented as a corpus.
[0081] The segment features corresponding to each corpus segment in the operation manual include sentence features corresponding to each sentence in the corpus segment. For the target corpus segment, the initial word vector features corresponding to each sentence in the target corpus segment are input into the semantic model to obtain the sentence features corresponding to each sentence in the target corpus segment. Combining these features yields the segment features corresponding to the target corpus segment.
[0082] Determining the target corpus segment based on the matching result includes:
[0083] The segments of the corpus are arranged in descending order of similarity to the sentence features corresponding to the question to be answered, and the sorting result is obtained.
[0084] The first N segments of the corpus in the sorting result are taken as the target corpus segments, where N is a positive integer greater than 1.
[0085] Based on the similarity between the segment features corresponding to the corpus segments and the sentence features corresponding to the question to be answered, the N corpus segments with the highest similarity are selected as the target corpus segments. The answer to the question to be answered is then searched within these target corpus segments. N can be determined based on the number of all corpus segments included in the operation manual. For example, N can be obtained by multiplying the number of all corpus segments included in the operation manual by a ratio less than 1 (e.g., 0.1, 0.2, etc.). It is worth noting that, since the semantic features corresponding to each sentence were actually reduced in the preceding steps when obtaining sentence features (meaning some features were lost), and since each corpus segment includes multiple sentences, to prevent sentences unrelated to the answer to the question from affecting the similarity and causing the corpus segment closest to the question to be missed as the target corpus segment, the method provided in this invention does not select only the corpus segment with the highest similarity as the target corpus segment, but selects multiple segments, achieving better robustness.
[0086] The sentence features corresponding to the question to be answered are matched with the segment features corresponding to each corpus segment in the operation manual to obtain the matching results, including:
[0087] Obtain the similarity score between the sentence features corresponding to the question to be answered and the sentence features corresponding to each sentence in the corpus segment;
[0088] The average value is obtained by averaging the similarity scores corresponding to the segments of the corpus.
[0089] Obtain the maximum value among the similarity scores corresponding to the corpus segments;
[0090] The similarity between the average value and the maximum value is obtained by weighted summation of the sentence features corresponding to the question to be answered and the segment features corresponding to the corpus segments.
[0091] Specifically, since a corpus segment contains multiple sentences, the similarity between sentences unrelated to the question to be answered and the question can affect the overall similarity between the corpus segment and the question. To mitigate this influence and ensure the relevance of the determined target corpus segment to the question, the method provided in this invention, after obtaining the similarity scores between each sentence in the corpus segment and the question and taking the average, does not directly use the average as the overall similarity between the entire corpus segment and the question. Instead, it obtains the maximum similarity score between the target segment and the question, and then performs a weighted summation of this maximum and average scores to obtain the final similarity score used to determine the target corpus segment. The weights in the weighted summation can be determined through multiple experiments.
[0092] After determining the target corpus segments, the target corpus segments and the question to be answered are input together into a trained question-answering model to obtain the answer output by the question-answering model. In the method provided by this invention, the question-answering model outputs multiple answers sorted by accuracy probability, and the answer with the highest accuracy probability is selected as the answer to the question to be answered and provided to the user, for example, by sending it to a display device for display.
[0093] Specifically, the question-answering model is obtained by adjusting multiple sets of second training data based on the first trained model. The first model is a natural language question-answering model trained using a general corpus. The second training data is data extracted from the operation manual. Each set of second training data includes sample questions to be answered, the CNC machine tool operation manual, and answer tags corresponding to the sample questions to be answered.
[0094] To improve efficiency, the method provided in this invention trains a natural language question-answering model using a general corpus to obtain the first model. Then, it trains the model again using second training data extracted and labeled from a CNC machine tool operation manual. Since the general corpus already contains labeled data, this method reduces labeling costs. Furthermore, there are already natural language question-answering models trained using a general corpus; these models can be directly used as the first model and adjusted using a small amount of labeled second training data. In other words, it is not necessary to train the first model manually.
[0095] The process of adjusting the first model using the second training data to obtain the question-answering model includes:
[0096] In the operation manual, select a first segment and a second segment that include the answer tag, wherein the length of the first segment is shorter than the length of the second segment;
[0097] The sample question to be answered and the first segment are input into the first model to obtain multiple first sample candidate answers output by the first model;
[0098] The sample question to be answered and the second passage are input into the first model to obtain multiple second sample candidate answers output by the first model;
[0099] The first loss is determined based on the difference between the first sample candidate answer with the highest accuracy probability among the plurality of first sample candidate answers and the answer label;
[0100] The multiple first sample candidate answers are reordered based on their relevance to the sample question to be answered, and a reordering result is obtained. A second loss is determined based on the reordering result and the order of the multiple first sample candidate answers output by the first model.
[0101] The third loss is determined based on the difference between the second sample candidate answer with the highest accuracy probability among the plurality of second sample candidate answers and the answer label;
[0102] The fourth loss is determined based on the difference between the second sample candidate answer with the highest accuracy probability among the plurality of second sample candidate answers and the first sample candidate answer with the highest accuracy probability among the plurality of first sample candidate answers.
[0103] The parameters of the first model are adjusted based on the first loss, the second loss, the third loss, and the fourth loss.
[0104] In the method provided by the present invention, during the process of adjusting the parameters of the first model using the second training data to obtain the question-answering model, the corpus in the operation manual is fully utilized. For the same answer label, segments containing different content are selected to obtain multiple losses. This can effectively improve the utilization of training data, improve training efficiency, and enable the question-answering model to output accurate answers for corpora containing different content, thereby improving accuracy.
[0105] The following describes the question-and-answer device based on the CNC machine tool operation manual provided by this invention. The question-and-answer device based on the CNC machine tool operation manual described below and the question-and-answer method based on the CNC machine tool operation manual described above can be referred to and corresponded to each other. Figure 2 The device includes:
[0106] The word feature module 210 is used to obtain the question to be answered and to obtain the initial word vector features corresponding to the question to be answered based on the word vector extraction model.
[0107] The sentence feature module 220 is used to input the initial word vector features corresponding to the question to be answered into the trained semantic model, and obtain the sentence features corresponding to the question to be answered output by the semantic model;
[0108] Matching module 230 is used to determine the target corpus segment based on the sentence features corresponding to the question to be answered in the operation manual;
[0109] The answering module 240 is used to input the question to be answered and the target corpus into the trained question-answering model in segments, and obtain the answer output by the question-answering model;
[0110] The semantic model is trained based on multiple sets of first training data, each set of first training data including the initial word vector features corresponding to each sample sentence in the sample text; the training process of the semantic model includes:
[0111] The initial word vector features corresponding to each sample sentence in the sample text are input into the semantic model to obtain the sample sentence features corresponding to each sample sentence output by the semantic model.
[0112] After occluding the first sample sentence feature in the sample sentence features corresponding to each sample sentence in the sample text, the feature is input into the prediction model to obtain the first prediction value of the first sample sentence feature output by the prediction model.
[0113] The target training loss is determined based on the first predicted value and the first sample sentence features, and the parameters of the prediction model and the semantic model are updated based on the target training loss.
[0114] Figure 3 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 3 As shown, the electronic device may include a processor 310, a communication interface 320, a memory 330, and a communication bus 340, wherein the processor 310, the communication interface 320, and the memory 330 communicate with each other through the communication bus 340. The processor 310 can call logical instructions in the memory 330 to execute a question-and-answer method based on a CNC machine tool operation manual. This method includes: obtaining a question to be answered, and obtaining initial word vector features corresponding to the question to be answered based on a word vector extraction model.
[0115] The initial word vector features corresponding to the question to be answered are input into the trained semantic model to obtain the sentence features corresponding to the question to be answered output by the semantic model.
[0116] Based on the sentence features corresponding to the questions to be answered, the target corpus segments are determined in the operation manual;
[0117] The question to be answered and the target corpus are input into the trained question-answering model in segments to obtain the answer output by the question-answering model;
[0118] The semantic model is trained based on multiple sets of first training data, each set of first training data including the initial word vector features corresponding to each sample sentence in the sample text; the training process of the semantic model includes:
[0119] The initial word vector features corresponding to each sample sentence in the sample text are input into the semantic model to obtain the sample sentence features corresponding to each sample sentence output by the semantic model.
[0120] After occluding the first sample sentence feature in the sample sentence features corresponding to each sample sentence in the sample text, the feature is input into the prediction model to obtain the first prediction value of the first sample sentence feature output by the prediction model.
[0121] The target training loss is determined based on the first predicted value and the first sample sentence features, and the parameters of the prediction model and the semantic model are updated based on the target training loss.
[0122] Furthermore, the logical instructions in the aforementioned memory 330 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0123] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the question-and-answer method based on the CNC machine tool operation manual provided by the above methods, the method comprising: obtaining a question to be answered, and obtaining initial word vector features corresponding to the question to be answered based on a word vector extraction model;
[0124] The initial word vector features corresponding to the question to be answered are input into the trained semantic model to obtain the sentence features corresponding to the question to be answered output by the semantic model.
[0125] Based on the sentence features corresponding to the questions to be answered, the target corpus segments are determined in the operation manual;
[0126] The question to be answered and the target corpus are input into the trained question-answering model in segments to obtain the answer output by the question-answering model;
[0127] The semantic model is trained based on multiple sets of first training data, each set of first training data including the initial word vector features corresponding to each sample sentence in the sample text; the training process of the semantic model includes:
[0128] The initial word vector features corresponding to each sample sentence in the sample text are input into the semantic model to obtain the sample sentence features corresponding to each sample sentence output by the semantic model.
[0129] After occluding the first sample sentence feature in the sample sentence features corresponding to each sample sentence in the sample text, the feature is input into the prediction model to obtain the first prediction value of the first sample sentence feature output by the prediction model.
[0130] The target training loss is determined based on the first predicted value and the first sample sentence features, and the parameters of the prediction model and the semantic model are updated based on the target training loss.
[0131] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0132] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0133] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A question-and-answer method based on a CNC machine tool operation manual, characterized in that, include: Obtain the question to be answered, and obtain the initial word vector features corresponding to the question to be answered based on the word vector extraction model; The initial word vector features corresponding to the question to be answered are input into the trained semantic model to obtain the sentence features corresponding to the question to be answered output by the semantic model. Based on the sentence features corresponding to the questions to be answered, the target corpus segments are determined in the operation manual; The question to be answered and the target corpus are input into the trained question-answering model in segments to obtain the answer output by the question-answering model; The semantic model is trained based on multiple sets of first training data, each set of first training data including the initial word vector features corresponding to each sample sentence in the sample text; the training process of the semantic model includes: The initial word vector features corresponding to each sample sentence in the sample text are input into the semantic model to obtain the sample sentence features corresponding to each sample sentence output by the semantic model. After occluding the first sample sentence feature in the sample sentence features corresponding to each sample sentence in the sample text, the feature is input into the prediction model to obtain the first prediction value of the first sample sentence feature output by the prediction model. The target training loss is determined based on the first predicted value and the first sample sentence features, and the parameters of the prediction model and the semantic model are updated based on the target training loss.
2. The question-and-answer method based on the CNC machine tool operation manual according to claim 1, characterized in that, The step of determining the target corpus segmentation based on the sentence features corresponding to the question to be answered, as described in the operation manual, includes: The sentence features corresponding to the question to be answered are matched with the segment features corresponding to each corpus segment in the operation manual to obtain the matching results. The matching results include the similarity between the sentence features corresponding to the question to be answered and the segment features corresponding to each corpus segment. The target corpus segments are determined based on the matching results; The segment features corresponding to each corpus segment in the operation manual are obtained by inputting the initial word vector features corresponding to each sentence in the corpus segment into the semantic model.
3. The question-and-answer method based on the CNC machine tool operation manual according to claim 2, characterized in that, The step of matching the sentence features corresponding to the question to be answered with the segment features corresponding to each corpus segment in the operation manual to obtain the matching result includes: Obtain the similarity score between the sentence features corresponding to the question to be answered and the sentence features corresponding to each sentence in the corpus segment; The average value is obtained by averaging the similarity scores corresponding to the segments of the corpus. Obtain the maximum value among the similarity scores corresponding to the corpus segments; The similarity between the average value and the maximum value is obtained by weighted summation of the sentence features corresponding to the question to be answered and the segment features corresponding to the corpus segments.
4. The question-and-answer method based on the CNC machine tool operation manual according to claim 2, characterized in that, Determining the target corpus segment based on the matching result includes: The segments of each corpus are arranged in descending order of similarity to the sentence features corresponding to the question to be answered, and the sorting result is obtained. The first N segments of the corpus in the sorting result are taken as the target corpus segments, where N is a positive integer greater than 1.
5. The question-and-answer method based on the CNC machine tool operation manual according to claim 1, characterized in that, The word vector extraction model includes a first word vector extraction model and a second word vector extraction model. The step of obtaining initial word vector features corresponding to the question to be answered based on the word vector extraction model includes: Based on the first word vector extraction model, the first initial word vector features corresponding to the question to be answered are obtained; Based on the second word vector extraction model, obtain the second initial word vector features corresponding to the question to be answered; The initial word vector features of the question to be answered are obtained by averaging the first initial word vector features and the second initial word vector features.
6. The question-and-answer method based on the CNC machine tool operation manual according to claim 1, characterized in that, The step of determining the target training loss based on the first predicted value and the first sample sentence features includes: The second sample sentence feature in the sample sentence feature corresponding to each sample sentence in the sample text is masked, and the first sample sentence feature is replaced with the first predicted value and then input into the prediction model to obtain the second predicted value of the second sample sentence feature output by the prediction model; The first training loss is determined based on the difference between the first predicted value and the features of the first sample sentence. The second training loss is determined based on the difference between the second predicted value and the features of the second sample sentence. The target training loss is obtained by weighted summation of the first training loss and the second training loss.
7. The question-and-answer method based on the CNC machine tool operation manual according to claim 1, characterized in that, The question-answering model is obtained by adjusting multiple sets of second training data based on the first trained model. The first model is a natural language question-answering model trained using a general corpus. The second training data is data extracted from the operation manual. Each set of second training data includes sample questions to be answered, the operation manual, and answer tags corresponding to the sample questions to be answered.
8. A question-and-answer device based on a CNC machine tool operation manual, characterized in that, include: The word feature module is used to obtain the question to be answered and to obtain the initial word vector features corresponding to the question to be answered based on the word vector extraction model. The sentence feature module is used to input the initial word vector features corresponding to the question to be answered into the trained semantic model, and obtain the sentence features corresponding to the question to be answered output by the semantic model; The matching module is used to determine the target corpus segment based on the sentence features corresponding to the question to be answered, as specified in the operation manual. The answering module is used to input the question to be answered and the target corpus into the trained question-answering model in segments, and obtain the answer output by the question-answering model; The semantic model is trained based on multiple sets of first training data, each set of first training data including the initial word vector features corresponding to each sample sentence in the sample text; the training process of the semantic model includes: The initial word vector features corresponding to each sample sentence in the sample text are input into the semantic model to obtain the sample sentence features corresponding to each sample sentence output by the semantic model. After occluding the first sample sentence feature in the sample sentence features corresponding to each sample sentence in the sample text, the feature is input into the prediction model to obtain the first prediction value of the first sample sentence feature output by the prediction model. The target training loss is determined based on the first predicted value and the first sample sentence features, and the parameters of the prediction model and the semantic model are updated based on the target training loss.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the question-and-answer method based on the CNC machine tool operation manual as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the question-and-answer method based on the CNC machine tool operation manual as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Question and answer matching method, training method of text matching model and related equipment
CN113342958A
Intelligent question and answer method, device and equipment and storage medium
CN114416927A