A Method for Mechanical Manufacturing Knowledge Q&A with Collaboration of Large Models and Multiple Agents
Through the mechanical manufacturing knowledge question-and-answer method of large-model multi-agent collaborative mechanical manufacturing knowledge question-and-answer, the collaboration between central agents and retrieval agents, combined with the dual-way recall method of sparse and intensive retrieval, the knowledge blind spots and inaccurate answers of a single large-model in the knowledge question-and-answer field of mechanical manufacturing is solved, and the timeliness and accuracy of knowledge is improved.
Patent Information
- Application Number
- CN202411757786.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2044-12-03
AI Technical Summary
When a single large model deals with complex and diverse knowledge Q&A tasks in the field of mechanical manufacturing, there are blind spots in knowledge and inaccurate answers. The existing blocking strategy leads to incomplete context, affecting the efficiency and accuracy of knowledge retrieval.
The mechanical manufacturing knowledge question-and-answer method is adopted with large-model multi-agent collaborative mechanical manufacturing knowledge question-and-answer method, and the central agent is responsible for receiving, judging and decomposing problems, and the search agent is used to perform multi-step reasoning, combining the dual-way recall method of sparse and intensive retrieval, optimize task allocation and collaboration, and improve the efficiency and accuracy of knowledge retrieval.
The timeliness and accuracy of the knowledge of large models in the field of mechanical manufacturing is achieved, the multi-step reasoning ability to deal with complex problems is enhanced, the task allocation and collaboration in multi-agent systems is optimized, and the efficiency and accuracy of knowledge retrieval is improved.
Smart Images

Figure CN119227817B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and particularly relates to a method for mechanical manufacturing knowledge question answering with multi-agent collaboration of large models. Background Art
[0002] With the rapid development of artificial intelligence technology, especially the breakthroughs in the field of deep learning, the application of large language models (large models) has become a key force driving innovation in many fields. Through their powerful representation and generalization capabilities, large models have demonstrated excellent performance in multiple tasks such as text generation, sentiment analysis, and machine translation. Applying artificial intelligence large model technology to solve specific problems in the field of mechanical manufacturing can comprehensively improve the problem response speed and production efficiency in the field of mechanical manufacturing.
[0003] Due to the professional and time-sensitive nature of knowledge in the field of mechanical manufacturing, as well as the high complexity and dynamic changes of knowledge questions in the field of mechanical manufacturing, a single general large model faces certain limitations. On the one hand, the general large model is based on a fixed training dataset, and its knowledge base is static and difficult to update in real time. Therefore, when dealing with newly emerging knowledge or knowledge in specific fields, there may be knowledge blind spots, resulting in inaccurate answers. On the other hand, when facing complex and diverse knowledge question answering tasks, a single large model has obvious limitations and often has difficulty balancing efficiency and effectiveness. In mechanical manufacturing knowledge question answering tasks that require multi-step reasoning or multi-source knowledge integration, a single large model is difficult to provide accurate and comprehensive answers.
[0004] When constructing a knowledge base, it is necessary to perform chunking on the text. Existing chunking strategies usually rely on punctuation marks and preset text lengths, which can lead to incomplete contexts and contain too much irrelevant information, thereby reducing the efficiency and accuracy of knowledge retrieval and affecting the quality of the final answer; in the knowledge recall stage, existing methods adopt a single-path recall method, and the knowledge recall effect is not good; in fuzzy retrieval such as keyword-based knowledge retrieval, existing methods calculate the similarity between two strings by calculating the "edit distance" between the two strings, and the calculation is redundant, increasing the processing time. Summary of the Invention
[0005] To solve the deficiencies of the existing technology, achieve the goals of improving the timeliness and accuracy of large model knowledge in the field of mechanical manufacturing, enhancing the multi-step reasoning ability when dealing with complex problems, optimizing task allocation and collaboration in the multi-agent system, and improving the efficiency and accuracy of knowledge retrieval, the present invention adopts the following technical solutions:
[0006] A method for mechanical manufacturing knowledge question answering with multi-agent collaboration of large models, including the following steps:
[0007] Step 1: Obtain problems in the field of mechanical manufacturing, input them together with pre-set strategy configuration prompt words into the central intelligent agent, and the central intelligent agent determines whether to adopt a parallel strategy to solve the problems;
[0008] Step 2: The central intelligent agent determines the decomposition method of the problem according to the strategy executed for the problem, and the decomposition methods include parallel decomposition;
[0009] Step 3: For the parallel decomposition method of the problem, the central intelligent agent splits the problem into multiple independent sub-problems, inputs them into the retrieval intelligent agent for multi-step reasoning, obtains the answers to the corresponding sub-problems respectively, and then inputs the answers to multiple sub-problems into the central intelligent agent to get the final answer.
[0010] Furthermore, the strategy configuration prompt words in Step 1 are the explanatory texts and specific reasoning steps of two execution strategies, which are used to guide the model to think and respond in an organized manner when facing complex problems. The construction of the central intelligent agent includes the following steps:
[0011] Step 1.1: Obtain various types of problems in the field of mechanical manufacturing, classify them according to the complexity of the problems and the types of questions. According to the complexity, they are divided into simple reasoning problems and complex reasoning problems. According to the types of questions, they are divided into single-choice questions, multiple-choice questions, and short-answer questions;
[0012] Step 1.2: Construct a multi-step reasoning data set for mechanical manufacturing problems applicable to the central intelligent agent, including a serial reasoning data set and a parallel reasoning data set for the central intelligent agent. Set the format of the prompt words obtained by the large model through the parallel reasoning data set to define the task strategy to be completed by the large model, and set the formats of the user input content and the large model answer content;
[0013] Step 1.3: Use the serial reasoning data set and the parallel reasoning data set of the central intelligent agent to fine-tune and train the Qwen2.5-14b large language model. Train the large language model through the data set with a defined format. By learning a large number of dialogue turns, enable the large language model to learn the decomposition method of the user input problems and how to generate appropriate responses according to the problems. Calculate the loss value based on the difference between the model output and the expected output. When the loss value in the training process tends to be stable after multiple iterations and no longer decreases significantly, stop the model training, and use the model state at this time as the final training result to obtain the central intelligent agent model.
[0014] Furthermore, in Step 1.1, simple reasoning problems refer to problems that do not contain sub-problems and problems that can be disassembled into multiple parallel sub-problems; complex reasoning problems refer to problems that can be disassembled into multiple serial sub-problems.
[0015] Furthermore, the format of the parallel reasoning data set of the central intelligent agent is:
[0016] System Prompt:
[0017] Step 1: Decompose the original problem in parallel, splitting the original problem into multiple independent sub - problems; Step 2: Answer the original problem based on the answers to the multiple sub - problems;
[0018] User Content:
[0019] The original problem;
[0020] Assistant Content:
[0021] Multiple sub - problems obtained by the large - model parallelly decomposing the original problem according to Step 1 of the prompt;
[0022] User Content:
[0023] Answers to multiple sub - problems;
[0024] Assistant Content:
[0025] The answer to the original problem obtained by the large - model according to Step 2 of the prompt, based on the answers to the multiple sub - problems;
[0026] Among them, System Prompt represents the prompt input to the large - model, defining the task strategy it needs to complete. User Content represents the content input by the user (the content input to the large - model), and Assistant Content represents the content answered by the large - model. Based on the problem, a decomposition strategy is obtained, and a set of sub - problems and their corresponding answers are obtained according to the decomposition strategy, so as to obtain the answer to the final problem.
[0027] Furthermore, the multi - step reasoning dataset also includes a central agent serial reasoning dataset, and the Qwen2.5 - 14b large - language model is fine - tuned and trained using the central agent serial reasoning dataset and the central agent parallel reasoning data;
[0028] For the way of serial decomposition of problems, the central agent splits the problem into a series of ordered solution steps according to a certain logical order. First, it disassembles Problem 1 and inputs Problem 1 into the retrieval agent multi - step reasoning module to obtain the answer to Problem 1. Then, the central agent disassembles Problem 2 based on the answer to Problem 1 and the original problem, and so on, until the final answer is obtained.
[0029] Furthermore, the format of the central agent serial reasoning dataset is:
[0030] System Prompt:
[0031] Step 1: Serially decompose the original question, split the original question in logical order, and first split out the first question; Step 2: Determine whether the original question can be answered based on the answer to the first question. If it can, directly generate the answer to the original question. Otherwise, generate the second question based on the original question and the answer to the first question, and so on, until the final answer to the original question is generated;
[0032] User Content:
[0033] Original question;
[0034] Assistant Content:
[0035] The large model serially decomposes the original question according to Step 1 of the prompt to obtain the first question;
[0036] User Content:
[0037] Answer to the first question;
[0038] Assistant Content:
[0039] The large model, according to Step 2 of the prompt, generates the answer to the original question when it can answer the original question based on the answer to the first question, or generates the second question when it cannot answer the original question;
[0040] User Content:
[0041] Answer to the second question;
[0042] Assistant Content:
[0043] The large model, according to Step 2 of the prompt, makes a judgment based on the answer to the second question and generates the answer to the original question or the answer to the third question, and so on, until the final answer to the original question is obtained;
[0044] Among them, System Prompt represents the prompt input to the large model, defining the task strategy it needs to complete. User Content represents the content input by the user (the content input to the large model), and Assistant Content represents the content answered by the large model. Based on the question, a decomposition strategy is obtained, and a set of sub-questions and their corresponding answers are obtained according to the decomposition strategy, so as to obtain the answer to the final question.
[0045] Furthermore, in Step 3, the multi-step reasoning of the retrieval agent includes the following steps:
[0046] Step 3.1: Obtain the question to be retrieved and the retrieval prompt. Extract keywords and retrieval phrases according to the question to be retrieved, and assign weights to each keyword;
[0047] Step 3.2: Conduct sparse retrieval on the retrieval keywords and weights, and conduct dense retrieval on the retrieval phrases.
[0048] Step 3.3: Input the retrieved knowledge into the retrieval agent. The retrieval agent determines whether the retrieved knowledge is sufficient to accurately answer the question by evaluating it, and decides whether further queries are needed. If further queries are needed, the retrieval agent regenerates more accurate or extended keywords and phrases based on the existing retrieval results, and repeats Steps 3.2 and 3.3 until the retrieval agent confirms that sufficient information has been obtained and generates the sub-question answer. If no further queries are needed, the retrieval agent directly generates the sub-question answer based on the existing retrieval results.
[0049] Furthermore, obtain questions in the field of mechanical manufacturing, extract sub-questions, and construct a multi-step reasoning dataset applicable to the retrieval agent. The dataset format is:
[0050] System Prompt:
[0051] Step 1: Extract keywords and retrieval phrases from the question, and assign weights to each keyword. Step 2: Evaluate whether the relevant knowledge retrieved based on the keywords and retrieval phrases is accurate enough to answer the question, and decide whether further queries are needed. If so, regenerate new keywords and query phrases. If not, answer the question based on the relevant knowledge. And so on, iteratively execute the logic of Steps 1 and 2 until the final relevant knowledge is generated to answer the question.
[0052] User Content:
[0053] Question;
[0054] Assistant Content:
[0055] The large model extracts keywords and retrieval phrases according to Step 1 of the retrieval prompt.
[0056] User Content:
[0057] The relevant knowledge text retrieved according to the keywords, and the relevant knowledge text retrieved according to the retrieval phrases;
[0058] Assistant Content:
[0059] The large model, according to Step 2 of the retrieval prompt, the relevant knowledge text retrieved by the keywords and the retrieval phrases that is sufficient to accurately answer the question;
[0060] Among them, System Prompt represents the retrieval prompt words input to the large model, defining the task strategy to be completed. User Content represents the content input by the user (the content input to the large model), and Assistant Content represents the content answered by the large model. Based on the task strategy, the retrieved answer is obtained.
[0061] The retrieval agent model is obtained by fine-tuning and training the Qwen2.5-14b large language model using the retrieval agent multi-step reasoning dataset.
[0062] Further, the sparse retrieval in step 3.2 includes the following steps:
[0063] Step 3.2.1.1: Obtain the knowledge text in the field of mechanical manufacturing and perform text segmentation to obtain multiple short texts;
[0064] Step 3.2.1.2: Calculate the similarity between the keyword and the short text using the Levenshtein distance algorithm based on dynamic programming. Using dynamic programming to optimize the Levenshtein distance algorithm can reduce the space complexity and improve the performance. The specific implementation of the Levenshtein distance algorithm based on dynamic programming is as follows:
[0065] Step 3.2.1.2.1: Initialization:
[0066] Let be the keyword string of length m, the short text string of length n;
[0067] Use the previous row array and the current row array :
[0068] Initialize the array ,
[0069] Initialize the array ,
[0070] Step 3.2.1.2.2: Calculate the minimum edit distance of the strings and at each position based on the dynamic programming method; by traversing each character of , for each character of , traverse each character of to loop and execute the calculation of the minimum edit distance:
[0071]
[0072] Among them,
[0073] Step 3.2.1.2.3: Update status:
[0074] Perform row data update:
[0075] After calculating the data of the current row, save the current row data as the data of the previous row, that is, update the current row array current to the previous row array previous, so that the results of the previous row can be utilized for the next calculation, which can achieve the dependency relationship of dynamic programming and save space at the same time;
[0076] Step 3.2.1.2.4: Calculate the final Levenshtein distance:
[0077]
[0078] Among them, after iterating through all rows, it contains the final result, that is, the minimum edit distance for matching all characters of the string with all characters of ;
[0079] Step 3.2.1.2.5: Calculate the similarity score:
[0080]
[0081] Step 3.2.1.3: Traverse all short texts, calculate their similarities with multiple keywords, and return the texts with similarities higher than the threshold; for each short text in the short text set , if there exists a keyword in the keyword set such that the similarity between the short text and the keyword is greater than the set threshold , then the short text will be included in the result set ; The implementation formula is as follows:
[0082]
[0083]
[0084] Among them, represents the short text set, , is the th short text; represents the keyword set, , is the a keyword; indicating the calculation of short text and the keyword between the similarities, indicating the weight of the keyword, indicating the set similarity threshold; is a set of short texts that meet the conditions, that is, a set of short texts with similarities higher than the threshold.
[0085] Furthermore, the dense retrieval in step 3.2 includes the following steps:
[0086] Step 3.2.2.1: Obtain knowledge texts in the field of mechanical manufacturing, and use a large model-based text semantic segmentation method to segment the knowledge texts in the field of mechanical manufacturing into text blocks, which specifically includes the following steps:
[0087] Step 3.2.2.1.1: Perform sentence segmentation on the input text to obtain multiple sentences;
[0088] Such as sentence 1, sentence 2, sentence 3... until sentence n. The sentence set can be expressed as:
[0089]
[0090] Step 3.2.2.1.2: Starting from the first sentence, sequentially take the current sentence, the next sentence, and a preset semantic segmentation prompt word as input;
[0091] The input can be expressed as:
[0092]
[0093] Step 3.2.2.1.3: Pass the input to the text semantic segmentation large model (SplitLLM). The text semantic segmentation large model decides whether two sentences are merged into a larger paragraph (block) or segmented (kept independent) according to the semantics of the sentences; The text semantic segmentation large model uses the Qwen2.5 - 14b large language model. The decision-making ( ) process can be expressed as:
[0094]
[0095] Step 3.2.2.1.4: If it is decided to splice, then merge the previous sentence (such as Sentence 1) and the next sentence (such as Sentence 2) into a block (such as Block 1), and then input the merged block (such as Block 1), the next sentence (such as Sentence 3), and the semantic segmentation prompt word into the text semantic segmentation large model again; if it is decided to split, then directly input the next sentence (such as Sentence 2), the next sentence (such as Sentence 3), and the semantic segmentation prompt word into the model;
[0096] The sentence processing procedures for deciding to splice (merge) and deciding to split (split) can be expressed as:
[0097]
[0098]
[0099]
[0100]
[0101]
[0102] Step 3.2.2.1.5: Repeat Step 3.2.2.1.2 to Step 3.2.2.1.4 until all sentences are processed, and finally output all the segmented text blocks;
[0103] The set of segmented text blocks can be expressed as:
[0104]
[0105] Step 3.2.2.2: Input the segmented text blocks into the semantic vector model to convert them into vector form, and store them in the vector database after establishing an index. The semantic vector model uses the gte-Qwen2-7B-instruct vector model, and the vector database uses the Faiss vector database;
[0106] Step 3.2.2.3: Input the retrieval phrase into the semantic vector model to obtain the retrieval phrase vector, recall relevant text blocks by calculating the semantic similarity between the retrieval phrase vector and the text block vectors in the vector database. The semantic similarity is achieved by calculating the cosine similarity between vectors.
[0107] The advantages and beneficial effects of the present invention are as follows:
[0108] A method for mechanical manufacturing knowledge Q&A with multi-agent collaboration of large models proposed by the present invention. The central agent is responsible for receiving, judging, and decomposing questions, while the retrieval agent is responsible for answering specific sub-questions through multi-step reasoning. This collaboration mode has clear division of labor, enabling the entire system to efficiently and accurately handle various complex problems. The present invention also proposes a text semantic segmentation method based on large models, which can more precisely analyze the meaning of long texts and reasonably segment the texts according to semantics, thereby improving the accuracy of subsequent retrieval and reasoning. The present invention utilizes an external mechanical manufacturing knowledge base to obtain additional information to assist in generating large model answers, expanding the domain knowledge of the large model, and enhancing the accuracy and professionalism of the answers. The present invention proposes a knowledge dual-channel recall method combining sparse retrieval and dense retrieval, and proposes a Levenshtein distance algorithm based on dynamic programming in the sparse retrieval stage to improve the quality and efficiency of information retrieval and recall in a large-scale mechanical manufacturing knowledge base, thereby enhancing the reliability and professionalism of mechanical manufacturing knowledge answer generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0109] Figure 1 is a flowchart of the method in an embodiment of the present invention.
[0110] Figure 2 is a schematic structural diagram of the multi-step reasoning module of the retrieval agent in an embodiment of the present invention.
[0111] Figure 3 is a schematic structural diagram of the sparse retrieval module in an embodiment of the present invention.
[0112] Figure 4 is a schematic structural diagram of the dense retrieval module in an embodiment of the present invention.
[0113] Figure 5 is a schematic structural diagram of the text semantic segmentation module based on large models in an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0114] The following further describes in detail the specific embodiments of the present invention with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only for explaining and illustrating the present invention, and are not used to limit the present invention.
[0115] As Figure 1 shown, a method for mechanical manufacturing knowledge Q&A with multi-agent collaboration of large models of the present invention includes the following steps:
[0116] Step 1: Obtain a question in the mechanical manufacturing field, input the question in the mechanical manufacturing field and a preset policy configuration prompt word into the central agent, and the central agent determines whether to adopt a parallel policy to solve the question;
[0117] The strategy configuration prompt words are the explanatory texts and specific reasoning steps for the two strategies, which are used to guide the model to think and respond systematically when facing complex problems. The construction of the central intelligent agent includes the following steps:
[0118] Step 1.1: Obtain various types of problems in the field of mechanical manufacturing. The various types of problems in the field of mechanical manufacturing can be divided into two categories according to the complexity of the problems: simple reasoning problems and complex reasoning problems; according to the question types, they can be divided into single-choice questions, multiple-choice questions, and short-answer questions.
[0119] Furthermore, the simple reasoning problems in Step 1.1 refer to problems that do not contain sub-problems and problems that can be disassembled into multiple parallel sub-problems. For example: "Fill in the blank: Which connector type is used for the RRU5152-fad antenna?", "Short-answer question: What is the spindle speed range of the CK6140 CNC lathe, and what are the maximum machining diameter and maximum machining length of the CK6140 respectively?", "Multiple-choice question: Which of the following interface standards are used for the connection between the following systems?, [A. The G2BSC of ALCTEL and the NSS connection use the X25 interface, B. The G2BSC of ALCTEL and the NSS connection use the Q3 interface, C. The OMCR and the NMC connection use the X25 interface, D. The OMCR and the NMC connection use the Q3 interface]".
[0120] The complex reasoning problems in Step 1.1 refer to problems that can be disassembled into multiple serial sub-problems. For example: "Fill in the blank: What method is generally used to achieve the machining accuracy requirements for the production method with very few fixtures?".
[0121] Step 1.2: Construct a multi-step reasoning dataset for mechanical manufacturing problems suitable for the central intelligent agent, including a central intelligent agent serial reasoning dataset and a central intelligent agent parallel reasoning dataset.
[0122] Furthermore, the format of the central intelligent agent parallel reasoning dataset is:
[0123] System Prompt: Use two strategies to answer questions. Strategy 1: Step 1: First, decompose the question in parallel, splitting the question into multiple independent sub-questions; Step 2: Answer the original question based on the answers to the multiple sub-questions. Strategy 2: Step 1: First, decompose the question serially, splitting the question in logical order, starting with the first question; Step 2: Determine whether the original question can be answered based on the answer to Question 1. If so, generate the answer directly. If not, generate Question 2 based on the original question and the answer to Question 1; Steps 3, 4, etc.: Repeat the logic of Step 2 until the final answer can be generated. User Content: Question: What is the spindle speed range of the CK6140 CNC lathe, and what are the maximum machining diameter and maximum machining length of the CK6140? Assistant Content: Step 1, the question can be decomposed in parallel into: Sub-question 1: 'What is the spindle speed range of the CK6140 CNC lathe?', Sub-question 2: 'What is the maximum machining diameter of the CK6140?', Sub-question 3: 'What is the maximum machining length of the CK6140?'. User Content: Answer corresponding to Sub-question 1: '.....', Answer corresponding to Sub-question 2: '.....', Answer corresponding to Sub-question 3: '.....'. Assistant Content: Step 2: Based on the answers to Sub-question 1, Sub-question 2, and Sub-question 3, the answer to the question 'What is the spindle speed range of the CK6140 CNC lathe, and what are the maximum machining diameter and maximum machining length of the CK6140?' is '......'.
[0124] System Prompt represents the premise prompt words input to the large model, defining the task it needs to complete; UserContent represents the content input by the user (the content input to the large model); Assistant Content represents the answer content of the large model. By using the dataset in this format to train the dialogue model, through learning a large number of dialogue rounds, the model can learn how to generate appropriate responses according to the user's input.
[0125] The format of the central intelligent agent serial reasoning dataset in Step 1.2 is:
[0126] System Prompt: Use two strategies to answer questions. Strategy 1: Step 1: First, decompose the question in parallel, splitting the question into multiple independent sub-questions; Step 2: Answer the original question based on the answers to the multiple sub-questions. Strategy 2: Step 1: First, decompose the question serially, splitting the question in logical order, starting with the first question; Step 2: Determine whether the original question can be answered based on the answer to Question 1. If so, generate the answer directly. If not, generate Question 2 based on the original question and the answer to Question 1; Steps 3, 4, etc.: Repeat the logic of Step 2 until the final answer can be generated. User Content: Question: What methods are generally used to meet the machining accuracy requirements in the production mode with extremely few fixtures? Assistant Content: Answer this question using Strategy 1. Step 1, serially decompose the question, and split out Question 1 according to the logical order: 'What is the production mode with extremely few fixtures?' User Content: Answer corresponding to Question 1: 'The production mode with extremely few fixtures is single-piece and small-batch production' Assistant Content: Step 2: The answer to Question 1 cannot answer the original question, generate Question 2: 'What methods are generally used to meet the machining accuracy requirements in single-piece and small-batch production?' User Content: Answer corresponding to Question 2: '......' AssistantContent: Step 2: The answer to Question 2 can answer the original question, the answer to the question: 'What methods are generally used to meet the machining accuracy requirements in the production mode with extremely few fixtures?' is: '.......'
[0127] Step 1.3: Use the constructed central agent serial inference dataset and the central agent parallel inference data to fine-tune and train the Qwen2.5-14b large language model. Calculate the loss value based on the difference between the model output and the expected output. When the loss value during the training process tends to be stable and no longer significantly decreases after multiple iterations, stop the model training and use the model state at this time as the final training result to obtain the central agent model.
[0128] Step 2: The central agent decides the problem decomposition method according to whether to adopt a parallel strategy, which can be divided into parallel decomposition and serial decomposition of the problem.
[0129] Step 3: Process the parallel decomposition and serial decomposition of the problem respectively to obtain the final answer.
[0130] For the parallel decomposition method of the problem, the central agent splits the problem into multiple independent sub-problems and inputs the multiple sub-problems into the retrieval agent multi-step reasoning module to obtain the answers corresponding to the sub-problems respectively. Finally, input the answers of the multiple sub-problems into the central agent to obtain the final answer.
[0131] As Figure 2 shown, the implementation of the retrieval agent multi-step reasoning module includes the following steps:
[0132] Step 3.1: Input the problem to be queried and the retrieval prompt words into the retrieval agent. The retrieval agent extracts keywords and retrieval phrases according to the problem to be retrieved, assigns weights to each keyword, and outputs the retrieval instruction:
[0133] Search-Keywords = {"k 1 ": w 1 , "k 2 ": w 2 , …, "k n ": w n}
[0134] Search-phrase = {"p 1 ", "p 2 ", …, "p n "}
[0135] where k 1 , k 2 …k n represent keywords 1, keyword 2… keyword n, and w 1 , w 2 …w n represent the weights corresponding to keywords 1, keyword 2… keyword n respectively; p 1, p 2 …p n represent retrieval phrases 1, retrieval phrases 2…retrieval phrases n.
[0136] Furthermore, the construction of the retrieval agent includes the following steps:
[0137] Obtain problems in the field of mechanical manufacturing, extract sub-problems, and construct a multi-step reasoning dataset applicable to the retrieval agent. The dataset format is:
[0138] System Prompt: Complete the task according to the following steps. Step 1: Extract keywords and retrieval phrases from the question, and assign weights to each keyword. Step 2: Evaluate whether the information retrieved based on the keywords and retrieval phrases is accurate enough to answer the question, and decide whether further queries are needed. If further queries are needed, regenerate more precise or extended keywords and query phrases; if no further queries are needed, answer the question based on the relevant knowledge. Step 3, 4, etc.: Iteratively execute the logic of Step 1 and Step 2 until a complete and accurate answer can be generated. User Content: Question: How is the timer T3168 sent down, and what is its role in the wireless system of GPRS One Phase? AssistantContent: Step 1: Extract keywords and search phrases from the question: Search-Keywords = {"timer T3168": 0.9, "sending method": 0.8, "GPRS One Phase": 0.8}, Search-phrase = {"sending method of timer T3168", "role of timer T3168 in the wireless system of GPRS One Phase"}. User Content: The relevant knowledge texts retrieved according to the keywords are: '.....'; The relevant knowledge texts retrieved according to the search phrases are: '.....'. Assistant Content: Step 2: The relevant knowledge texts retrieved by the keywords and the relevant knowledge texts retrieved by the search phrases are sufficient to accurately answer the question. {"Whether further queries are needed": "No"}. According to the relevant knowledge texts, the answer to the question 'How is the timer T3168 sent down, and what is its role in the wireless system of GPRS One Phase?' is '......'
[0139] Fine-tune and train the Qwen2.5-14b large language model using the multi-step reasoning dataset of the retrieval agent to obtain the retrieval agent model.
[0140] Step 3.2: Input the retrieval instruction into the retrieval module to obtain the retrieved knowledge. Among them, the retrieval keywords and weights are input into the sparse retrieval module, and the retrieval phrases are input into the dense retrieval module.
[0141] Furthermore, as Figure 3 shown, the implementation of the sparse retrieval module includes the following steps:
[0142] Step 3.2.1.1: Obtain the knowledge text in the field of mechanical manufacturing and perform text segmentation to obtain multiple short texts.
[0143] Step 3.2.1.2: Calculate the similarity between the keyword and the short text using the Levenshtein distance algorithm based on dynamic programming. Using dynamic programming to optimize the Levenshtein distance algorithm can reduce the space complexity and improve the performance. The specific implementation of the Levenshtein distance algorithm based on dynamic programming is:
[0144] Step 3.2.1.2.1: Initialization:
[0145] Let be the keyword string of length m, the short text string of length n.
[0146] Use the previous row array and the current row array :
[0147] Initialization ,
[0148] Initialization ,
[0149] Step 3.2.1.2.2: Calculate the strings and character by character based on the dynamic programming methodThe minimum edit distance at each position; by traversing each character of for each character of each character of
[0150]
[0151] where
[0152] Step 3.2.1.2.3: Update the status:
[0153] Perform row data update:
[0154] After calculating the data of the current row, save the current row data as the data of the previous row, that is, update the current row array current to the previous row array previous, so that the results of the previous row can be utilized for the next calculation, which can achieve the dependency relationship of dynamic programming and save space at the same time;
[0155] Step 3.2.1.2.4: Calculate the final Levenshtein distance:
[0156]
[0157] where, after iterating through all rows, contains the final result, that is, the minimum edit distance for matching all characters of the string with all characters of
[0158] Step 3.2.1.2.5: Calculate the similarity score:
[0159]
[0160] Step 3.2.1.3: Traverse all short texts to calculate the similarity with multiple keywords, and return the texts with similarity higher than the threshold. The specific implementation is as follows: For each short text in the short text set , if there exists a keyword in the keyword set such that the similarity between and is greater than the set threshold , then the short text will be included in the result set . The implementation formula is as follows:
[0161]
[0162]
[0163] Among them, represents a set of short texts, , is the th short text; represents a set of keywords, , is the th keyword; represents calculating the similarity between the short text and the keyword ; represents the weight of the th keyword, represents a set similarity threshold; is a set of short texts that meet the conditions, that is, a set of short texts with a similarity higher than the threshold.
[0164] Furthermore, as Figure 4 shown, the implementation of the dense retrieval module includes the following steps:
[0165] Step 3.2.2.1: Obtain knowledge texts in the field of mechanical manufacturing, and use a large model-based text semantic segmentation method to segment the knowledge texts in the field of mechanical manufacturing into text blocks. As Figure 5 shown, the implementation of the large model-based text semantic segmentation method is:
[0166] Step 3.2.2.1.1: Input the long text , and perform sentence segmentation on it to obtain multiple sentences, such as sentence 1, sentence 2, sentence 3... until sentence n. The sentence set can be expressed as:
[0167]
[0168] Step 3.2.2.1.2: Starting from sentence 1, sequentially take the current sentence (such as sentence 1), the next sentence (such as sentence 2), and a preset semantic segmentation prompt as the input. The input can be expressed as:
[0169]
[0170] Step 3.2.2.1.3: Pass the input from Step 3.2.2.1.2 to the Text Semantic Segmentation Large Model (SplitLLM). The Text Semantic Segmentation Large Model decides whether these two sentences should be merged into a larger paragraph (block) or split (kept independent) based on the semantics of the sentences. The Text Semantic Segmentation Large Model uses the Qwen2.5-14b large language model. The decision-making ( ) process can be expressed as:
[0171]
[0172] Step 3.2.2.4: If it is decided to splice, merge the previous sentence (e.g., sentence 1) and the next sentence (e.g., sentence 2) into a block (e.g., block 1), and then input the merged block (e.g., block 1), the next sentence (e.g., sentence 3), and the semantic segmentation prompt word into the Text Semantic Segmentation Large Model again; if it is decided to split, directly input the next sentence (e.g., sentence 2), the next sentence (e.g., sentence 3), and the semantic segmentation prompt word into the model. The sentence processing processes for deciding to merge and deciding to split can be expressed as:
[0173]
[0174]
[0175]
[0176]
[0177]
[0178] Step 3.2.2.5: Repeat Step 3.2.2.2 to Step 3.2.2.4 until all sentences are processed, and finally output all the segmented text blocks. The set of segmented text blocks can be expressed as:
[0179]
[0180] Step 3.2.2.2: Input the text blocks obtained in Step 3.2.2.1 into the semantic vector model to convert them into vector form, and store them in the vector database after establishing an index. The semantic vector model uses the gte-Qwen2-7B-instruct vector model, and the vector database uses the Faiss vector database.
[0181] Step 3.2.2.3: Input the retrieval phrase into the semantic vector model to obtain the retrieval phrase vector. Recall relevant text chunks by calculating the semantic similarity between the retrieval phrase vector and the text chunk vectors in the vector database. The semantic similarity is achieved by calculating the cosine similarity between vectors.
[0182] Step 3.3: Input the knowledge retrieved in Step 3.2 into the retrieval agent. The retrieval agent decides whether further queries are needed by evaluating whether the retrieved relevant knowledge is sufficient to accurately answer the question. If further queries are needed, the retrieval agent regenerates more precise or extended keywords and phrases based on the existing retrieval results. Repeat Steps 3.2 and 3.3 until the retrieval agent confirms that sufficient information has been obtained. Once this criterion is met, the agent generates sub-question answers based on the retrieved knowledge; if no further queries are needed, the retrieval agent directly generates sub-question answers based on the existing retrieval results.
[0183] For the way of serial decomposition of questions, the central agent decomposes the question into a series of ordered solution steps according to a certain logical order. First, decompose question 1 and input question 1 into the multi-step reasoning module of the retrieval agent to obtain the answer to question 1. Then, the central agent decomposes question 2 based on the answer to question 1 and the original question, and repeats the above operations until the final answer is obtained.
[0184] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A large-scale multi-agent collaborative mechanical manufacturing knowledge question-answering method, characterized by The steps include: Step 1: Obtain the problem in the field of mechanical manufacturing and input it and the preset strategy configuration prompt words into the central intelligent agent; Step 2: The central agent determines the decomposition method of the problem according to the problem execution strategy, and the decomposition method includes parallel decomposition; Step 3: For the parallel decomposition method, the central agent splits the problem into multiple independent sub-problems and inputs them into the retrieval agent for multi-step reasoning to obtain the answers to the corresponding sub-problems respectively. The answers to the multiple sub-problems are then input into the central agent to obtain the final answer. The multi-step reasoning of the retrieval agent is to obtain the search question and the search prompt word, extract keywords and search phrases according to the search question, assign weights to each keyword, perform sparse search on the search keywords and weights, and perform dense search on the search phrases; the sparse search includes the following steps: Step 3.2.1.1: Obtain knowledge text in the field of mechanical manufacturing and perform text segmentation to obtain multiple short texts; Step 3.2.1.2: Use a distance algorithm based on dynamic programming to calculate the similarity between keywords and short texts: Step 3.2.1.2.1: Initialization: Let S k is a keyword string of length m, S st A short text string of length n; Use the previous row array and the current row array: Initialize current[0]=i(0≤i≤m), Initialize previous[j]=j(0≤j≤n), Step 3.2.1.2.2: Calculate the string S character by character based on dynamic programming method k and S st The minimum edit distance at each position; by traversing S k For each character of S k For each character of S st The minimum edit distance is calculated for each character in a loop: current[j] = min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + cost) where, Step 3.2.1.2.3: Update status: Update row data: previous, current = current, previous After calculating the data of the current row, save the data of the current row as the data of the previous row, that is, update the array current of the current row to the array previous of the previous row; Step 3.2.1.2.4: Calculate the final Levenshtein distance: Levenshtein_distance(S k ,S st )=previous[n] Among them, after iterating over all rows, previous[n] contains the final result, that is, the string S k All characters with S st The minimum edit distance for all character matches; Step 3.2.1.2.5: Calculate the similarity score: Step 3.2.1.3: Traverse all short texts, calculate their similarity with multiple keywords, and return texts with similarity higher than a threshold; for a short text in a short text set, if there is a keyword in the keyword set such that the similarity between the short text and the keyword is greater than a set threshold, the short text will be included in the result set.
2. According to claim 1, a large-scale multi-agent collaborative mechanical manufacturing knowledge question-answering method is characterized by: The strategy configuration prompt in step 1 is the description and reasoning steps of the execution strategy. The construction of the central intelligent agent includes the following steps: Step 1.1: Obtain various types of problems in the field of mechanical manufacturing and classify them according to their complexity; Step 1.2: Construct a multi-step reasoning dataset for mechanical manufacturing problems suitable for the central agent, including a parallel reasoning dataset for the central agent. Through the parallel reasoning dataset, set the prompt word format obtained by the large model to define the task strategy to be completed by the large model, and set the format of the user input content and the large model answer content; Step 1.3: Use the central agent parallel reasoning data to fine-tune the large language model so that the large language model can decompose complex problems into multiple parallel sub-problems and generate accurate answers based on the problems to obtain the central agent.
3. The large-scale multi-agent collaborative mechanical manufacturing knowledge question-answering method according to claim 2 is characterized by: In step 1.1, the problems are divided into simple reasoning problems and complex reasoning problems according to their complexity. Simple reasoning problems refer to problems that do not contain sub-problems and problems that can be decomposed into multiple parallel sub-problems. Complex reasoning problems are those that can be broken down into multiple serial sub-problems.
4. The large-scale multi-agent collaborative mechanical manufacturing knowledge question-answering method according to claim 2 is characterized by: The format of the central agent parallel reasoning dataset is: System Prompt: Step 1: Parallel decomposition of the original problem into multiple independent sub-problems; Step 2: Answer the original question based on the answers to the multiple sub-problems; User Content: Original question; Assistant Content: The large model decomposes the original problem in parallel into multiple sub-problems according to step 1 of the prompt word; User Content: Answers to multiple sub-questions; Assistant Content: The large model obtains the answer to the original question based on the answers to multiple sub-questions according to step 2 of the prompt word; Among them, System Prompt represents the prompt word input to the big model, defining the task strategy to be completed; UserContent represents the content input by the user, that is, the content input to the big model; Assistant Content represents the content answered by the big model; a decomposition strategy is obtained based on the question, and a set of sub-questions and their corresponding answers are obtained according to the decomposition strategy, thereby obtaining the answer to the final question.
5. The large-scale multi-agent collaborative mechanical manufacturing knowledge question-answering method according to claim 2 is characterized by: The multi-step reasoning data set also includes a central agent serial reasoning data set, and the central agent serial reasoning data set and the central agent parallel reasoning data set are used to perform fine-tuning training on the large language model; For the serial decomposition method of the problem, the central intelligent agent breaks down the problem into a series of orderly solution steps in a logical order. It first breaks down problem 1 and inputs problem 1 into the multi-step reasoning module of the retrieval agent to get the answer to problem 1. Then the central intelligent agent breaks down problem 2 based on the answer to problem 1 and the original problem, and so on, until the final answer is obtained.
6. The large-scale multi-agent collaborative mechanical manufacturing knowledge question-answering method according to claim 5 is characterized by: The format of the central agent serial reasoning dataset is: System Prompt: Step 1: Decompose the original question in series, split the original question in logical order, and first split the first question; Step 2: Determine whether the answer to the first question can answer the original question, if so, directly generate the answer to the original question, otherwise, generate the second question based on the original question and the answer to the first question, and so on, until the final answer to the original question is generated; User Content: Original question; Assistant Content: The large model serially decomposes the original question according to step 1 of the prompt word to obtain the first question; User Content: The answer to the first question: Assistant Content: The large model generates an answer to the original question when it can answer the original question, or generates a second question when it cannot answer the original question, according to the answer to the first question in step 2 of the prompt word; User Content: The answer to the second question: Assistant Content: The large model makes a judgment based on the answer to the second question according to the prompt word step 2, and generates the answer to the original question or the answer to the third question, and so on, until the final answer to the original question is obtained; Among them, System Prompt represents the prompt word input to the big model, defining the task strategy to be completed; UserContent represents the content input by the user, that is, the content input to the big model; Assistant Content represents the content answered by the big model; a decomposition strategy is obtained based on the question, and a set of sub-questions and their corresponding answers are obtained according to the decomposition strategy, thereby obtaining the answer to the final question.
7. The large-scale multi-agent collaborative mechanical manufacturing knowledge question-answering method according to claim 1 is characterized by: In step 3, the multi-step reasoning of the retrieval agent includes the following steps: Step 3.1: Obtain the search question and search prompt words, extract keywords and search phrases according to the search question, and assign weights to each keyword; Step 3.2: Perform sparse search on search keywords and weights, and perform dense search on search phrases; Step 3.3: Input the retrieved knowledge into the retrieval agent. The retrieval agent will evaluate whether the retrieved knowledge is sufficient to accurately answer the question and decide whether further query is needed. If further query is needed, the retrieval agent will regenerate keywords and phrases based on the existing retrieval results and repeat steps 3.2 and 3.3 until the retrieval agent confirms that it has obtained sufficient information to generate answers to sub-questions. If further query is not needed, the retrieval agent will directly generate answers to sub-questions based on the existing retrieval results.
8. The large-scale multi-agent collaborative mechanical manufacturing knowledge question-answering method according to claim 7 is characterized by: Obtain problems in the field of mechanical manufacturing, extract sub-problems, and construct a multi-step reasoning dataset suitable for retrieval agents. The dataset format is: System Prompt: Step 1: Extract keywords and search phrases from the question and assign weights to each keyword; Step 2: Based on the relevant knowledge retrieved by the keywords and search phrases, evaluate whether the relevant knowledge is accurate enough to answer the question and decide whether further queries are needed; if necessary, regenerate new keywords and search phrases; If not, answer the question based on relevant knowledge, and so on, iterating the logic of steps 1 and 2 until the final relevant knowledge answer question is generated; User Content: question; Assistant Content: The large model extracts keywords and search phrases based on the search prompt words in step 1; User Content: Related knowledge texts retrieved based on keywords and related knowledge texts retrieved based on search phrases; Assistant Content: The large model uses the step 2 of the search prompt words to retrieve relevant knowledge texts that are sufficient to accurately answer the question based on the keywords and the search phrases; Among them, System Prompt represents the search prompt word input to the big model, defining the task strategy to be completed; User Content represents the content input by the user, that is, the content input to the big model; Assistant Content represents the content answered by the big model, and the search answer is obtained based on the task strategy; The large language model is fine-tuned using the retrieval agent multi-step reasoning dataset to obtain the retrieval agent.
9. The large-scale multi-agent collaborative mechanical manufacturing knowledge question-answering method according to claim 7 is characterized by: The intensive search in step 3.2 includes the following steps: Step 3.2.2.1: Obtain knowledge text in the field of mechanical manufacturing, and use a large model-based text semantic segmentation method to segment the knowledge text in the field of mechanical manufacturing into text blocks, which specifically includes the following steps: Step 3.2.2.1.1: Segment the input text into sentences to obtain multiple sentences; Step 3.2.2.1.2: Starting from the first sentence, take the current sentence, the next sentence and the preset semantic segmentation prompt words as input; Step 3.2.2.1.3: Pass the input to the text semantic segmentation model, which decides whether to merge or segment two sentences based on the semantics of the sentences; Step 3.2.2.1.4: If concatenation is decided, the previous sentence and the next sentence are merged into a block, and then the merged block, the next sentence and the semantic segmentation prompt words are input into the text semantic segmentation model again; if segmentation is decided, the next sentence, the next sentence and the semantic segmentation prompt words are directly input into the model; Step 3.2.2.1.5: Repeat steps 3.2.2.1.2 to 3.2.2.1.4 until all sentences are processed, and finally output all segmented text blocks; Step 3.2.2.2: Input the segmented text blocks into a semantic vector model to convert them into vector form, and store them in a vector database after indexing; Step 3.2.2.3: Input the search phrase into the semantic vector model to obtain the search phrase vector, and recall the relevant text blocks by calculating the semantic similarity between the search phrase vector and the text block vector in the vector database.
Citation Information
Patent Citations
Question and answer method and device, electronic equipment and storage medium
CN116955561A
Knowledge vector library construction method, device, equipment, system and storage medium
CN117422136A